Skip to content

Automated npm releases via CI (trusted publishing) - #455

Open
malteish wants to merge 1 commit into
chore/dependency-cleanupfrom
feature/ci-release
Open

Automated npm releases via CI (trusted publishing)#455
malteish wants to merge 1 commit into
chore/dependency-cleanupfrom
feature/ci-release

Conversation

@malteish

Copy link
Copy Markdown
Collaborator

Stacked on #454 (needs its Node 24 bump — trusted publishing requires npm ≥ 11.5, which ships with Node 24).

Implements the CI release flow: pushing a v* tag publishes @tokenize.it/contracts to npm and creates the GitHub release. A release becomes:

npm version <newversion>
git push --follow-tags

How it works

  • Auth: npm trusted publishing (OIDC). No tokens stored in the repo, no 2FA OTPs. Publishes carry --provenance attestations linking the tarball to the exact commit and workflow run.
  • Safety: the workflow fails if the tag doesn't match package.json; tests and the full build run against a fresh checkout of the tag, so the tarball contains exactly what's committed — untracked working-directory files can never end up on npm again.
  • Prereleases: -alpha*/-beta* versions publish under the alpha/beta dist-tag, other prerelease suffixes under next, and are marked prerelease on GitHub. Only stable versions get latest, so npm install never resolves to a preview.
  • Release notes are extracted from the matching ## [x.y.z] section of CHANGELOG.md (fallback: GitHub's generated notes).
  • prepack is reduced to npmignore --auto; CI runs tests/build as explicit steps. docs/npm_publishing.md is rewritten accordingly, including the manual-fallback procedure.

One-time setup before merging (npm account required)

On npmjs.com → @tokenize.it/contracts → Settings → Trusted Publisher: org corpus-io, repo tokenize.it-smart-contracts, workflow release.yml (no environment). Optionally restrict the package's publishing access to trusted publisher only, which revokes the ability of any token or laptop to publish.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BmhG9gFVHiF1XL2AfdAHRr

Pushing a v* tag now publishes to npm and creates the GitHub release
automatically:

- authenticates via npm trusted publishing (OIDC) — no tokens in the
  repo, no 2FA one-time passwords, publishes carry --provenance
- guards that the tag matches package.json version
- runs forge tests and the full build from a fresh checkout, which
  packs exactly what is committed (no working-directory pollution)
- versions with -alpha/-beta suffixes publish under the alpha/beta
  dist-tag and are marked prerelease on GitHub; other prerelease
  suffixes go to next; only stable versions become latest
- GitHub release notes are extracted from the matching CHANGELOG.md
  section, falling back to generated notes

prepack is reduced to npmignore only, since CI runs tests and build as
explicit steps. docs/npm_publishing.md describes the new two-command
release flow and the manual fallback.

Requires one-time setup on npmjs.com: register this repo's release.yml
as trusted publisher for @tokenize.it/contracts.
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.

1 participant