ci: publish to npmjs via OIDC Trusted Publishing (no token)
CI / build (pull_request) Successful in 23s

Replaces the NPM_AUTH secret on the prod path with npm Trusted Publishing: id-token: write + npm>=11.5.1, npm exchanges the OIDC token for a short-lived publish token and attaches provenance. Requires a trusted publisher configured on npmjs (Expressive-Tea/green-tea, release.yml).

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-18 14:53:28 -05:00
1 parent 8e822cad17
commit 3ff90b418d
1 file changed
+9 -7
+9 -7
View File
@@ -1,9 +1,9 @@
name: Release → npmjs name: Release → npmjs
# Production publish. Runs on GITHUB ONLY, on a version tag (`v*`). Publishes the stable # Production publish. Runs on GITHUB ONLY, on a version tag (`v*`). Publishes the stable
# package (version from package.json) to the public npmjs registry under `latest`. # package to npmjs via OIDC **Trusted Publishing** — no long-lived token. Requires a trusted
# The tag arrives via the promote workflow; the version should be stable (no prerelease) # publisher configured on npmjs for this package (org Expressive-Tea, repo green-tea,
# before tagging. # workflow release.yml). npm also attaches build provenance automatically.
on: on:
push: push:
tags: ['v*'] tags: ['v*']
@@ -12,15 +12,17 @@ jobs:
publish-prod: publish-prod:
if: ${{ github.server_url == 'https://github.com' }} if: ${{ github.server_url == 'https://github.com' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
id-token: write # OIDC for Trusted Publishing (also enables provenance)
contents: read
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: '22' node-version: '22'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- run: npm install -g npm@latest # npm >= 11.5.1 is required for OIDC trusted publishing
- run: npm ci - run: npm ci
# `npm publish` runs prepublishOnly (lint + complexity + typecheck + test + build) first. # `npm publish` runs prepublishOnly (lint + complexity + typecheck + test + build) first.
- name: Publish to npmjs # No NODE_AUTH_TOKEN — npm exchanges the OIDC id-token for a short-lived publish token.
env: - run: npm publish --access public
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH }}
run: npm publish --access public