Skip to content

ci: switch npm publish to trusted publishing (OIDC) - #9

Merged
mrgoonie merged 3 commits into
mainfrom
ci/npm-trusted-publishing
Aug 7, 2026
Merged

ci: switch npm publish to trusted publishing (OIDC)#9
mrgoonie merged 3 commits into
mainfrom
ci/npm-trusted-publishing

Conversation

@mrgoonie

@mrgoonie mrgoonie commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

npm deprecated classic long-lived tokens. Switch this repo's release pipeline to Trusted Publishing (OIDC) — no `NPM_TOKEN` secret, no rotation, per-run short-lived credential, and free sigstore provenance.

Workflow changes

  • Drop `NPM_TOKEN` from the `semantic-release` env.
  • Pin `npm install -g npm@latest` before install (Node 22 image ships npm 10.x; OIDC detection landed in npm 11.5.1).
  • Set `NPM_CONFIG_PROVENANCE=true` so `@semantic-release/npm` publishes with `--provenance` and the tarball ships a sigstore attestation.
  • `permissions: id-token: write` was already declared on the release job.

One-time setup on npmjs.com (DO NOT merge before this is done)

Package `agentbrain` → SettingsTrusted publishersAdd trusted publisherGitHub Actions:

  • Repository owner: `nextlevelbuilder`
  • Repository name: `agentbrain-cli`
  • Workflow filename: `release.yml`
  • Environment name: (leave blank)

If `agentbrain` hasn't been reserved on npm yet, create it first via `Packages` → `New package` (or reserve through this Trusted Publishers form if the UI allows).

After merge

  • `NPM_TOKEN` repo secret can be deleted.
  • First push to main triggers publish (semantic-release will still cut `v1.0.0` based on commit history).
  • Future publishes on `dev` produce `X.Y.Z-beta.N` on the `beta` dist-tag.

Rollback

Revert this PR + re-add `NPM_TOKEN` (classic or GAT).

- Drop NPM_TOKEN from the semantic-release env; npm CLI 11.5.1+ picks
  up the GitHub Actions OIDC token automatically and exchanges it for
  a short-lived publish credential when a Trusted Publisher is
  configured on npmjs.com for the package.
- Pin `npm install -g npm@latest` (Node 22 image ships npm 10.x, which
  predates OIDC support).
- Enable NPM_CONFIG_PROVENANCE so the published tarball carries a
  sigstore provenance attestation.

Requires (one-time, on npmjs.com):
  Package agentbrain -> Settings -> Trusted publishers ->
  Add GitHub Actions publisher:
    Repository owner: nextlevelbuilder
    Repository name:  agentbrain-cli
    Workflow:         release.yml
    Environment:      (leave blank)

After this PR merges, the NPM_TOKEN repo secret can be deleted.
npm blocked "agentbrain" (E403, name too similar to existing "agent-brain").
Renamed to "agentbrain-cli" and manually published 1.0.0 to reserve the name.

CLI binary command remains `agentbrain` (unchanged in bin field).
@mrgoonie
mrgoonie merged commit 796eee3 into main Aug 7, 2026
4 checks passed
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