You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/packages-and-modules/securing-your-code/generating-provenance-statements.mdx
+40-23Lines changed: 40 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,55 +49,72 @@ To update your GitHub Actions workflow to publish your packages with provenance,
49
49
50
50
- Give permission to mint an ID-token:
51
51
52
-
```
52
+
```yaml
53
53
permissions:
54
54
id-token: write
55
55
```
56
56
57
57
- Run on a [GitHub-hosted runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources):
58
58
59
-
```
59
+
```yaml
60
60
runs-on: ubuntu-latest
61
61
```
62
62
63
63
- Add the `--provenance` flag to your publish command:
64
64
65
-
```
65
+
```sh
66
66
npm publish --provenance
67
67
```
68
68
69
69
- If you are publishing a package for the first time you will also need to explicitly set access to public:
70
70
71
-
```
71
+
```sh
72
72
npm publish --provenance --access public
73
73
```
74
74
75
75
### Example GitHub Actions workflow
76
76
77
77
This example workflow publishes a package to the npm registry with provenance.
78
78
79
-
```
79
+
```yaml
80
80
name: Publish Package to npmjs
81
81
on:
82
-
release:
83
-
types: [created]
82
+
release:
83
+
types: [created]
84
84
jobs:
85
-
build:
86
-
runs-on: ubuntu-latest
87
-
permissions:
88
-
contents: read
89
-
id-token: write
90
-
steps:
91
-
- uses: actions/checkout@v3
92
-
- uses: actions/setup-node@v3
93
-
with:
94
-
node-version: '18.x'
95
-
registry-url: 'https://registry.npmjs.org'
96
-
- run: npm install -g npm
97
-
- run: npm ci
98
-
- run: npm publish --provenance --access public
99
-
env:
100
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
85
+
build:
86
+
runs-on: ubuntu-latest
87
+
permissions:
88
+
contents: read
89
+
id-token: write
90
+
steps:
91
+
- uses: actions/checkout@v3
92
+
- uses: actions/setup-node@v3
93
+
with:
94
+
node-version: '18.x'
95
+
registry-url: 'https://registry.npmjs.org'
96
+
- run: npm install -g npm
97
+
- run: npm ci
98
+
- run: npm publish --provenance --access public
99
+
env:
100
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
101
+
```
102
+
103
+
### Example GitLab CI job
104
+
105
+
This example job publishes a package to the npm registry with provenance when a git tag is pushed. Don’t forget to define the `NPM_TOKEN` variable in your GitLab project settings.
106
+
107
+
```yaml
108
+
publish:
109
+
image: 'node:20'
110
+
rules:
111
+
- if: $CI_COMMIT_TAG
112
+
id_tokens:
113
+
SIGSTORE_ID_TOKEN:
114
+
aud: sigstore
115
+
script:
116
+
- npm config set //registry.npmjs.org/:_authToken "$NPM_TOKEN"
0 commit comments