fix(rock): embed GARM version via git describe in ldflags#219
Merged
Conversation
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.
yanksyoon
commented
Jun 1, 2026
cbartz
approved these changes
Jun 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR ensures the garm binary embedded in the ROCK reports a meaningful version (instead of v0.0.0-unknown) by deriving a version string from the checked-out git tag at build time and injecting it via Go -ldflags.
Changes:
- Derive
VERSIONduringoverride-buildusinggit describe --tags --match='v[0-9]*' --always. - Pass
-X github.com/cloudbase/garm/util/appdefaults.Version=${VERSION}togo buildso the compiled binary reports the correct version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
garmbinary reportsv0.0.0-unknownbecause the build does not inject version information via ldflags.Fix
Use
git describe --tags --match='v[0-9]*' --alwaysat build time to extract the version from the checked-out source tag, then pass it via-X github.com/cloudbase/garm/util/appdefaults.Version=${VERSION}. This matches upstream's Makefile approach.When Renovate bumps
source-tag(e.g.v0.2.1→v0.3.0), the embedded version automatically follows — no second field to maintain.