Skip to content

Commit 344076b

Browse files
authored
feat(ci): npm OIDC trusted publishing with provenance (#469)
## Summary Switch npm publishing from `NPM_TOKEN` to OIDC trusted publishing with provenance attestations. ### Changes - Add `id-token: write` permission for OIDC token generation - Switch `yarn publish` → `npm publish --provenance` (Yarn 1.x doesn't support provenance) - `NPM_TOKEN` kept as fallback until trusted publishing is configured ### Setup required on npmjs.com 1. Go to https://www.npmjs.com/package/@netresearch/node-magento-eqp/access 2. **Trusted Publisher** → **GitHub Actions** 3. Enter: - Repository: `netresearch/node-magento-eqp` - Workflow: `release.when-tagged.yml` - Environment: *(leave blank)* 4. Save ### After setup Re-run the failed release workflow: ```bash gh run rerun 22063536695 --repo netresearch/node-magento-eqp ``` The package will publish with a **"Built and signed by GitHub Actions"** provenance badge on npmjs.com. ## Test plan - [ ] Configure trusted publisher on npmjs.com - [ ] Merge this PR - [ ] Re-run the release workflow or push a new tag - [ ] Verify provenance badge appears on npm package page
2 parents ece71c6 + cb67c1f commit 344076b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.github/workflows/pr-quality.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ jobs:
5252
run: gh pr review --approve "$PR_URL"
5353

5454
- name: Auto-approve (bot via APPROVE_TOKEN)
55-
if: steps.check-permission.outputs.permission == 'bot' && secrets.APPROVE_TOKEN != ''
55+
if: steps.check-permission.outputs.permission == 'bot'
5656
env:
5757
PR_URL: ${{ github.event.pull_request.html_url }}
58-
GH_TOKEN: ${{ secrets.APPROVE_TOKEN }}
59-
run: gh pr review --approve "$PR_URL"
58+
GH_TOKEN: ${{ secrets.APPROVE_TOKEN || secrets.GITHUB_TOKEN }}
59+
run: gh pr review --approve "$PR_URL" || true

.github/workflows/release.when-tagged.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Publish and create GitHub Release when a signed tag is pushed.
22
# Triggered by: git tag -s vX.Y.Z -m "vX.Y.Z" && git push origin vX.Y.Z
33
# Also available via workflow_dispatch for manual reruns.
4+
#
5+
# npm authentication uses OIDC trusted publishing (no NPM_TOKEN needed).
6+
# Setup: https://www.npmjs.com/package/@netresearch/node-magento-eqp/access
7+
# → Trusted Publisher → GitHub Actions → workflow: release.when-tagged.yml
48

59
name: 📦☁️ Release
610

@@ -13,6 +17,7 @@ on:
1317
permissions:
1418
contents: write
1519
packages: write
20+
id-token: write # OIDC trusted publishing to npm
1621

1722
env:
1823
HUSKY: '0'
@@ -37,8 +42,8 @@ jobs:
3742
- name: 🔨 Build
3843
run: yarn build:lib
3944

40-
- name: ☁️ Publish to NPM
41-
run: yarn publish --access=public
45+
- name: ☁️ Publish to NPM (OIDC + provenance)
46+
run: npm publish --access=public --provenance
4247
env:
4348
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4449

@@ -49,7 +54,7 @@ jobs:
4954
scope: '@netresearch'
5055

5156
- name: ☁️ Publish to GitHub Package Registry
52-
run: yarn publish --access=public
57+
run: npm publish --access=public
5358
env:
5459
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5560

0 commit comments

Comments
 (0)