Skip to content

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

Draft
kylemcd wants to merge 2 commits into
mainfrom
kyle-kno-16635-javascript-move-to-trusted-publishing-via-github-actions
Draft

kylemcd wants to merge 2 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. The built-in GITHUB_TOKEN drops to contents: read, because pushes and release PRs already use the knock-eng-bot token.
  • 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

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>
@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 5, 2026 8:55pm UTC
javascript-nextjs-example Ready Ready Preview Nov 5, 2026 8:55pm UTC
javascript-slack-connect-example Ready Ready Preview Nov 5, 2026 8:55pm UTC
javascript-slack-kit-example Ready Ready Preview Nov 5, 2026 8:55pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 37d5de7

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

…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>
@codecov

codecov Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.48%. Comparing base (ca39f68) to head (37d5de7).
⚠️ Report is 1 commits behind head on main.
✅ 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 marked this pull request as draft November 5, 2026 21:31

This branch was successfully deployed

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

1 participant