Skip to content

Derive the preview version from a release base, not a prerelease tag - #2

Merged
sadeqabuhattem merged 1 commit into
mainfrom
fix-preview-version-base
Sep 10, 2026
Merged

sadeqabuhattem merged 1 commit into
mainfrom
fix-preview-version-base

Conversation

@sadeqabuhattem

Copy link
Copy Markdown
Member

The bug

git describe returns the newest tag, which in this repository is itself a prerelease — v1.0.0-preview.1. The job stripped only the leading v, leaving a base that already carried a prerelease suffix, then appended the run number:

BASE=1.0.0-preview.1  →  VERSION=1.0.0-preview.1-preview.<run_number>

Every push to main published under that name. Nothing failed, which is why it went unnoticed: the SemVer guard further down is ^[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$, and the optional trailing group happily matches the entire doubled suffix.

The fix

Strip any -prerelease / +build suffix along with the v, then assert the result is MAJOR.MINOR.PATCH before it is used — so a tag the strip cannot reduce (v1.0) fails here with a readable message rather than deep inside pack.

This is the same family as c47c871, which fixed the empty-base fallback in these same lines: the base is only trustworthy once it has been checked.

Verified

Ran the block's logic against each case:

tag ref version
v1.0.0-preview.1 refs/heads/main 1.0.0-preview.42
v1.0.0-preview.1 refs/heads/develop 1.0.0-dev.42
v1.0.0 refs/heads/main 1.0.0-preview.42
(no tags) refs/heads/main 1.0.0-preview.42
v1.0.0-preview.1 refs/tags/v1.0.0-preview.2 1.0.0-preview.2
v1.0 refs/heads/main fails with Derived base version '1.0' is not MAJOR.MINOR.PATCH

Known limitation, not addressed here

Row three shows it: once v1.0.0 is genuinely released, main builds still compute 1.0.0-preview.N, which sorts below the released 1.0.0. Previews would then look older than the release they follow. Fixing that means deciding what post-release previews should target — next patch, next minor, or a version read from a file — which is a design call rather than a bug fix. It does not bite today, because the only tag is a prerelease.

🤖 Generated with Claude Code

git describe returns the newest tag, which in this repository is itself a
prerelease: v1.0.0-preview.1. Stripping only the leading v left a base that
already carried a prerelease suffix, and appending the run number produced

    1.0.0-preview.1-preview.<run_number>

for every push to main. That string satisfies the SemVer check further down —
the optional group after MAJOR.MINOR.PATCH matches the whole doubled suffix —
so nothing failed; the packages simply published to GitHub Packages under a
name nobody would look for.

Strip any -prerelease or +build suffix along with the v, and assert the result
is MAJOR.MINOR.PATCH before it is used, so a tag the strip cannot reduce (v1.0)
fails here with a readable message rather than inside pack.

This is the same family of bug as c47c871, which fixed the empty-base fallback
in these lines: the base is only trustworthy after it has been checked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sadeqabuhattem
sadeqabuhattem merged commit 4ac4f68 into main Sep 10, 2026
10 checks passed
@sadeqabuhattem
sadeqabuhattem deleted the fix-preview-version-base branch September 10, 2026 16:33
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