-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (36 loc) · 1.23 KB
/
Copy pathpublish.yml
File metadata and controls
39 lines (36 loc) · 1.23 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
name: Publish to npm
on:
release:
types: [published]
push:
tags: ['v*']
permissions:
contents: read
id-token: write
jobs:
publish:
if: startsWith(github.event.release.tag_name, 'v') || startsWith(github.ref_name, 'v')
runs-on: ubuntu-latest
environment: npm
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.release.target_commitish || github.ref }}
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false
- run: npm ci
- run: npm run typecheck && npm run lint && npm test && npm run build
- name: Use current npm CLI for trusted publishing
run: npm install --global npm@latest && npm --version
- name: Publish when this version is not on npm yet
run: |
package_name=$(node -p "require('./package.json').name")
package_version=$(node -p "require('./package.json').version")
if npm view "${package_name}@${package_version}" version >/dev/null 2>&1; then
echo "${package_name}@${package_version} is already published; skipping."
exit 0
fi
npm publish --access public