From cd11d33cc0f965cb817aa1a29f7d861252f2ba57 Mon Sep 17 00:00:00 2001 From: Sadeq Abu-Hattem Date: Wed, 9 Sep 2026 22:29:54 +0300 Subject: [PATCH] Derive the preview version from a release base, not a prerelease tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 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 --- .github/workflows/ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e03435..a378aaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -262,9 +262,22 @@ jobs: # tags in the repository the fallback never fired, BASE came out empty, and the # version became "-preview.N" — which pack rejects deep inside MSBuild. Test the # value, not the exit status. - BASE=$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || true) + # + # The newest tag is itself usually a prerelease (v1.0.0-preview.1), so strip any + # -prerelease / +build suffix as well as the leading v and keep MAJOR.MINOR.PATCH. + # Appending -preview.N to a base that already carries a prerelease suffix yields + # 1.0.0-preview.1-preview.N: valid enough SemVer to pass the check below, and wrong + # enough to publish under a name nobody is looking for. + BASE=$(git describe --tags --abbrev=0 2>/dev/null | sed -E 's/^v//; s/[-+].*$//' || true) [[ -n "${BASE}" ]] || BASE="1.0.0" + # Anything the strip did not reduce to MAJOR.MINOR.PATCH (a v1.0 tag, say) would + # only surface later as an opaque pack failure. + if [[ ! "${BASE}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "::error::Derived base version '${BASE}' is not MAJOR.MINOR.PATCH" + exit 1 + fi + if [[ "${GITHUB_REF}" == refs/heads/main ]]; then VERSION="${BASE}-preview.${{ github.run_number }}" else