-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (58 loc) · 2.02 KB
/
Copy pathpublish.yml
File metadata and controls
72 lines (58 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: publish
on:
release:
types: [published]
permissions:
contents: read
id-token: write
attestations: write
artifact-metadata: write
jobs:
publish:
name: publish to npmjs
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v6
- name: setup node 24
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm
- name: verify publish toolchain
run: |
node --version
npm --version
node -e "const version = require('node:child_process').execFileSync('npm', ['--version'], { encoding: 'utf8' }).trim(); const [major, minor, patch] = version.split('.').map(Number); if (major < 11 || (major === 11 && (minor < 5 || (minor === 5 && patch < 1)))) throw new Error('npm 11.5.1 or newer is required for trusted publishing')"
- name: install dependencies
run: npm ci
- name: run tests
run: npm test
- name: audit dependencies
run: npm audit --audit-level=moderate
- name: verify runtime dependency tree
run: npm ls --omit=dev --all
- name: pack package
id: pack
run: |
mkdir -p dist
npm pack --json --pack-destination dist > dist/pack.json
tarball="$(find dist -maxdepth 1 -name '*.tgz' -print -quit)"
test -n "$tarball"
echo "tarball=$tarball" >> "$GITHUB_OUTPUT"
- name: attest npm package artifact
uses: actions/attest@v4
with:
subject-path: ${{ steps.pack.outputs.tarball }}
- name: upload npm package artifact
uses: actions/upload-artifact@v4
with:
name: npm-package
path: ${{ steps.pack.outputs.tarball }}
if-no-files-found: error
- name: publish package
run: npm publish "$TARBALL" --provenance --access public
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}