Report the next release version for dev builds - #6189
Open
denik wants to merge 2 commits into
Open
Conversation
A local build reported 0.0.0-dev+<sha>, which semver sorts below every release even though the build is made from main and is therefore newer than the latest release. Report <next release>-dev+<sha> instead, read from .nextchanges/version, matching what goreleaser produces for snapshots. Dev builds were detected by string-matching the 0.0.0 prefix in six places, all of which would silently stop recognizing them. Replace those with build.Info.IsDevelopment, which keys off the -dev prerelease.
Collaborator
Integration test reportCommit: a36687a
10 interesting tests: 4 RECOVERED, 4 SKIP, 2 flaky
Top 3 slowest tests (at least 2 minutes):
|
janniklasrose
approved these changes
Aug 6, 2026
|
|
||
| const DefaultSemver = "0.0.0-dev" | ||
| // devPrerelease marks a build that was not produced from a release tag. | ||
| const devPrerelease = "-dev" |
Contributor
There was a problem hiding this comment.
can we export this and use in the other places?
go:embed is byte-exact and the version file must end with a newline, so keep the raw contents unexported and export the trimmed value. Callers no longer have to remember to trim. Replace the three copies of the "-dev" prerelease constant with one exported predicate, and pin the version ordering with a test that asserts every pair in an ascending list.
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.
Why
A local build (
go build, no release flags) reported0.0.0-dev+<sha>. Semver treats-devas aprerelease, so that sorted below every published release — even below bare
0.0.0— even though alocal build is made from main and is therefore newer than the latest release.
Now it reports
<next release>-dev+<sha>, e.g.1.12.0-dev+abc123, read from.nextchanges/version. It sorts above the latest release and below the release it will become,matching what goreleaser already produces for snapshots (
snapshot.version_template).Changes
.nextchanges/nextversion.goembeds the version file as a sibling — go:embed cannot reach a parentdirectory, and embedding from
internal/buildwould need a second copy of the value that coulddrift. A generated const would go stale in the release commit itself: the release bot bumps
.nextchanges/versionthrough the GitHub API without running Go generators.Six places detected dev builds by string-matching the
0.0.0prefix and would all have silentlystopped recognizing them (
version --checkwould start nagging developers to upgrade, skillmin-version gates would start applying, the compat manifest would resolve the wrong entry). They now
share
build.Info.IsDevelopment, which keys off the-devprerelease.Two acceptance fixtures hardcoded
0.0.0-devand rendered as[CLI_VERSION]only because ithappened to equal the real version; they now use
0.0.0-testso they no longer track it.Tests
IsDevelopmentunit tests including a release candidate (not a dev build) and a snapshot of arelease version, plus a test pinning the ordering invariant this change exists for.