fix: restore version ldflag for GoReleaser builds#25
Merged
miguelsanchez-upsun merged 1 commit intomainfrom Mar 11, 2026
Merged
fix: restore version ldflag for GoReleaser builds#25miguelsanchez-upsun merged 1 commit intomainfrom
miguelsanchez-upsun merged 1 commit intomainfrom
Conversation
Commit 73a97c7 removed the version ldflag in favor of runtime/debug.ReadBuildInfo(). However, Go's build info only reports the correct version when the module path matches the tag's major version. Since the module is github.com/upsun/cli (no /v5 suffix) but tags are v5.x.x, Go returns a pseudo-version instead. Restore the -X ldflag to inject the version from the tag at build time. The debug.ReadBuildInfo() fallback remains for go install users (where ldflags are not set). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR restores injecting the CLI release version via Go linker flags in GoReleaser builds, avoiding incorrect pseudo-versions when debug.ReadBuildInfo() can’t resolve the tagged module version.
Changes:
- Add
-X github.com/upsun/cli/internal/config.Version={{.Version}}to the ldflags for all four build configurations (platform, platform-macos, upsun, upsun-macos). - Keep the existing
debug.ReadBuildInfo()fallback behavior for non-GoReleaser installs (e.g.,go install).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
miguelsanchez-upsun
approved these changes
Mar 11, 2026
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.
Summary
Commit 73a97c7 removed version ldflags in favor of
runtime/debug.ReadBuildInfo(). This doesn't work because the module path (github.com/upsun/cli) lacks the/v5suffix required for Go to associatev5.x.xtags with the module. The result: binaries reportv0.0.0-<pseudo-version>instead of the actual release version.-X internal/config.Version={{.Version}}ldflag to all four build entriesdebug.ReadBuildInfo()fallback inversion.goremains forgo installusers🤖 Generated with Claude Code