-
Notifications
You must be signed in to change notification settings - Fork 1
259 lines (252 loc) · 8.56 KB
/
release.yml
File metadata and controls
259 lines (252 loc) · 8.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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: Release
on:
push:
tags:
- "v*.*.*" # Trigger on version tags like v1.2.3
jobs:
setup:
name: Resolve primary Node version
runs-on: ubuntu-latest
permissions: {}
outputs:
primary-node: ${{ steps.read.outputs.version }}
steps:
- uses: actions/checkout@v6
- id: read
run: echo "version=$(cat .node-version)" >> "$GITHUB_OUTPUT"
build-napi:
name: Build N-API modules
runs-on: ${{ matrix.settings.host }}
permissions: {}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
settings:
- host: macos-15-intel
target: x86_64-apple-darwin
npm_platform: darwin-x64
- host: macos-latest
target: aarch64-apple-darwin
npm_platform: darwin-arm64
- host: windows-latest
target: x86_64-pc-windows-msvc
npm_platform: win32-x64-msvc
- host: windows-11-arm
target: aarch64-pc-windows-msvc
npm_platform: win32-arm64-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
npm_platform: linux-x64-gnu
- host: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
npm_platform: linux-arm64-gnu
steps:
# Speed up apt-get operations by disabling unnecessary man-db auto-update
- name: Disable man-db auto-update
if: runner.os == 'Linux'
run: |
echo "man-db man-db/auto-update boolean false" | sudo debconf-set-selections
sudo rm -f /var/lib/man-db/auto-update
- uses: actions/checkout@v6
- name: Enable Corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: pnpm
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
- name: Setup Task runner
uses: go-task/setup-task@v2
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libcups2-dev pkg-config clang
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build N-API module
run: |
echo "Building for target: ${{ matrix.settings.target }}"
task build:napi
- name: Post-build cleanup
run: |
# Remove all NPM directory contents except the current platform (cross-platform)
cd npm/
for dir in */; do
if [ -d "$dir" ] && [ "$dir" != "${{ matrix.settings.npm_platform }}/" ]; then
echo "Removing directory: $dir"
rm -rf "$dir"
fi
done
cd ..
echo "Contents of npm/${{ matrix.settings.npm_platform }}:"
if [ "$RUNNER_OS" = "Windows" ]; then
dir "npm\\${{ matrix.settings.npm_platform }}\\" 2>/dev/null || echo "Directory listing failed"
else
ls -la "npm/${{ matrix.settings.npm_platform }}/" || echo "Directory listing failed"
fi
# Ensure there's a second file in the NPM directory to avoid upload-artifact stripping the target directory
touch npm/ignore.txt
- name: Upload N-API artifact
uses: actions/upload-artifact@v7
with:
name: npm-binaries-${{ matrix.settings.target }}
path: npm/
if-no-files-found: error
test-targets:
name: Cross-runtime test on ${{ matrix.settings.target }} (Node ${{ matrix.node }})
runs-on: ${{ matrix.settings.host }}
needs: [build-napi, setup]
permissions: {}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node: [22, 24]
settings:
- host: macos-15-intel
target: x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: windows-11-arm
target: aarch64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
steps:
# Speed up apt-get operations by disabling unnecessary man-db auto-update
- name: Disable man-db auto-update and install deps
if: runner.os == 'Linux'
run: |
echo "man-db man-db/auto-update boolean false" | sudo debconf-set-selections
sudo rm -f /var/lib/man-db/auto-update
sudo apt-get update
sudo apt-get install -y libcups2-dev pkg-config clang
- uses: actions/checkout@v6
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
cache: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
no-cache: true
- name: Enable Corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache: false
- name: Setup Task runner
uses: go-task/setup-task@v2
- name: Download all N-API binary artifacts
uses: actions/download-artifact@v8
with:
pattern: npm-binaries-*
path: npm-temp
- name: Reconstruct npm directory structure
run: |
mkdir -p npm
# Move each platform's files to the correct npm subdirectory
for artifact_dir in npm-temp/npm-binaries-*/; do
if [ -d "$artifact_dir" ]; then
# Copy the platform directory contents to npm/
cp -r "$artifact_dir"* npm/ 2>/dev/null || true
fi
done
ls -la npm/ 2>/dev/null || dir npm
- name: Install Node.js dependencies
run: pnpm install --frozen-lockfile
- name: Run comprehensive tests (includes compilation)
run: |
# Only the primary Node version (sourced from .node-version via the
# setup job) runs the full cross-runtime suite. Other Node versions
# only re-run the Node runtime tests, since Rust/Deno/Bun results
# don't depend on the installed Node.
if [ "${{ matrix.node }}" != "${{ needs.setup.outputs.primary-node }}" ]; then
echo "Running Node-only tests for Node ${{ matrix.node }}"
task test -- node
else
echo "Running all runtime tests"
task test
fi
publish:
name: Publish to npm
runs-on: ubuntu-latest
needs: test-targets
permissions:
contents: write
id-token: write
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Setup Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Enable Corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install Node.js dependencies
run: pnpm install --frozen-lockfile
- name: Download all N-API binary artifacts
uses: actions/download-artifact@v8
with:
pattern: npm-binaries-*
path: npm-temp
- name: Reconstruct npm directory structure
run: |
mkdir -p npm
# Move each platform's files to the correct npm subdirectory
for artifact_dir in npm-temp/npm-binaries-*/; do
if [ -d "$artifact_dir" ]; then
# Copy the platform directory contents to npm/
cp -r "$artifact_dir"* npm/ 2>/dev/null || true
fi
done
ls -la npm/ 2>/dev/null || dir npm
- name: Compile TypeScript for publishing
run: task compile
- name: Collect native binaries for release
run: |
mkdir -p release-assets
for binary in npm/*/printers.*.node; do
if [ -f "$binary" ]; then
cp "$binary" release-assets/
fi
done
ls -la release-assets/
- name: Publish GitHub release with native binaries
uses: softprops/action-gh-release@v3
with:
files: release-assets/*.node
fail_on_unmatched_files: true
- name: Publish to npm
run: pnpm publish --no-git-checks