Skip to content

fix(version): tolerate prerelease suffixes in next-env-version calc#420

Merged
joshua-temple merged 1 commit into
mainfrom
fix/version-calc-dryrun
Jul 1, 2026
Merged

fix(version): tolerate prerelease suffixes in next-env-version calc#420
joshua-temple merged 1 commit into
mainfrom
fix/version-calc-dryrun

Conversation

@joshua-temple

@joshua-temple joshua-temple commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #410. The orchestrate next-env-version calc (internal/version CalculateNext then Parse) aborted with "invalid version format" when nextEnvVersion carried a -dryrun.N suffix. This broke the real v0.6.0 release; the only unblock was a manual tag prune.

Root cause (deeper than #382)

#382 filtered the git-tag discovery path (GetLatest* via IsValidVersionTag). But nextEnvVersion also originates from state.Version (orchestrator.go:383) and the no-env currentDevVersion, neither of which discovery filtering touches. A dry-run vector persists a dryrun version into state, and the next real release reads it as nextEnvVersion and aborts.

Fix

Add ParseBase, which extracts the numeric core (prefix plus major.minor.patch) and discards any prerelease suffix (-rc.N, -dryrun.N, -beta.1), erroring only when the core is not a valid triple. CalculateNext uses ParseBase for nextEnvVersion. This is inert for well-formed inputs because the calc consumes only the numeric core via BaseVersion(); the existing v1.4.0-rc.2.hotfix.1 test still passes.

Tests (TDD)

TestParseBase (9 cases incl. dryrun, opaque, reject-garbage) and TestCalculateNext_NextEnvHoldsDryrunVersion (dry-run-then-release computes from base, no abort). Red before, green after. 2303 tests pass; golangci-lint clean.

Pairs with #388 (dryrun-tag sweeper, merged): the sweeper reduces accumulation, this makes the calc robust regardless.

The next-env-version calc parsed nextEnvVersion with the strict semver
parser, which only accepts an -rc.N suffix. A stray v0.6.0-dryrun.13 value
recorded as the latest aborted the whole calculation with
"parsing next env version: invalid version format", which blocked a real
release until the dryrun tags were pruned by hand. Discovery-side tag
lookups already skip such exercise tags, but the calc path did not.

Add ParseBase, which extracts the numeric core of a version and discards
any pre-release suffix, and use it for nextEnvVersion. Only the base
major.minor.patch feeds the calculation, so dropping the suffix is
correct and cannot change the result for well-formed inputs.

Closes #410

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple joshua-temple enabled auto-merge (squash) July 1, 2026 01:43
@joshua-temple joshua-temple merged commit fcf5575 into main Jul 1, 2026
18 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.

Orchestrate version-calc trips on accumulated -dryrun tags

1 participant