fix(build): order canary builds by commit time - #3772
armando-navarro wants to merge 1 commit into
Conversation
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 angular#3771
tyler-reitz
left a comment
There was a problem hiding this comment.
Approving. I ran the behaviour rather than reading it: the git show in a --depth 1 clone and under TZ=Asia/Tokyo, twice on the same commit, and 21.0.0-canary.20260925120000.sha-0123456 through npm version. UTC, deterministic, leading zero intact. Bare 0123456 is genuinely invalid semver, so the sha- prefix is load-bearing and the comment saying so should stay.
One line worth adding to the description. A numeric first identifier always loses to an alphanumeric one, so the new names rank below the old ones:
21.0.0-canary.20260925120000.sha-0123456
21.0.0-canary.a2662fe
That is the whole affected set: a2662fe is the only published 21.0.0-canary.*, so it outranks every canary built from now until 21.0.0 ships. Nothing installs differently, since canary is a dist-tag set at publish time and #3771's Scope covers the ranges. But "Names sort by time regardless of hash" reads as global when it only holds among the new names.
Fixes #3771
Canary builds are named after their commit's UTC time as well as its hash, so npm ranks them by age, and an all-digit hash keeps its leading zero.
Changes
tools/build.shnames a canary<version>-canary.<YYYYMMDDHHmmss>.sha-<short sha>, for example21.0.0-canary.20260924201718.sha-a2662fe, instead of21.0.0-canary.a2662fe.maingets the same name and publishes nothing new.sha-prefix keeps the hash a text identifier.Verification
Run in a depth-1 clone like the workflow's checkout, with
npm run buildstubbed:mainnames the canary21.0.0-canary.20260924201718.sha-a2662feon thecanarytag, the commit's UTC time on a runner set to another time zone.21.0.0-rc.2and21.0.0still publish those versions onnextandlatest.package.json, the canary is still named after21.0.0.npm versionkeepssha-0123456intact.