From 9fae4ffd81da46b5a21e6540f2d45bce8e074307 Mon Sep 17 00:00:00 2001 From: Michael Wang Date: Tue, 17 Nov 2026 04:35:57 +0000 Subject: [PATCH] ci(publish): a prerelease tag publishes only to an allow-listed dist-tag (#7963) The publish job took the npm dist-tag from the pushed tag's suffix and refused only an exact "latest". A tag such as v1.2.3-LATEST.1, or one with a new suffix, still named its own dist-tag. The job's channel check now accepts only alpha, beta, rc, next, canary, hdr, native and desktop, matched exactly. --- .github/workflows/publish.yml | 10 ++++++++++ docs/contributing/release-channels.mdx | 2 +- scripts/publish-workflow.test.mjs | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 02640959f6..8823a5174a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -457,6 +457,16 @@ jobs: echo "::error::v$VERSION is a prerelease and cannot publish to the latest dist-tag." exit 1 fi + # An allow-list, matched exactly, so no letter case or new suffix of a pushed tag names another dist-tag. + if [ "$PRERELEASE" = "true" ]; then + case "$DIST_TAG" in + alpha | beta | rc | next | canary | hdr | native | desktop) ;; + *) + echo "::error::v$VERSION names the dist-tag \"$DIST_TAG\". Prereleases publish only to alpha, beta, rc, next, canary, hdr, native or desktop." + exit 1 + ;; + esac + fi - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: diff --git a/docs/contributing/release-channels.mdx b/docs/contributing/release-channels.mdx index 807f5ef47a..91782fd74f 100644 --- a/docs/contributing/release-channels.mdx +++ b/docs/contributing/release-channels.mdx @@ -6,7 +6,7 @@ description: How HyperFrames keeps alpha-only work out of stable releases. HyperFrames publishes two release channels: - Stable releases use versions like `0.4.24` and publish to the npm `latest` dist-tag. -- Prereleases use versions like `0.4.24-alpha.1` and publish to the npm dist-tag named by the prerelease suffix, such as `alpha`. +- Prereleases use versions like `0.4.24-alpha.1` and publish to the npm dist-tag named by the prerelease suffix, such as `alpha`. The suffix must be one of `alpha`, `beta`, `rc`, `next`, `canary`, `hdr`, `native` or `desktop`, in lower case. The publish workflow refuses any other suffix before it publishes. ## Branch policy diff --git a/scripts/publish-workflow.test.mjs b/scripts/publish-workflow.test.mjs index de4684fa57..c497ef5285 100644 --- a/scripts/publish-workflow.test.mjs +++ b/scripts/publish-workflow.test.mjs @@ -296,6 +296,11 @@ test("the publish job checks the release channel without repo scripts", () => { assert.equal(check("push", "0.9.55-alpha.1;id", "true"), 1); assert.equal(check("push", "0.9.55-latest.1", "true", "latest"), 1); assert.equal(check("push", "0.9.55-hdr.1", "true", "hdr"), 0); + assert.equal(check("push", "0.9.55-beta.1", "true", "beta"), 0); + assert.equal(check("push", "0.9.55-LATEST.1", "true", "LATEST"), 1); + assert.equal(check("push", "0.9.55-Latest.1", "true", "Latest"), 1); + assert.equal(check("push", "0.9.55-Alpha.1", "true", "Alpha"), 1); + assert.equal(check("push", "0.9.55-stable.1", "true", "stable"), 1); }); test("the publish job takes only tarballs that npm reads the way the check does", () => {