Skip to content

ci: publish to npm via trusted publishing behind a release environment - #2936

Merged
Trivo25 merged 1 commit into
mainfrom
ci/npm-trusted-publishing
Dec 1, 2026
Merged

Trivo25 merged 1 commit into
mainfrom
ci/npm-trusted-publishing

Conversation

@Trivo25

@Trivo25 Trivo25 commented Dec 1, 2026

Copy link
Copy Markdown
Member

Summary

Move all npm publishing to npm trusted publishing (OIDC) and gate it with a GitHub environment. With this change, publishing does not use a long-lived npm token, and only an approved run from an allowed branch can publish.

  • manual_release.yml and push_main.yml: Release-on-NPM now runs in the release environment and authenticates with OIDC. I removed NPM_TOKEN.
  • push_main.yml: replace JS-DevTools/npm-publish@v3, which requires a token, with the same "skip if the version exists, else npm publish --provenance" step that manual_release.yml uses.
  • publish_native.yml: publish-native-packages now runs in the release environment. It already used OIDC.
  • Install npm 11.6.2 before publishing, because trusted publishing needs npm >= 11.5.1 and Node 22 ships npm 10.
  • Remove secrets: inherit from the publish_native.yml calls. That workflow uses no secrets.

Behavior difference: the old strategy: upgrade also skipped versions lower than the version on npm. The new step skips only versions that already exist. Check-Version-Change still skips prereleases and unchanged versions.

Required before merge

The next release fails unless these settings exist:

  1. GitHub → Settings → Environments: create release with required reviewers and "prevent self-review". Limit deployment branches to main and any release branches.
  2. npmjs.com → o1js → Trusted publishing: add o1-labs/o1js + manual_release.yml and o1-labs/o1js + push_main.yml, both with environment release.
  3. Add the same two entries to each @o1js/native platform package and the meta package. npm checks the calling workflow file for reusable workflows.
  4. On each package, set publishing access to "Require 2FA and disallow tokens".

After the first OIDC release works, delete the NPM_TOKEN repo secret and revoke the token on npm.

Verification

actionlint reports no new findings. The workflows have not run yet. The first release is the end-to-end test.

🤖 Generated with Claude Code

Replace the long-lived NPM_TOKEN with npm trusted publishing (OIDC) in
manual_release.yml and push_main.yml, matching publish_native.yml. All
three publish jobs now run in the `release` GitHub environment, so
required reviewers and branch rules gate every publish.

- Install npm 11.6.2 before publishing (OIDC needs npm >= 11.5.1).
- Replace JS-DevTools/npm-publish with an explicit npm publish step.
- Drop `secrets: inherit` from the publish_native.yml calls; it uses none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Trivo25
Trivo25 merged commit 92c8011 into main Dec 1, 2026
11 of 17 checks passed
@Trivo25
Trivo25 deleted the ci/npm-trusted-publishing branch December 1, 2026 06:34
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