Skip to content

fix: wire release build info into the version the binaries report - #21

Merged
selimdizer merged 1 commit into
mainfrom
fix/build-info-ldflags
Jul 31, 2026
Merged

selimdizer merged 1 commit into
mainfrom
fix/build-info-ldflags

Conversation

@selimdizer

Copy link
Copy Markdown
Collaborator

v0.4.0 shipped reporting Commit: dev and Built: unknown. GoReleaser was injecting -X main.version/commit/date, but package main only holds func main() — the values landed nowhere. The desktop build passed no ldflags at all, and pkg/api carried its own hardcoded copy of the version, so cutting a release meant editing the number in three places.

Changes

  • internal/buildinfo is now the single source of version, commit and build date. cmd/version.go and pkg/api.GetVersion both read it.
  • GoReleaser and all five wails desktop builds inject into that package.
  • Without ldflags, the values come from the toolchain's embedded build info (debug.ReadBuildInfo), so go install and local builds report the real revision and time instead of placeholders. A modified tree is marked -dirty.
  • The update check strips build metadata before comparing, which otherwise parsed 0.4.10+dirty as 0.4.0 and could hide an available update.

Verification

$ go build -ldflags "-X .../buildinfo.version=9.9.9 -X .../buildinfo.commit=abc1234 \
    -X .../buildinfo.buildDate=2026-08-01T00:00:00Z" -o walgo .
$ ./walgo version
Walgo v9.9.9
Commit:  abc1234
Built:   2026-08-01T00:00:00Z

$ go build -o walgo .        # no ldflags — falls back to build info
$ ./walgo version
Walgo v0.4.0+dirty
Commit:  a0a860494391a84efc9e3a08a7a1fe90a3d14843-dirty
Built:   2026-07-31T22:07:32Z

go test ./... passes across all 23 packages with a cleared cache; golangci-lint v2.12.2 (the CI version) reports 0 issues. New unit tests cover both the ldflags and fallback paths.

🤖 Generated with Claude Code

GoReleaser injected -X main.version/commit/date, but package main only holds
func main() — the values were dropped and every released binary reported
"Commit: dev, Built: unknown". The desktop build passed no ldflags at all, and
pkg/api hardcoded its own copy of the version string, so three places had to be
edited by hand for each release.

- Add internal/buildinfo as the single source, read by the CLI and the API
- Point GoReleaser and the desktop (wails) builds at it
- Fall back to the toolchain's embedded build info when no ldflags are given,
  so `go install` and local builds report the real revision and build time
- Strip build metadata ("+dirty") in the update check, which otherwise parsed
  0.4.10+dirty as 0.4.0

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@selimdizer
selimdizer merged commit 803bd67 into main Jul 31, 2026
2 checks passed
@selimdizer
selimdizer deleted the fix/build-info-ldflags branch July 31, 2026 22:44
selimdizer added a commit that referenced this pull request Aug 1, 2026
Windows runners default to PowerShell, so the build-info stamping added in #21
failed to parse and both Windows desktop jobs died before wails ran.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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