Skip to content

Commit b829e49

Browse files
committed
no-mistakes(review): refuse an rc of an already-shipped version
1 parent d290bd4 commit b829e49

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎docs/RELEASING.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,9 @@ that already exists (`v1.2.3` once `v1.3.0` exists), because the deploy would ne
643643
So a maintenance patch is for a line that is still the newest release. The same holds on npm:
644644
`release.mjs` publishes to `latest`, and a patch cut after a newer minor shipped would move
645645
`latest` backwards — so `release.mjs` refuses, in its preflight and before anything is
646-
published, any version older than the newest release tag (resolved the same way the site
647-
deploy resolves its tag). It offers no non-`latest` dist-tag path.
646+
published, any version older than the newest release tag, and any release candidate of a
647+
version that has already shipped (npm sorts it below the full release; resolved the same
648+
way the site deploy resolves its tag). It offers no non-`latest` dist-tag path.
648649
649650
**Then bring the fix to `main`.** A maintenance branch is never merged back wholesale (its
650651
version bumps and CHANGELOG would collide with `main`'s). Cherry-pick or re-land each fix on

‎scripts/lib/release-branch.mjs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ export function newestNpmReleaseTag(out) {
5959
/**
6060
* Why `version` may not be released while `newestTag` is the newest release tag, or `null`
6161
* when it may. `bun publish` tags `latest`, so a version older than the newest release
62-
* would move `latest` backwards — including an `-rc` cut on a line a newer release passed.
62+
* would move `latest` backwards — including an `-rc` cut on a line a newer release passed,
63+
* and an `-rc` of the very version that already shipped (npm sorts `1.2.4-rc.1` below
64+
* `1.2.4`).
6365
*
6466
* @param {string} version the version being cut (`1.2.4`, or `1.2.4-rc.1`)
6567
* @param {string} newestTag the newest npm-line release tag (`v1.3.0`), or `""` if none
@@ -77,5 +79,9 @@ export function latestRegressionRefusal(version, newestTag) {
7779
`\`latest\`, so this would move \`latest\` backwards. A patch on a line a newer release ` +
7880
`has passed needs a non-\`latest\` dist-tag path this script does not yet offer.`;
7981
}
80-
return null;
82+
return /-rc\.\d+$/.test(version)
83+
? `${version} is a release candidate for ${newestTag.slice(1)}, which has already shipped — ` +
84+
`npm sorts it below the full release, so publishing to \`latest\` would move \`latest\` ` +
85+
`backwards.`
86+
: null;
8187
}

‎scripts/test-release-branch.mjs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ check(latestRegressionRefusal("1.2.4", "v1.3.0") !== null,
4242
"a version older than the newest release is refused");
4343
check(latestRegressionRefusal("1.2.4-rc.1", "v1.3.0") !== null,
4444
"an RC on a line a newer release passed is refused too");
45+
check(latestRegressionRefusal("1.2.4-rc.1", "v1.2.4") !== null,
46+
"an RC of the version that already shipped is refused");
47+
check(latestRegressionRefusal("1.2.4", "v1.2.4") === null,
48+
"the released version itself is not a regression");
49+
check(latestRegressionRefusal("1.3.0-rc.1", "v1.2.4") === null,
50+
"an RC of a NEWER triple passes");
4551
check(latestRegressionRefusal("1.3.1", "v1.3.0") === null,
4652
"a version newer than the newest release passes");
4753
check(latestRegressionRefusal("1.2.4", "v1.2.3") === null,

0 commit comments

Comments
 (0)