Skip to content

build: derive version from git tags - #660

Closed
huong8373tt-beep wants to merge 1 commit into
rootless-containers:masterfrom
huong8373tt-beep:build/detect-version-from-git-tag-631
Closed

huong8373tt-beep wants to merge 1 commit into
rootless-containers:masterfrom
huong8373tt-beep:build/detect-version-from-git-tag-631

Conversation

@huong8373tt-beep

Copy link
Copy Markdown

Fixes #631.

Summary

  • derive the build version with git describe --tags --always --dirty;
  • inject it through Go linker flags for Makefile-built binaries;
  • retain unknown when building a source archive without Git metadata.

Validation

  • Linux: go test ./pkg/version ./cmd/rootlesskit ./cmd/rootlessctl ./cmd/rootlesskit/unshare ./cmd/rootlesskit-docker-proxy
  • Linux: make clean all VERSION=v4.0.0-test; verified rootlesskit and rootlessctl report the injected version and --print-semver major returns 4
  • Linux: default Makefile build reports the checkout's git describe value
  • Linux: a copy with .git removed builds with version unknown; --print-semver reports the expected semantic-version parsing error
  • git diff --check

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.

Signed-off-by: Slai.life <huong8373tt@gmail.com>
Comment thread pkg/version/version.go
// Version is set at build time from the repository tag.
//
// Keep a useful fallback for source archives that do not contain Git metadata.
var Version = "unknown"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • "unknown" isn't useful
  • This task is not actionable until v4. I'm planning to work on it myself
  • You seem to be a fully automatic bot account

@AkihiroSuda AkihiroSuda closed this Nov 4, 2026
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.

[v4] Avoid hard-coding version in pkg/version/version.go

2 participants