Publish a canary release on every merge
Publish a unique 0.0.0-canary version under a canary dist-tag from CI on each merge to main, so testers get the latest code without touching latest.
Teams that want to test the newest code without cutting a real release can publish a canary from each merge. The version carries the commit hash, so each one is unique, and the canary tag keeps it away from latest.
name: Canary
on:
push:
branches: [main]
permissions:
contents: read
id-token: write
jobs:
canary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm version "0.0.0-canary.${GITHUB_SHA::7}" --no-git-tag-version
- run: npm publish --tag canaryAfterward, the tags look like this:
canary: 0.0.0-canary.3f2a1bc
latest: 1.4.2The hash will be your commit. Users install it with npm install my-lib@canary. The --no-git-tag-version flag stops npm version from creating a commit and tag in the CI checkout.
Each canary stays on the registry forever, so clean-up is manual. Using a prerelease version also keeps it out of any caret range, as covered in the semver docs.