-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (175 loc) · 5.87 KB
/
Copy pathrelease.yml
File metadata and controls
181 lines (175 loc) · 5.87 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Release
on:
push:
tags: ['v*']
concurrency:
group: release
cancel-in-progress: false
jobs:
verify-publish-credentials:
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Verify npm publish token
run: |
if [ -z "$NODE_AUTH_TOKEN" ]; then
echo "NPM_TOKEN secret is required before building release binaries." >&2
exit 1
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
build-native:
needs: verify-publish-credentials
strategy:
fail-fast: false
matrix:
include:
- os: macos-15
target: aarch64-apple-darwin
platform: darwin-arm64
flags: ''
- os: macos-15-intel
target: x86_64-apple-darwin
platform: darwin-x64
flags: ''
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
platform: linux-arm64-gnu
flags: --use-napi-cross
- os: ubuntu-24.04
target: x86_64-unknown-linux-gnu
platform: linux-x64-gnu
flags: --use-napi-cross
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
platform: linux-arm64-musl
flags: -x
zig_arch: aarch64
zig_sha256: f7a654acc967864f7a050ddacfaa778c7504a0eca8d2b678839c21eea47c992b
- os: ubuntu-24.04
target: x86_64-unknown-linux-musl
platform: linux-x64-musl
flags: -x
zig_arch: x86_64
zig_sha256: 24aeeec8af16c381934a6cd7d95c807a8cb2cf7df9fa40d359aa884195c4716c
- os: windows-2025
target: x86_64-pc-windows-msvc
platform: win32-x64-msvc
flags: ''
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v4.4.0
with:
version: 11.20.0
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.97.1
targets: ${{ matrix.target }}
- name: Install Zig
if: contains(matrix.target, 'musl')
shell: bash
run: |
zig_archive="$RUNNER_TEMP/zig.tar.xz"
zig_dir="$RUNNER_TEMP/zig"
curl -fsSLo "$zig_archive" "https://ziglang.org/download/0.14.1/zig-${{ matrix.zig_arch }}-linux-0.14.1.tar.xz"
echo "${{ matrix.zig_sha256 }} $zig_archive" | sha256sum -c -
mkdir -p "$zig_dir"
tar -xJf "$zig_archive" -C "$zig_dir" --strip-components=1
echo "$zig_dir" >> "$GITHUB_PATH"
- uses: taiki-e/install-action@v2
if: contains(matrix.target, 'musl')
with:
tool: cargo-zigbuild
- run: pnpm install --frozen-lockfile
- name: Build native binding
shell: bash
run: pnpm exec napi build --release --platform --no-js --dts native.d.ts --target ${{ matrix.target }} ${{ matrix.flags }}
- name: Load test native binding
shell: bash
run: |
if [[ '${{ matrix.platform }}' == *-musl ]]; then
docker run --rm -v "$PWD:/work" -w /work node:20-alpine node -e "require('./index.${{ matrix.platform }}.node')"
else
node -e "require('./index.${{ matrix.platform }}.node')"
fi
- name: Stage native package
shell: bash
run: |
mkdir -p release/${{ matrix.platform }}
cp index.${{ matrix.platform }}.node release/${{ matrix.platform }}/
cp npm/${{ matrix.platform }}/package.json npm/${{ matrix.platform }}/README.md release/${{ matrix.platform }}/
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.platform }}
path: release/${{ matrix.platform }}
if-no-files-found: error
retention-days: 7
publish:
needs:
- verify-publish-credentials
- build-native
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v4.4.0
with:
version: 11.20.0
- uses: actions/setup-node@v7
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.97.1
- run: pnpm install --frozen-lockfile
- name: Verify release source
run: pnpm run check
- uses: actions/download-artifact@v8
with:
path: artifacts
- run: pnpm exec napi artifacts --output-dir artifacts --npm-dir npm
- name: Verify release version and artifacts
shell: bash
run: |
test "v$(node -p "require('./package.json').version")" = "$GITHUB_REF_NAME"
node scripts/check-artifacts.mjs npm
pnpm exec napi prepublish -t npm --no-gh-release --dry-run
- name: Dry-run every package
shell: bash
run: |
for target in darwin-arm64 darwin-x64 linux-arm64-gnu linux-arm64-musl linux-x64-gnu linux-x64-musl win32-x64-msvc; do
npm pack --dry-run --ignore-scripts "./npm/$target"
done
npm pack --dry-run --ignore-scripts
- name: Publish native packages, then root
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_ACCESS: public
NPM_CONFIG_PROVENANCE: true
github-release:
needs: publish
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: >
gh release create "$GITHUB_REF_NAME"
--repo "$GITHUB_REPOSITORY"
--verify-tag
--generate-notes