From 4f61583105d7ec3e741b73d7c04e76e1ad3cb976 Mon Sep 17 00:00:00 2001 From: vlnst Date: Wed, 7 Oct 2026 02:01:08 +0300 Subject: [PATCH] feat: set version from git tag at build time --- .github/workflows/docker-image.yml | 2 ++ Dockerfile | 3 ++- config/version.go | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) 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"