Skip to content

Commit 386e1a8

Browse files
committed
ci: canary base bumps past a published stable (semver-correct canary ordering)
1 parent 499a409 commit 386e1a8

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ jobs:
6969
sed -i '/_authToken/d' "$NPM_CONFIG_USERCONFIG"
7070
unset NODE_AUTH_TOKEN
7171
72+
PKG=$(node -p "require('./package.json').name")
7273
BASE_VERSION=$(node -p "require('./package.json').version")
74+
# If package.json's version is already a PUBLISHED stable, this canary is work toward the
75+
# NEXT version — bump the patch so the canary sorts ABOVE the release (else BASE-canary.X
76+
# ranks below the published BASE). Unreleased versions (the 0.1.0 hold) are left as-is.
77+
if [ -n "$(npm view "${PKG}@${BASE_VERSION}" version 2>/dev/null || true)" ]; then
78+
BASE_VERSION=$(node -e "const v=require('./package.json').version.split('.').map(Number); console.log(v[0]+'.'+v[1]+'.'+(v[2]+1))")
79+
fi
7380
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
7481
CANARY_VERSION="${BASE_VERSION}-canary.${SHORT_SHA}"
7582
npm version "$CANARY_VERSION" --no-git-tag-version --ignore-scripts

0 commit comments

Comments
 (0)