diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 56b0dd9..614d888 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -20,6 +20,8 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} with: + build-args: | + VERSION=${{ github.ref_type == 'tag' && github.ref_name || github.sha }} output: image push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 diff --git a/Dockerfile b/Dockerfile index 143262f..49a99ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,9 +12,10 @@ COPY . . # Architecture and OS are set dynamically (by BuildKit) ARG TARGETOS ARG TARGETARCH +ARG VERSION=dev ENV CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH -RUN go build -o anonymousoverflow && go build -o healthcheck ./src/healthcheck +RUN go build -ldflags="-X anonymousoverflow/config.Version=${VERSION#v}" -o anonymousoverflow && go build -o healthcheck ./src/healthcheck FROM scratch diff --git a/config/version.go b/config/version.go index d2a1fa2..f356490 100644 --- a/config/version.go +++ b/config/version.go @@ -1,3 +1,3 @@ package config -var Version = "1.13.0" +var Version = "dev"