Skip to content

fix: restore version ldflag for GoReleaser builds#25

Merged
miguelsanchez-upsun merged 1 commit intomainfrom
cli-112-fix-version-ldflags
Mar 11, 2026
Merged

fix: restore version ldflag for GoReleaser builds#25
miguelsanchez-upsun merged 1 commit intomainfrom
cli-112-fix-version-ldflags

Conversation

@pjcdawkins
Copy link
Contributor

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 /v5 suffix required for Go to associate v5.x.x tags with the module. The result: binaries report v0.0.0-<pseudo-version> instead of the actual release version.

  • Restore -X internal/config.Version={{.Version}} ldflag to all four build entries
  • The debug.ReadBuildInfo() fallback in version.go remains for go install users

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 11, 2026 15:47
Copy link

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 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 miguelsanchez-upsun merged commit 2cc2753 into main Mar 11, 2026
8 checks passed
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.

3 participants