Harden release tag recovery

Recover unpublished current-ref stable tags and use package.json as the stable version floor when GitHub Releases regresses after a deleted release.
This commit is contained in:
Neil 2026-06-03 18:38:03 -07:00 committed by GitHub
parent fc896b3207
commit c60744ec22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 0 deletions

View File

@ -255,6 +255,13 @@ jobs:
node config/scripts/release-rc-history.mjs "$1"
}
current_package_stable() {
node -e '
const { version } = require("./package.json");
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(version)) console.log(version);
'
}
tag_matches_current_ref() {
local tag="$1"
local tag_commit
@ -317,6 +324,25 @@ jobs:
latest_stable="0.0.0"
fi
package_stable="$(current_package_stable)"
if [[ -n "$package_stable" ]]; then
# Why: if a stable release is deleted after its version-bump commit
# reached main, GitHub's release list regresses. package.json is the
# floor for the current ref so the next cut cannot reuse an older
# stable number just because the public release was nuked.
if semver_gt "$package_stable" "$latest_stable"; then
if [[ "$KIND" != "rc" ]]; then
package_tag="v$package_stable"
if git rev-parse "$package_tag" >/dev/null 2>&1; then
recover_unpublished_tag "$package_tag" "current ref stable tag is newer than latest published stable" || true
fi
fi
echo "Stable floor from package.json: $package_stable"
latest_stable="$package_stable"
fi
fi
case "$KIND" in
rc)
# Why: RCs always stabilize the *next* patch after whatever