fix(version): report module version for go install #24

Merged
thklein merged 2 commits from fix/version-from-buildinfo into main 2026-10-18 10:43:55 +00:00
Owner

go install git.basepeak.dev/basepeak-ai/gptscript@v0.9.10 builds a binary that reports gptscript version v0.0.0-dev, because only goreleaser sets version.Tag via ldflags.

This falls back to the main module version from debug.ReadBuildInfo() when the tag is still the default. Release builds (ldflags) are unchanged; local go build (module version (devel)) keeps v0.0.0-dev.

Tested with a table test for resolveTag (ldflags wins, go-install module version, (devel), no build info). go vet / golangci-lint clean on the package.

`go install git.basepeak.dev/basepeak-ai/gptscript@v0.9.10` builds a binary that reports `gptscript version v0.0.0-dev`, because only goreleaser sets `version.Tag` via ldflags. This falls back to the main module version from `debug.ReadBuildInfo()` when the tag is still the default. Release builds (ldflags) are unchanged; local `go build` (module version `(devel)`) keeps `v0.0.0-dev`. Tested with a table test for `resolveTag` (ldflags wins, go-install module version, `(devel)`, no build info). `go vet` / golangci-lint clean on the package.
fix(version): report module version for go install
Some checks failed
smoke / check-label (pull_request_target) Failing after 1s
smoke / gpt-4o-2024-08-06 (pull_request_target) Has been skipped
smoke / gpt-4o-mini-2024-07-18 (pull_request_target) Has been skipped
smoke / claude-3-7-sonnet-20250219 (pull_request_target) Has been skipped
Validate docs build / validate-docs (pull_request) Failing after 9s
integration / integration (ubuntu-22.04) (pull_request) Failing after 12s
test / test (ubuntu-22.04) (pull_request) Failing after 15s
integration / integration (windows-latest) (pull_request) Has been cancelled
test / test (windows-latest) (pull_request) Has been cancelled
f235f7a2e7
Release binaries get the tag via goreleaser ldflags, but
`go install git.basepeak.dev/basepeak-ai/gptscript@v0.9.10` printed
v0.0.0-dev. Fall back to the main module version from the build info
when the tag was not set at link time.
Author
Owner

Review follow-up: since Go 1.24, go build in a checkout stamps a pseudo-version (with +dirty) into the build info, so the first version doubled the commit suffix for local/make build builds. The fallback now only applies when the build info has no vcs.revision (module-cache go install builds); added a test for the checkout case. Release builds (ldflags) and go install @vX / @branch verified unchanged.

Review follow-up: since Go 1.24, `go build` in a checkout stamps a pseudo-version (with `+dirty`) into the build info, so the first version doubled the commit suffix for local/`make build` builds. The fallback now only applies when the build info has no `vcs.revision` (module-cache `go install` builds); added a test for the checkout case. Release builds (ldflags) and `go install @vX` / `@branch` verified unchanged.
fix(version): skip module version for VCS builds
Some checks failed
integration / integration (windows-latest) (pull_request) Waiting to run
test / test (windows-latest) (pull_request) Waiting to run
smoke / check-label (pull_request_target) Failing after 1s
smoke / gpt-4o-2024-08-06 (pull_request_target) Has been skipped
smoke / gpt-4o-mini-2024-07-18 (pull_request_target) Has been skipped
smoke / claude-3-7-sonnet-20250219 (pull_request_target) Has been skipped
Validate docs build / validate-docs (pull_request) Failing after 9s
test / test (ubuntu-22.04) (pull_request) Failing after 10s
integration / integration (ubuntu-22.04) (pull_request) Failing after 22s
644811c8b1
Since Go 1.24 a local go build stamps a pseudo-version into the
build info, which made String() print the commit twice. Only fall
back when there is no vcs.revision, as with module-cache builds.
thklein deleted branch fix/version-from-buildinfo 2026-10-18 10:43:55 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
basepeak-ai/gptscript!24
No description provided.