From 0015b6d27cf34a65081ecc6283830b06ba35e29f Mon Sep 17 00:00:00 2001 From: charlie4284 Date: Mon, 1 Jun 2026 12:55:23 +0800 Subject: [PATCH] fix(rock): embed GARM version via git describe in ldflags The garm binary was reporting v0.0.0-unknown because the build did not inject version information. Use git describe at build time to extract the version from the source-tag, matching upstream's Makefile approach. This ensures renovate bumps to source-tag automatically propagate to the embedded binary version without maintaining a duplicate variable. --- garm-rockcraft.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/garm-rockcraft.yaml b/garm-rockcraft.yaml index 868ae922..d083ea28 100644 --- a/garm-rockcraft.yaml +++ b/garm-rockcraft.yaml @@ -24,7 +24,10 @@ parts: - GOTOOLCHAIN: local override-build: | cd "$CRAFT_PART_SRC" - go build -tags osusergo,netgo,sqlite_omit_load_extension -ldflags "-extldflags -static" -o bin/garm ./cmd/garm + VERSION=$(git describe --tags --match='v[0-9]*' --always) + go build -tags osusergo,netgo,sqlite_omit_load_extension \ + -ldflags "-extldflags -static -X github.com/cloudbase/garm/util/appdefaults.Version=${VERSION}" \ + -o bin/garm ./cmd/garm mkdir -p "$CRAFT_PART_INSTALL/usr/local/bin" cp bin/garm "$CRAFT_PART_INSTALL/usr/local/bin/"