-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (73 loc) · 2.16 KB
/
Copy pathrelease.yml
File metadata and controls
86 lines (73 loc) · 2.16 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: "Release tag to build and publish (e.g. v0.1.0)"
required: true
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.release.tag_name }}
- uses: actions/setup-node@v7
with:
node-version: "22.x"
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Install
run: npm ci
- name: Verify version matches release tag
env:
TAG: ${{ github.event.release.tag_name || github.event.inputs.tag }}
run: |
PKG=$(node -p "require('./package.json').version")
if [ "${TAG#v}" != "$PKG" ]; then
echo "ERROR: release tag $TAG does not match package.json version $PKG." >&2
echo "Bump the version before cutting the release." >&2
exit 1
fi
echo "OK: tag $TAG matches package.json version $PKG"
- name: Typecheck, lint and test
run: |
npm run typecheck
npm run lint
npm test
- name: Pack
run: npm pack
- uses: actions/upload-artifact@v7
with:
name: tarball
path: "*.tgz"
publish:
needs: build
if: vars.PUBLISH_TO_NPM == 'true'
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.release.tag_name }}
- uses: actions/setup-node@v7
with:
node-version: "22.x"
cache: npm
registry-url: "https://registry.npmjs.org"
- name: Install
run: npm ci
# npm >= 11.5.1 publishes with a provenance attestation via OIDC when
# id-token: write is granted. NODE_AUTH_TOKEN is still needed unless the
# package is configured for trusted publishing on npmjs.com.
- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}