Skip to content

chore(KNO-16635): publish to npm through trusted publishing - #1107

Merged
kylemcd merged 4 commits into
mainfrom
kyle-kno-16635-javascript-move-to-trusted-publishing-via-github-actions
Nov 6, 2026
Merged

kylemcd merged 4 commits into
mainfrom
kyle-kno-16635-javascript-move-to-trusted-publishing-via-github-actions

Conversation

@kylemcd

@kylemcd kylemcd commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Description

Moves npm publishing to trusted publishing (OIDC), so CI no longer needs NPM_TOKEN. npm stops direct publishes from 2FA-bypass tokens in January 2027. Part of KNO-16634, for KNO-16635.

Workflow (release.yml)

  • Grants id-token: write to the release job only, which Yarn needs for the OIDC exchange and provenance. The workflow-level contents: read from main stays as is.
  • Removes the npm token, the "Set NPM Auth" step, and setup-node's registry-url. Yarn uses npmAuthToken ahead of OIDC when one is set, and registry-url injects a placeholder token.
  • Runs the job in the production-release environment. npm's trusted publisher config can't check the branch, so this environment's branch policy decides which branches can publish (main, canary, rc).

Yarn 4.9.1 → 4.18.1

  • Yarn publishes through OIDC natively from 4.10.3 (scoped packages).
  • npmMinimalAgeGate: 0 keeps the pre-4.15 install behavior.
  • npmPublishRegistry publishes to registry.npmjs.org, not the yarnpkg alias.
  • yarn.lock changes are metadata only (format version and the resolve patch hash).

Publishing

  • release:publish adds --provenance (Yarn doesn't turn it on automatically) and --tolerate-republish.
  • Before it builds, it fails when a package isn't on npm yet, because npm can't publish a package's first version through trusted publishing. The error names the command to run.
  • Every package's repository field now points at this repo with its directory. npm checks it against the workflow. types, eslint-config, and typescript-config had none.

yarn release:bootstrap (new, scripts/npm-trusted-publishing.mjs)

  • Adds the trusted publisher config (npm trust github ... --env production-release --allow-publish) for every package, or for the ones you name.
  • For a package name that isn't on npm yet, it first publishes a 0.0.0 placeholder so the name exists.
  • --dry-run prints the npm commands without running them. RELEASES.md documents it.

Reviewers can skip .yarn/releases/. It's the vendored Yarn binary.

Todos

  • Restrict the production-release environment to main, canary, and rc, with admin bypass off.
  • Protect rc. The only ruleset targets the default branch.
  • After this merges and the Version PR opens, run yarn release:bootstrap, then merge the Version PR within 2 days. npm drops a new config that hasn't published by then.
  • Keep NPM_TOKEN until canary merges main. Canary still authenticates with npmAuthToken. Remove it after that (KNO-16640).

Checklist

  • Tests have been added for new features or major refactors to existing features.

🤖 Generated with Claude Code

@kylemcd
kylemcd requested a review from a team as a code owner November 5, 2026 20:23
@kylemcd
kylemcd requested review from andy-knock and meryldakin and removed request for a team November 5, 2026 20:23
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
javascript-ms-teams-connect-example Ready Ready Preview Nov 6, 2026 5:41pm UTC
javascript-nextjs-example Ready Ready Preview Nov 6, 2026 5:41pm UTC
javascript-slack-connect-example Ready Ready Preview Nov 6, 2026 5:41pm UTC
javascript-slack-kit-example Ready Ready Preview Nov 6, 2026 5:41pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6307642

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@knocklabs/client Patch
@knocklabs/eslint-config Patch
@knocklabs/expo Patch
@knocklabs/prettier-config Patch
@knocklabs/react Patch
@knocklabs/react-core Patch
@knocklabs/react-native Patch
@knocklabs/types Patch
@knocklabs/typescript-config Patch
nextjs-app-dir-example Patch
ms-teams-connect-example Patch
slack-connect-example Patch
slack-kit-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@linear-code

linear-code Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

KNO-16635

KNO-16634

kylemcd and others added 2 commits November 6, 2026 11:04
Release publishing now authenticates with npm through OIDC instead of
NPM_TOKEN, and every published version carries signed provenance.

- release.yml: grant id-token: write, drop the npm token and registry-url,
  and run in the production-release environment so only main, canary, and
  rc can publish.
- Bump Yarn to 4.18.1 for native OIDC publishing. Keep the pre-4.15
  package age gate off and publish to registry.npmjs.org directly.
- release:publish requests provenance, skips versions already on npm, and
  fails early when a package is not on npm yet.
- Add yarn release:bootstrap, which publishes a 0.0.0 placeholder for a
  new package name and adds the trusted publisher config for each package.
- Point every package's repository field at its directory in this repo,
  which npm checks against the publishing workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rder

- Pass --registry to `npm trust` like the other npm calls in the
  bootstrap, so a different default registry in a maintainer's npm config
  can't send it elsewhere.
- RELEASES.md: restrict the production-release environment before adding
  trusted publishers, since npm doesn't check the branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not approved: this is a release-pipeline and publishing change, not an auto-release, dependency, or docs-only PR, so it needs product-team review. Human review is needed; requested @connorlindsey (in addition to the existing request for @cjbell).

Open in Web View Automation 

Sent by Cursor Approval Agent: SDK approver

The new rc ruleset limits creating, deleting, and pushing directly to rc
to repo admins, which covers the setup and prerelease-exit steps here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
npm@latest is now npm 12, which needs Node 24.15+, while this repo pins
Node 24.13.0. npm 11 has `npm trust` from 11.15.0 and supports the
repo's Node.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.48%. Comparing base (92ad6b6) to head (6307642).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1107   +/-   ##
=======================================
  Coverage   78.48%   78.48%           
=======================================
  Files         140      140           
  Lines        4508     4508           
  Branches     1314     1314           
=======================================
  Hits         3538     3538           
  Misses        873      873           
  Partials       97       97           

@kylemcd
kylemcd merged commit 8968d01 into main Nov 6, 2026
15 checks passed
@kylemcd
kylemcd deleted the kyle-kno-16635-javascript-move-to-trusted-publishing-via-github-actions branch November 6, 2026 18:03

This branch was successfully deployed

4 active deployments
Preview – javascript-ms-teams-connect-example — 6307642e Deployed Nov 6, 2026 by vercel[bot]
Preview – javascript-slack-kit-example — 6307642e Deployed Nov 6, 2026 by vercel[bot]
Preview – javascript-nextjs-example — 6307642e Deployed Nov 6, 2026 by vercel[bot]
Preview – javascript-slack-connect-example — 6307642e Deployed Nov 6, 2026 by vercel[bot]
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