Skip to content

fix: long version info not displayed correctly in release builds#1374

Open
phm07 wants to merge 4 commits intomainfrom
fix-long-version-info
Open

fix: long version info not displayed correctly in release builds#1374
phm07 wants to merge 4 commits intomainfrom
fix-long-version-info

Conversation

@phm07
Copy link
Copy Markdown
Contributor

@phm07 phm07 commented Mar 26, 2026

Goreleaser allows injecting the vcs.revision and vcs.time variables directly using ldflags, which is more reliable than using debug.ReadBuildInfo() and should fix the long version output for GitHub releases. debug.ReadBuildInfo() is still used as a fallback in case the binary was not built using goreleaser. The go mod tidy before hook was removed from the goreleaser config as we already keep our go mod tidied using renovate.

@phm07 phm07 self-assigned this Mar 26, 2026
@phm07 phm07 requested a review from a team as a code owner March 26, 2026 14:47
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.61%. Comparing base (9c284a1) to head (baad337).

Files with missing lines Patch % Lines
internal/version/version.go 47.36% 5 Missing and 5 partials ⚠️
internal/cmd/version/version.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1374      +/-   ##
==========================================
+ Coverage   67.59%   72.61%   +5.01%     
==========================================
  Files         300      300              
  Lines       11054    11067      +13     
==========================================
+ Hits         7472     8036     +564     
+ Misses       2641     2133     -508     
+ Partials      941      898      -43     
Flag Coverage Δ
e2e 51.32% <37.50%> (?)
unit 67.56% <50.00%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -1,5 +1,7 @@
package version

import "runtime/debug"
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.

Why use runtime/debug at all if we inject the values anyways?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

debug.ReadBuildInfo() is still used as a fallback in case the binary was not built using goreleaser.

This is useful for example for go install. Also I think some package managers run custom builds.

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.

Could you add a comment about this somewhere in this file please?

.goreleaser.yml Outdated
- -w
- -X {{ .ModulePath }}/internal/version.version={{ .Version }}
- -X {{ .ModulePath }}/internal/version.versionPrerelease={{- if .IsSnapshot -}}dev+{{ .ShortCommit }}{{- end -}}
- -X {{ .ModulePath }}/internal/version.commit={{ .Commit }}
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.

According to goreleaser, this template value is deprecated: https://goreleaser.com/customization/general/templates/

We should probably use .FullCommit instead.

// Modified specifies whether the git worktree was dirty during build time
Modified = func() bool {
return getSettingsValue("vcs.modified", "false") == "true"
}()
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.

What about using goreleaser's .IsGitDirty template variable to set this value?

@phm07 phm07 requested a review from jooola March 27, 2026 16:36
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.

2 participants