Skip to content

fix(rock): embed GARM version via git describe in ldflags#219

Merged
yanksyoon merged 1 commit into
mainfrom
fix/garm-version-ldflags
Jun 1, 2026
Merged

fix(rock): embed GARM version via git describe in ldflags#219
yanksyoon merged 1 commit into
mainfrom
fix/garm-version-ldflags

Conversation

@yanksyoon
Copy link
Copy Markdown
Member

Problem

The garm binary reports v0.0.0-unknown because the build does not inject version information via ldflags.

Fix

Use git describe --tags --match='v[0-9]*' --always at 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.1v0.3.0), the embedded version automatically follows — no second field to maintain.

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.
Comment thread garm-rockcraft.yaml
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 VERSION during override-build using git describe --tags --match='v[0-9]*' --always.
  • Pass -X github.com/cloudbase/garm/util/appdefaults.Version=${VERSION} to go build so the compiled binary reports the correct version.

Copilot finished work on behalf of cbartz June 1, 2026 05:05
Copilot AI requested a review from cbartz June 1, 2026 05:05
@yanksyoon yanksyoon merged commit 02ba5cc into main Jun 1, 2026
49 checks passed
@yanksyoon yanksyoon deleted the fix/garm-version-ldflags branch June 1, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants