From 5c3c92da282e029a38004cc237a0cffd8586afa5 Mon Sep 17 00:00:00 2001 From: Quick <31828688+Quick104@users.noreply.github.com> Date: Thu, 28 May 2026 18:46:56 -0400 Subject: [PATCH] build: stamp git revision via Makefile ldflags `make build` did not inject buildinfo's `revisionOverride`/`dirtyOverride` ldflags (the Dockerfile already does), so binaries built via make report their version as "unavailable" in the admin Build panel whenever Go's VCS metadata isn't embedded. Mirror the Dockerfile by computing the git revision + dirty state and passing them through `-ldflags -X`. Co-Authored-By: Claude Opus 4.8 (1M context) --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 32cff7f3..60a2eb4c 100644 --- a/Makefile +++ b/Makefile @@ -14,13 +14,20 @@ endif JELLYFIN_WEB_OUTPUT_DIR ?= third_party/jellyfin-web +# Build version stamping: inject the git revision so the admin Build panel shows a +# version even when Go's VCS metadata isn't embedded (mirrors the Dockerfile ldflags). +BUILDINFO_PKG := github.com/Silo-Server/silo-server/internal/buildinfo +BUILD_REVISION ?= $(shell git rev-parse HEAD 2>/dev/null) +BUILD_DIRTY ?= $(shell test -n "$$(git status --porcelain 2>/dev/null)" && echo true || echo false) +GO_LDFLAGS := -X $(BUILDINFO_PKG).revisionOverride=$(BUILD_REVISION) -X $(BUILDINFO_PKG).dirtyOverride=$(BUILD_DIRTY) + # Build the frontend (requires pnpm) frontend: cd web && pnpm install --frozen-lockfile && pnpm run build # Build the Go binary (depends on frontend) build: frontend - go build -o silo ./cmd/silo/ + go build -ldflags "$(GO_LDFLAGS)" -o silo ./cmd/silo/ # Run frontend dev server (proxies API to localhost:8080) dev-frontend: