Skip to content

Commit fd97c84

Browse files
authored
Merge pull request #617 from PolicyEngine/fix/npm-oidc-publishing
ci: switch npm publishing to GitHub OIDC provenance
2 parents 4a01b0a + 077c3ee commit fd97c84

File tree

3 files changed

+24
-52
lines changed

3 files changed

+24
-52
lines changed

.github/workflows/publish-design-system.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# - Manual workflow dispatch
66
#
77
# Prerequisites:
8-
# - NPM_TOKEN secret configured in repo settings
98
# - @policyengine org exists on npmjs.com
9+
# - Package is linked to this GitHub repo on npmjs.com for OIDC provenance
1010
#
1111
# Version bumps are determined automatically from commit messages:
1212
# - fix: ... → patch (0.1.0 → 0.1.1)
@@ -27,6 +27,11 @@ on:
2727
jobs:
2828
publish:
2929
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
issues: write
33+
pull-requests: write
34+
id-token: write
3035
defaults:
3136
run:
3237
working-directory: .
@@ -42,7 +47,6 @@ jobs:
4247
uses: actions/setup-node@v4
4348
with:
4449
node-version: "22"
45-
registry-url: "https://registry.npmjs.org"
4650

4751
- name: Install dependencies
4852
run: npm ci
@@ -58,7 +62,6 @@ jobs:
5862
working-directory: packages/design-system
5963
env:
6064
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6265

6366
- name: Summary
6467
run: |

packages/design-system/.releaserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"plugins": [
44
"@semantic-release/commit-analyzer",
55
"@semantic-release/release-notes-generator",
6-
"@semantic-release/npm",
6+
["@semantic-release/npm", { "provenance": true }],
77
"@semantic-release/github"
88
]
99
}

packages/design-system/NPM_SETUP.md

Lines changed: 17 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Publishing @policyengine/design-system to npm
22

3-
This document describes how to set up and publish the design system package to npm.
3+
This document describes how the design system package is published to npm.
44

55
## Prerequisites
66

@@ -19,45 +19,31 @@ npm view @policyengine/design-system
1919
2. Create organization named `policyengine`
2020
3. Add team members with appropriate access
2121

22-
### 2. npm Access Token
22+
### 2. Link package to GitHub repo (OIDC provenance)
2323

24-
Generate an automation token for CI/CD:
24+
Publishing uses GitHub Actions OIDC — no npm tokens or secrets needed. For this to work, the package must be linked to the GitHub repo on npmjs.com:
2525

26-
1. Log in to https://www.npmjs.com
27-
2. Go to Access Tokens → Generate New Token
28-
3. Select **"Automation"** type (bypasses 2FA for CI)
29-
4. Copy the token (starts with `npm_...`)
26+
1. Go to https://www.npmjs.com/package/@policyengine/design-system/access
27+
2. Under "Publishing access", link to the `PolicyEngine/policyengine-app-v2` GitHub repository
3028

31-
### 3. GitHub Secret
32-
33-
Add the npm token as a repository secret:
34-
35-
1. Go to repo Settings → Secrets and variables → Actions
36-
2. Click "New repository secret"
37-
3. Name: `NPM_TOKEN`
38-
4. Value: paste the npm token
39-
5. Click "Add secret"
29+
This allows GitHub Actions to authenticate with npm using a short-lived OIDC token, and published versions get a verified provenance badge.
4030

4131
## Publishing
4232

4333
### Automatic (Recommended)
4434

45-
The package is automatically published when you create a GitHub Release:
46-
47-
1. Update version in `packages/design-system/package.json`
48-
2. Commit and push to main
49-
3. Create a new Release on GitHub
50-
4. The `publish-design-system.yaml` workflow triggers automatically
35+
Publishing is handled automatically by [semantic-release](https://github.com/semantic-release/semantic-release) via the `publish-design-system.yaml` workflow. It triggers on:
5136

52-
### Manual
37+
- Push to `main` with changes in `packages/design-system/**`
38+
- Manual `workflow_dispatch`
5339

54-
Trigger the workflow manually:
40+
Version bumps are determined from **conventional commit messages** — no manual version changes needed:
5541

56-
1. Go to Actions → "Publish Design System"
57-
2. Click "Run workflow"
58-
3. Optionally enable "Dry run" to test without publishing
42+
- `fix: ...` → patch (0.1.0 → 0.1.1)
43+
- `feat: ...` → minor (0.1.0 → 0.2.0)
44+
- `feat!: ...` or `BREAKING CHANGE:` → major (0.1.0 → 1.0.0)
5945

60-
### Local (Development)
46+
### Manual (Development)
6147

6248
```bash
6349
# Login to npm (one-time)
@@ -70,23 +56,6 @@ npm run build --workspace=@policyengine/design-system
7056
npm publish --workspace=@policyengine/design-system --access public
7157
```
7258

73-
## Version Bumping
74-
75-
Before publishing a new version:
76-
77-
```bash
78-
cd packages/design-system
79-
80-
# Patch (0.1.0 → 0.1.1) - bug fixes
81-
npm version patch
82-
83-
# Minor (0.1.0 → 0.2.0) - new features
84-
npm version minor
85-
86-
# Major (0.1.0 → 1.0.0) - breaking changes
87-
npm version major
88-
```
89-
9059
## Consuming the Package
9160

9261
### JavaScript/TypeScript
@@ -131,12 +100,12 @@ https://unpkg.com/@policyengine/design-system/dist/tokens.json
131100
- You may not have publish access to the org
132101

133102
### "npm ERR! 403 Forbidden"
134-
- Token may be expired or invalid
135-
- Token may not have publish permissions
103+
- OIDC provenance may not be configured (see Prerequisites step 2)
104+
- The workflow may be missing `id-token: write` permission
136105

137106
### "npm ERR! 402 Payment Required"
138107
- Trying to publish private package without paid npm account
139-
- Ensure `--access public` flag is used
108+
- Ensure `publishConfig.access` is `"public"` in package.json
140109

141110
## Package Contents
142111

0 commit comments

Comments
 (0)