Skip to content

Commit 3a84b51

Browse files
committed
Update publish workflow to use OIDC authentication with provenance
Workflow changes: - Add permissions for id-token: write and contents: read - Enable OIDC authentication for npm publishing - Add --provenance flag for supply chain security - Add --access public flag to ensure package visibility Documentation updates: - Update workflows/README.md with OIDC authentication details - Explain provenance attestations and security benefits - Add manual publishing instructions with --access public flag - Update main README to highlight provenance publishing Benefits: - Enhanced security through OIDC authentication - Supply chain transparency with provenance attestations - Automatic attestation generation on GitHub Actions - Better verification of package authenticity
1 parent e079ff7 commit 3a84b51

File tree

3 files changed

+51
-12
lines changed

3 files changed

+51
-12
lines changed

.github/workflows/README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ Runs automatically when a new GitHub release is created.
2020
**What it does:**
2121
- Installs dependencies
2222
- Runs tests to ensure quality
23-
- Publishes the package to npm
23+
- Publishes the package to npm with provenance using OIDC authentication
24+
25+
**Features:**
26+
- Uses OpenID Connect (OIDC) for secure authentication
27+
- Publishes with `--provenance` flag for supply chain security
28+
- Automatically makes the package public with `--access public`
2429

2530
## Publishing to npm
2631

@@ -48,27 +53,52 @@ To publish a new version:
4853
- Run tests
4954
- Publish to npm if tests pass
5055

51-
## Required Secrets
56+
## Required Setup
57+
58+
### NPM Authentication
5259

53-
For the publish workflow to work, you need to add an `NPM_TOKEN` secret to your GitHub repository:
60+
The workflow uses OIDC (OpenID Connect) authentication with provenance for enhanced security. You still need to configure an `NPM_TOKEN` secret:
5461

55-
1. Generate an npm token:
62+
1. Generate an npm Automation token:
5663
- Log in to https://www.npmjs.com
5764
- Go to Account Settings → Access Tokens
58-
- Generate a new "Automation" token
65+
- Click "Generate New Token" → Choose "Automation"
66+
- Copy the generated token
5967

6068
2. Add the token to GitHub:
6169
- Go to repository Settings → Secrets and variables → Actions
6270
- Click "New repository secret"
6371
- Name: `NPM_TOKEN`
64-
- Value: Your npm token
72+
- Value: Your npm automation token
6573
- Click "Add secret"
6674

75+
### OIDC Permissions
76+
77+
The workflow includes the required permissions:
78+
```yaml
79+
permissions:
80+
id-token: write # Required for OIDC authentication
81+
contents: read
82+
```
83+
84+
These permissions allow the workflow to:
85+
- Authenticate with npm using OIDC
86+
- Generate provenance attestations for supply chain security
87+
- Read repository contents for publishing
88+
6789
## Manual Publishing
6890
6991
If you prefer to publish manually:
7092
7193
```bash
7294
npm login
73-
npm publish
95+
npm publish --access public
7496
```
97+
98+
To publish with provenance locally (requires npm 9.5.0+):
99+
100+
```bash
101+
npm publish --provenance --access public
102+
```
103+
104+
**Note:** Provenance generation may not work from all environments. GitHub Actions is the recommended way to publish with provenance.

.github/workflows/publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ jobs:
88
publish:
99
runs-on: ubuntu-latest
1010

11+
permissions:
12+
id-token: write # Required for OIDC authentication
13+
contents: read
14+
1115
steps:
1216
- name: Checkout code
1317
uses: actions/checkout@v4
@@ -24,7 +28,7 @@ jobs:
2428
- name: Run tests
2529
run: npm test
2630

27-
- name: Publish to npm
28-
run: npm publish
31+
- name: Publish to npm with provenance
32+
run: npm publish --provenance --access public
2933
env:
3034
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ This creates test projects in `test-manual/` for manual verification. Clean up w
9090

9191
### Automated Publishing (Recommended)
9292

93-
The package is automatically published to npm when a new GitHub release is created:
93+
The package is automatically published to npm with provenance when a new GitHub release is created:
9494

9595
1. Update the version:
9696
```bash
@@ -105,15 +105,20 @@ The package is automatically published to npm when a new GitHub release is creat
105105
```
106106

107107
3. Create a GitHub release at https://github.com/ServiceStack/create-net/releases/new
108-
- The GitHub Action will automatically run tests and publish to npm
108+
- The GitHub Action will automatically run tests and publish to npm with provenance
109+
110+
**Security Features:**
111+
- Uses OIDC authentication for secure publishing
112+
- Generates provenance attestations for supply chain security
113+
- Published with `--access public` flag
109114

110115
### Manual Publishing
111116

112117
To publish manually:
113118

114119
```bash
115120
npm login
116-
npm publish
121+
npm publish --access public
117122
```
118123

119124
**Note:** You need to configure the `NPM_TOKEN` secret in GitHub repository settings for automated publishing. See [`.github/workflows/README.md`](.github/workflows/README.md) for details.

0 commit comments

Comments
 (0)