Skip to content

build: make Version dynamic via ldflags (const → var)#453

Open
nlenepveu wants to merge 1 commit intoasheshgoplani:mainfrom
blackfuel-ai:fix/dynamic-version-via-ldflags
Open

build: make Version dynamic via ldflags (const → var)#453
nlenepveu wants to merge 1 commit intoasheshgoplani:mainfrom
blackfuel-ai:fix/dynamic-version-via-ldflags

Conversation

@nlenepveu
Copy link
Copy Markdown
Contributor

@nlenepveu nlenepveu commented Mar 28, 2026

Summary

The Makefile already sets LDFLAGS=-ldflags "-X main.Version=$(VERSION)" using git describe --tags, but this had no effect because Version was declared as a const — Go's linker -X flag only works on package-level vars.

As a result, every build (including official releases) always reports the hardcoded string (e.g. v0.27.5) regardless of the actual tag or commit.

Changes:

  • cmd/agent-deck/main.go: const Version = "..."var Version = "..." (one character change)
  • Makefile: strip the leading v from git describe output so the injected value matches the existing "0.27.5" format and avoids a double-v prefix in the output

Before:

$ agent-deck --version
Agent Deck v0.27.5   # always, even on dirty/ahead builds

After:

$ agent-deck --version
Agent Deck v0.27.5             # clean tag build
Agent Deck v0.27.5-3-gabcdef0  # build ahead of tag

The default fallback value is unchanged — clean tag builds are unaffected.

Test plan

  • make build && ./build/agent-deck --version on a clean tag checkout reports vX.Y.Z
  • Same command on a commit ahead of the tag reports vX.Y.Z-N-gSHA
  • make build with no git repo falls back to dev

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.

1 participant