File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,9 @@ jobs:
170170 platforms : linux/${{ matrix.arch }}
171171 tags : ${{ steps.meta.outputs.tags }}
172172 labels : ${{ steps.meta.outputs.labels }}
173+ build-args : |
174+ VERSION=${{ github.ref_type == 'tag' && github.ref_name || '' }}
175+ COMMIT_HASH=${{ github.sha }}
173176 - name : Attest Docker Hub image
174177 uses : actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 https://github.com/actions/attest-build-provenance/releases/tag/v3.0.0
175178 with :
Original file line number Diff line number Diff line change 11FROM ghcr.io/blinklabs-io/go:1.25.4-1 AS build
22
3+ ARG VERSION
4+ ARG COMMIT_HASH
5+ ENV VERSION=${VERSION}
6+ ENV COMMIT_HASH=${COMMIT_HASH}
7+
38WORKDIR /code
49RUN go env -w GOCACHE=/go-cache
510RUN go env -w GOMODCACHE=/gomod-cache
Original file line number Diff line number Diff line change @@ -10,13 +10,15 @@ BINARIES=$(shell cd $(ROOT_DIR)/cmd && ls -1 | grep -v ^common)
1010# Extract Go module name from go.mod
1111GOMODULE =$(shell grep ^module $(ROOT_DIR ) /go.mod | awk '{ print $$2 }')
1212
13- # Set version strings based on git tag and current ref
14- GO_LDFLAGS =-ldflags "-s -w -X '$(GOMODULE ) /internal/version.Version=$(shell git describe --tags --exact-match 2>/dev/null) ' -X '$(GOMODULE ) /internal/version.CommitHash=$(shell git rev-parse --short HEAD) '"
13+ # Set version strings: use env vars if set, else git
14+ VERSION ?= $(shell git describe --tags --exact-match 2>/dev/null)
15+ COMMIT_HASH ?= $(shell git rev-parse --short HEAD)
16+ GO_LDFLAGS =-ldflags "-s -w -X '$(GOMODULE ) /internal/version.Version=$(VERSION ) ' -X '$(GOMODULE ) /internal/version.CommitHash=$(COMMIT_HASH ) '"
1517
1618.PHONY : all build mod-tidy clean format golines test bench test-load-profile
1719
1820# Default target
19- all : build test bench
21+ all : format golines build test
2022
2123# Build target
2224build : $(BINARIES )
You can’t perform that action at this time.
0 commit comments