-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (49 loc) · 1.64 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (49 loc) · 1.64 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
name: Publish to npm
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: read
# id-token: write lets npm sign provenance via sigstore OIDC.
# Registry auth uses NPM_TOKEN; provenance signing is a separate OIDC flow.
id-token: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Verify package.json version matches git tag
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
if [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "workflow_dispatch on main — skipping tag match check"
elif [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
echo "::error::package.json version ($PKG_VERSION) does not match git tag ($TAG_VERSION)"
exit 1
fi
- name: Test (mock backend + doctor regression guards)
run: npm test
- name: Verify dist/ is up to date
run: |
if [ -n "$(git diff --name-only dist/)" ]; then
echo "::error::dist/ is out of date. Run 'npm run build' and commit before tagging."
git diff --stat dist/
exit 1
fi
- name: Publish with provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --provenance --access public