Repository navigation
🍕 Publish to npm from GitHub Actions when a version tag is pushed - #295
Conversation
release.yml runs the tests (ci.yml is now callable) and then publishes with npm trusted publishing and provenance, so no npm token is stored in GitHub and nobody publishes from a laptop. 6.0.0-rc.14 goes to the "rc" dist-tag, a version without a prerelease id to "latest"; the tag must match package.json.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f2520bb8c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| tag=latest | ||
| if [[ "$GITHUB_REF_NAME" == *-* ]]; then | ||
| pre="${GITHUB_REF_NAME#*-}" | ||
| tag="${pre%%.*}" |
There was a problem hiding this comment.
Use a valid dist-tag for numeric prereleases
When using the advertised npm run release prepatch path (also the release script's default), .github/scripts/release.sh:43 creates a version such as 6.0.1-0. This extraction sets the dist-tag to 0, so the publish step fails even with trusted publishing configured. npm's bundled npm-dist-tag documentation states, “Tags that can be interpreted as valid semver ranges will be rejected”; an offline npm publish --dry-run --ignore-scripts --offline --tag 0 confirms the error. Map numeric prerelease identifiers to a valid channel such as next, or update the release script to generate a named prerelease identifier.
Useful? React with 👍 / 👎.
… dist-tag npm refuses a dist-tag that is a semver range, and `npm run release prepatch` makes 6.0.1-0, whose prerelease id is 0.
TL;DR
Pushing a version tag (
v6.0.0-rc.14) now publishes claycli from GitHub Actions with npm trusted publishing: no npm token in GitHub, no publishing from a laptop, and every release gets a provenance attestation. Same setup as clay/handlebars, which published clayhandlebars 6.0.0 this way.What changes
.github/workflows/release.yml(new): on av*tag, runs the tests, checks the tag equals thepackage.jsonversion, thennpm publish --provenance. The dist-tag is the prerelease id (6.0.0-rc.14goes torc, as the rcs do today), orlatestfor a version without one..github/workflows/ci.yml: addsworkflow_callso the release runs the same tests.Before the first tag
A package owner links claycli to this workflow once (npm 11.15 or later, web 2FA):
Until then the publish job fails with a plain npm auth error (E404/E401), and nothing is published.
Releasing after this
npm version prereleaseon master, then push the commit and the tag. The workflow publishes.