Skip to content

🍕 Publish to npm from GitHub Actions when a version tag is pushed - #295

Merged
jjpaulino merged 2 commits into
masterfrom
jordan/release-workflow
Nov 17, 2026
Merged

jjpaulino merged 2 commits into
masterfrom
jordan/release-workflow

Conversation

@jjpaulino

Copy link
Copy Markdown
Member

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 a v* tag, runs the tests, checks the tag equals the package.json version, then npm publish --provenance. The dist-tag is the prerelease id (6.0.0-rc.14 goes to rc, as the rcs do today), or latest for a version without one.
  • .github/workflows/ci.yml: adds workflow_call so 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):

npm trust github claycli --repo clay/claycli --file release.yml --allow-publish

Until then the publish job fails with a plain npm auth error (E404/E401), and nothing is published.

Releasing after this

npm version prerelease on master, then push the commit and the tag. The workflow publishes.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T01:56:31.996060Z 8f2520b PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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%%.*}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@coveralls

coveralls commented Nov 17, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 85.71%. remained the same — jordan/release-workflow into master

@jjpaulino jjpaulino self-assigned this Nov 17, 2026
… 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.
@jjpaulino
jjpaulino merged commit aa8343f into master Nov 17, 2026
1 check passed
@jjpaulino
jjpaulino deleted the jordan/release-workflow branch November 17, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants