File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish to npm
2+
3+ # Triggers when a semver tag (v*) is pushed. Publishes `codeburn` to the npm
4+ # registry using npm OIDC trusted publishing, so no NPM_TOKEN lives in
5+ # secrets. The `npm-publish` Environment requires a human approval before
6+ # the publish step runs.
7+ on :
8+ push :
9+ tags :
10+ - ' v*'
11+ workflow_dispatch :
12+
13+ permissions :
14+ contents : read
15+ id-token : write # Required for npm OIDC provenance
16+
17+ jobs :
18+ publish :
19+ runs-on : ubuntu-latest
20+ environment : npm-publish
21+ steps :
22+ - name : Checkout
23+ uses : actions/checkout@v4
24+
25+ - name : Setup Node.js
26+ uses : actions/setup-node@v4
27+ with :
28+ node-version : ' 22'
29+ registry-url : ' https://registry.npmjs.org'
30+
31+ - name : Verify tag matches package.json
32+ run : |
33+ TAG_VERSION="${GITHUB_REF#refs/tags/v}"
34+ PKG_VERSION=$(node -p "require('./package.json').version")
35+ if [[ "$TAG_VERSION" != "$PKG_VERSION" ]]; then
36+ echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" >&2
37+ exit 1
38+ fi
39+
40+ - name : Install dependencies
41+ run : npm ci
42+
43+ - name : Build
44+ run : npm run build
45+
46+ - name : Run tests
47+ run : npm test -- --run
48+
49+ - name : Publish with provenance
50+ run : npm publish --provenance --access public
You can’t perform that action at this time.
0 commit comments