From 3da9227f2cefbe956ae5b960f0e32ee9a80bf0d8 Mon Sep 17 00:00:00 2001 From: Adrian PETERCA Date: Mon, 8 Jun 2026 09:56:20 +0300 Subject: [PATCH] Added versioning inside the binary --- .github/workflows/cd.yml | 4 +++- .github/workflows/docker-dev.yml | 2 ++ Dockerfile | 3 ++- config.go | 3 +++ main.go | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b3ad37f..57e9398 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -51,4 +51,6 @@ jobs: push: true tags: | ghcr.io/${{ github.repository }}:latest - ghcr.io/${{ github.repository }}:${{ github.ref_name }} \ No newline at end of file + ghcr.io/${{ github.repository }}:${{ github.ref_name }} + build-args: | + VERSION=${{ github.ref_name }} \ No newline at end of file diff --git a/.github/workflows/docker-dev.yml b/.github/workflows/docker-dev.yml index ac7a974..b8708e8 100644 --- a/.github/workflows/docker-dev.yml +++ b/.github/workflows/docker-dev.yml @@ -30,3 +30,5 @@ jobs: tags: | ghcr.io/${{ github.repository }}:dev ghcr.io/${{ github.repository }}:dev-${{ github.sha }} + build-args: | + VERSION=dev-${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index f30ffd2..7bdd558 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,8 @@ COPY static/ ./static/ COPY templates/ ./templates/ COPY *.go ./ -RUN CGO_ENABLED=0 GOOS=linux go build -o curier . +ARG VERSION=dev +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X main.version=${VERSION}" -o curier . FROM scratch diff --git a/config.go b/config.go index 07c286f..ad84e5b 100644 --- a/config.go +++ b/config.go @@ -13,6 +13,9 @@ var templateFiles embed.FS var shareTemplate *template.Template +// Will be updated by ldflags +var version = "dev" + // All variables can be overwritten by using environment variables. // All env vars need to start with `CURIER_` followed by the variable name in uppercase, each word separated with an underscore. // diff --git a/main.go b/main.go index d457106..f19749a 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,8 @@ import ( func main() { + log.Printf("Starting curier %s\n", version) + parseEnvVars() parseFS()