-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (79 loc) · 2.56 KB
/
Copy pathrelease.yml
File metadata and controls
104 lines (79 loc) · 2.56 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Release
on:
release:
types: [published]
permissions:
contents: read
id-token: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: release-${{ github.event.release.tag_name }}
cancel-in-progress: false
jobs:
publish-npm:
name: Publish npm package
runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease }}
steps:
- name: Checkout release tag
uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org/
cache: npm
- name: Update npm
run: npm install -g npm@latest
- name: Verify release toolchain
run: |
node --version
npm --version
- name: Install dependencies
run: npm ci
- name: Verify release version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
node --input-type=module <<'NODE'
import { readFileSync } from 'node:fs';
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
const expectedTag = `v${pkg.version}`;
if (process.env.RELEASE_TAG !== expectedTag) {
throw new Error(`Release tag ${process.env.RELEASE_TAG} does not match package version ${expectedTag}`);
}
NODE
- name: Verify npm version is unpublished
run: |
node --input-type=module <<'NODE'
import { execFileSync } from 'node:child_process';
import { readFileSync } from 'node:fs';
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
const spec = `${pkg.name}@${pkg.version}`;
try {
execFileSync('npm', ['view', spec, 'version'], { stdio: 'pipe' });
} catch {
console.log(`${spec} is not published yet`);
process.exit(0);
}
throw new Error(`${spec} is already published on npm`);
NODE
- name: Lint
run: npm run lint -- --quiet
- name: Typecheck
run: npm run typecheck
- name: Test
run: npm test
- name: Build
run: npm run build
- name: Verify package exports
run: npm run smoke:exports
- name: Verify packed package install
run: npm run smoke:install
- name: Verify pack boundary
run: npm run pack:verify
- name: Publish to npm
run: npm publish --access public --provenance