Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
id: build-meta
run: |
echo "version=$(make version)" >> $GITHUB_OUTPUT
echo "git_commit=$(make get-commit-hash)" >> $GITHUB_OUTPUT
echo "build_date=$(make get-build-date)" >> $GITHUB_OUTPUT

- name: Extract metadata (tags, labels) for Docker
Expand All @@ -71,7 +70,6 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
ROXIE_VERSION=${{ steps.build-meta.outputs.version }}
GIT_COMMIT=${{ steps.build-meta.outputs.git_commit }}
BUILD_DATE=${{ steps.build-meta.outputs.build_date }}
cache-from: |
type=gha
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ jobs:
id: version
run: |
echo "version=$(make version)" >> $GITHUB_OUTPUT
echo "git_commit=$(make get-commit-hash)" >> $GITHUB_OUTPUT
echo "build_date=$(make get-build-date)" >> $GITHUB_OUTPUT

- name: Build binaries for multiple platforms
env:
VERSION: ${{ steps.version.outputs.version }}
GIT_COMMIT: ${{ steps.version.outputs.git_commit }}
BUILD_DATE: ${{ steps.version.outputs.build_date }}
run: |
LDFLAGS="-X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT} -X main.buildDate=${BUILD_DATE}"
LDFLAGS="-X main.version=${VERSION} -X main.buildDate=${BUILD_DATE}"

# Linux amd64
GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o roxie-linux-amd64 ./cmd
Expand Down
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ COPY . .
# Build roxie binary with version info and cross-compilation support
ARG ROXIE_VERSION
ARG BUILD_DATE
ARG GIT_COMMIT
RUN CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
ROXIE_VERSION=${ROXIE_VERSION} \
BUILD_DATE=${BUILD_DATE} \
GIT_COMMIT=${GIT_COMMIT} \
make build

# Download gcloud SDK in builder stage to avoid UBI filesystem restrictions
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ PKG_LIST := $(shell $(GOCMD) list ./... | grep -v /vendor/)
BUILD_DIR := .
BINARY := $(BUILD_DIR)/$(BINARY_NAME)

# Version information
GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
# Convention is that the git tags are of the form
# v<major>.<minor>.<patch>-<build-number>-<commit-hash>[-dirty]
# or v<major>.<minor>.<patch>
Expand All @@ -31,16 +29,12 @@ GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
# This will also become the tag of the docker images.
ROXIE_VERSION ?= $(shell git describe --tags --always --dirty | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+-[0-9]+-[a-z0-9]+(-dirty)?$$)/\1/')
BUILD_DATE ?= $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -X main.version=$(ROXIE_VERSION) -X main.gitCommit=$(GIT_COMMIT) -X main.buildDate=$(BUILD_DATE)
LDFLAGS := -X main.version=$(ROXIE_VERSION) -X main.buildDate=$(BUILD_DATE)

.PHONY: get-build-date
get-build-date:
@echo $(BUILD_DATE)

.PHONY: get-commit-hash
get-commit-hash:
@echo $(GIT_COMMIT)

.PHONY: version
version:
@echo $(ROXIE_VERSION)
Expand Down Expand Up @@ -210,7 +204,6 @@ docker-build: ## Build roxie Docker image for current platform
fi
$(CONTAINER_RUNTIME) build \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG) \
-t $(IMAGE_VERSION_TAG) \
Expand All @@ -230,7 +223,6 @@ docker-build-arm64: ## Build roxie Docker image for arm64
$(CONTAINER_RUNTIME) build \
--platform linux/arm64 \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG)-arm64 \
-t $(IMAGE_VERSION_TAG)-arm64 \
Expand All @@ -249,7 +241,6 @@ docker-build-amd64: ## Build roxie Docker image for amd64
$(CONTAINER_RUNTIME) build \
--platform linux/amd64 \
--build-arg ROXIE_VERSION=$(ROXIE_VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_DATE=$(BUILD_DATE) \
-t $(IMAGE_LATEST_TAG)-amd64 \
-t $(IMAGE_VERSION_TAG)-amd64 \
Expand Down
7 changes: 1 addition & 6 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
var (
// Version information set at build time via -ldflags
version = "dev"
gitCommit = "unknown"
buildDate = "unknown"
)

Expand All @@ -25,11 +24,7 @@ func newVersionCmd() *cobra.Command {
}

func runVersion(cmd *cobra.Command, args []string) {
if gitCommit != "unknown" && gitCommit != "" {
fmt.Printf("roxie version %s-%s", version, gitCommit)
} else {
fmt.Printf("roxie version %s", version)
}
fmt.Printf("roxie version %s", version)

if buildDate != "unknown" && buildDate != "" {
fmt.Printf(" (%s)", buildDate)
Expand Down
18 changes: 0 additions & 18 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,9 @@
let
pkgs = nixpkgs.legacyPackages.${system};

# Get git commit hash (short version - first 8 chars)
# Uses builtins.readFile to get hash even from dirty repos
gitCommit =
let
shortRev = self.shortRev or null;
dirtyRev = builtins.readFile (pkgs.runCommand "git-hash" {
nativeBuildInputs = [ pkgs.git ];
} ''
git -C ${./.} rev-parse --short=8 HEAD > $out 2>/dev/null || echo "unknown" > $out
'');
cleanDirtyRev = pkgs.lib.strings.removeSuffix "\n" dirtyRev;
in
if shortRev != null then shortRev
else if self ? rev then "${cleanDirtyRev}-dirty"
else cleanDirtyRev;

# Build roxie
roxie = pkgs.buildGoModule {
pname = "roxie";
Comment thread
AlexVulaj marked this conversation as resolved.
version = "0.1-${gitCommit}";

src = ./.;

Expand All @@ -41,7 +24,6 @@
# Inject version information at build time
ldflags = [
"-X main.version=0.1"
"-X main.gitCommit=${gitCommit}"
"-X main.buildDate=1970-01-01T00:00:00Z"
];

Expand Down
Loading