feat(version): bake release tag into binary; About card and /health field
Release / build-and-push (push) Successful in 3m1s

The version tag previously existed only in git and the Docker image tag —
the running app had no way to report what build it was. Version is now
injected at build time via -ldflags into internal/version.Version (defaults
to "dev" for local builds), passed by the release workflow as the
APP_VERSION Docker build arg from the pushed tag.

Surfaced in Admin → Settings → About (extensible card for future rows like
disk space) and in the /health JSON response, so deployments can be
verified with curl alone.
This commit is contained in:
John O'Keefe
2026-09-21 20:21:43 -04:00
parent 9e4cc4efd0
commit 1c1f5cf1bb
6 changed files with 121 additions and 20 deletions
+8 -1
View File
@@ -37,10 +37,17 @@ RUN cd templates && templ generate
RUN npm run build:css:prod
RUN npm run build:ts
# App version baked into the binary (shown in Admin → Settings → About).
# Declared after `COPY . .` so a version bump only invalidates this layer.
# The release workflow passes the git tag, e.g. APP_VERSION=v1.5.
ARG APP_VERSION=dev
# Build Go binary (cached unless Go files or generated code changes)
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o main ./cmd/server
CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo \
-ldflags "-X bookhoard/internal/version.Version=${APP_VERSION}" \
-o main ./cmd/server
# Materialize the Go module cache into an image layer so the test-runner
# stage can restore it. GOMODCACHE is /go/pkg/mod; cache mounts elsewhere are