Skip to content

Commit ac17ede

Browse files
fix(build): order canaries by commit time, keep all-digit hashes intact (#3772)
Canaries were named `<version>-canary.<short sha>`, so npm ranked them by hash: alphabetically, with all-digit hashes below the rest. Naming them `<version>-canary.<UTC commit time>.sha-<short sha>` ranks them by age. The time comes from the commit, so the weekday scheduled rebuild of an unchanged main produces the same name. `npm version` drops the leading zero of an all-digit identifier, so a hash like 0123456 would publish as 123456. The `sha-` prefix keeps it text. Fixes #3771
1 parent a2662fe commit ac17ede

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎tools/build.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
21
TAG_TEST="^refs/tags/.+$"
32
LATEST_TEST="^[^-]*$"
43

@@ -18,7 +17,9 @@ else
1817
if [[ $BASE_VERSION != "$FULL_VERSION" ]]; then
1918
echo "package.json version is $FULL_VERSION. Naming this canary after $BASE_VERSION instead, so it does not outrank $FULL_VERSION on npm. Prereleases are published from their own git tag, so this field is meant to hold a plain release number." >&2
2019
fi
21-
OVERRIDE_VERSION=$BASE_VERSION-canary.$SHORT_SHA
20+
# `sha-` stops npm dropping an all-digit sha's leading zero.
21+
CANARY_ID=$(TZ=UTC git show -s --date=format-local:%Y%m%d%H%M%S --format=%cd.sha-%h $GITHUB_SHA)
22+
OVERRIDE_VERSION=$BASE_VERSION-canary.$CANARY_ID
2223
NPM_TAG=canary
2324
fi;
2425

0 commit comments

Comments
 (0)