4
4
- pull_request
5
5
permissions : {}
6
6
jobs :
7
- github-runner :
7
+ build-native :
8
8
permissions :
9
- contents : write
10
- name : ${{ matrix.platform }} - Node.js ${{ matrix.nodejs_version_major }} ${{ matrix.prebuild && '- prebuild ' }}
9
+ contents : read
10
+ name : " build- ${{ matrix.platform }} [ Node.js ${{ matrix.nodejs_version_major }}] ${{ matrix.package && '[package] ' }}"
11
11
runs-on : ${{ matrix.os }}
12
- container :
13
- image : ${{ matrix.container }}
14
- volumes :
15
- - /:/host
12
+ container : ${{ matrix.container }}
16
13
strategy :
17
14
fail-fast : false
18
15
matrix :
23
20
nodejs_version : " ^18.17.0"
24
21
nodejs_version_major : 18
25
22
platform : linux-x64
26
- prebuild : true
23
+ package : true
27
24
- os : ubuntu-24.04
28
25
container : rockylinux:8
29
26
nodejs_arch : x64
40
37
container : node:18-alpine3.17
41
38
nodejs_version_major : 18
42
39
platform : linuxmusl-x64
43
- prebuild : true
40
+ package : true
44
41
- os : ubuntu-24.04
45
42
container : node:20-alpine3.18
46
43
nodejs_version_major : 20
@@ -55,28 +52,19 @@ jobs:
55
52
nodejs_version : " ^18.17.0"
56
53
nodejs_version_major : 18
57
54
platform : linux-arm64
58
- prebuild : true
55
+ package : true
59
56
- os : ubuntu-24.04-arm
60
57
container : arm64v8/rockylinux:8
61
58
nodejs_arch : arm64
62
59
nodejs_version : " ^20.3.0"
63
60
nodejs_version_major : 20
64
61
platform : linux-arm64
65
- - os : ubuntu-24.04-arm
66
- container : node:18-alpine3.17
67
- nodejs_version_major : 18
68
- platform : linuxmusl-arm64
69
- prebuild : true
70
- - os : ubuntu-24.04-arm
71
- container : node:20-alpine3.18
72
- nodejs_version_major : 20
73
- platform : linuxmusl-arm64
74
62
- os : macos-13
75
63
nodejs_arch : x64
76
64
nodejs_version : " ^18.17.0"
77
65
nodejs_version_major : 18
78
66
platform : darwin-x64
79
- prebuild : true
67
+ package : true
80
68
- os : macos-13
81
69
nodejs_arch : x64
82
70
nodejs_version : " ^20.3.0"
92
80
nodejs_version : " ^18.17.0"
93
81
nodejs_version_major : 18
94
82
platform : darwin-arm64
95
- prebuild : true
83
+ package : true
96
84
- os : macos-14
97
85
nodejs_arch : arm64
98
86
nodejs_version : " ^20.3.0"
108
96
nodejs_version : " 18.18.2" # pinned to avoid 18.19.0 and npm 10
109
97
nodejs_version_major : 18
110
98
platform : win32-ia32
111
- prebuild : true
99
+ package : true
112
100
- os : windows-2022
113
101
nodejs_arch : x86
114
102
nodejs_version : " ^20.3.0"
@@ -124,7 +112,7 @@ jobs:
124
112
nodejs_version : " ^18.17.0"
125
113
nodejs_version_major : 18
126
114
platform : win32-x64
127
- prebuild : true
115
+ package : true
128
116
- os : windows-2022
129
117
nodejs_arch : x64
130
118
nodejs_version : " ^20.3.0"
@@ -140,28 +128,18 @@ jobs:
140
128
nodejs_version : " ^20.3.0"
141
129
nodejs_version_major : 20
142
130
platform : win32-arm64
143
- prebuild : true
131
+ package : true
144
132
- os : windows-11-arm
145
133
nodejs_arch : arm64
146
134
nodejs_version : " ^22.9.0"
147
135
nodejs_version_major : 22
148
136
platform : win32-arm64
149
137
steps :
150
- - name : Allow Linux musl containers on ARM64 runners # https://github.com/actions/runner/issues/801#issuecomment-2394425757
151
- if : matrix.platform == 'linuxmusl-arm64'
152
- shell : sh
153
- run : |
154
- apk add nodejs
155
- sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release
156
- cd /host/home/runner/runners/*/externals/
157
- rm -rf node20/*
158
- mkdir node20/bin
159
- ln -s /usr/bin/node node20/bin/node
160
138
- name : Dependencies (Rocky Linux glibc)
161
139
if : contains(matrix.container, 'rockylinux')
162
140
run : |
163
- dnf install -y gcc-toolset-11 -gcc-c++ make git python3.12 fontconfig google-noto-sans-fonts
164
- echo "/opt/rh/gcc-toolset-11 /root/usr/bin" >> $GITHUB_PATH
141
+ dnf install -y gcc-toolset-14 -gcc-c++ make git python3.12 fontconfig google-noto-sans-fonts
142
+ echo "/opt/rh/gcc-toolset-14 /root/usr/bin" >> $GITHUB_PATH
165
143
- name : Dependencies (Linux musl)
166
144
if : contains(matrix.container, 'alpine')
167
145
run : apk add build-base git python3 font-noto --update-cache
@@ -176,31 +154,70 @@ jobs:
176
154
with :
177
155
node-version : ${{ matrix.nodejs_version }}
178
156
architecture : ${{ matrix.nodejs_arch }}
179
- - name : Checkout
180
- uses : actions/checkout@v4
157
+ - uses : actions/checkout@v4
181
158
- name : Install
182
159
run : npm install --build-from-source
183
160
- name : Test
184
161
run : npm test
185
- - name : Test packaging
186
- run : |
187
- npm run package-from-local-build
188
- npm pkg set "optionalDependencies.@img/sharp-${{ matrix.platform }}=file:./npm/${{ matrix.platform }}"
189
- npm run clean
190
- npm install --ignore-scripts
191
- npm test
192
- - name : Prebuild
193
- if : matrix.prebuild && startsWith(github.ref, 'refs/tags/')
194
- env :
195
- prebuild_upload : ${{ secrets.GITHUB_TOKEN }}
162
+ - name : Populate npm package
163
+ if : matrix.package
164
+ run : npm run package-from-local-build
165
+ - uses : actions/upload-artifact@v4
166
+ if : matrix.package
167
+ with :
168
+ name : ${{ matrix.platform }}
169
+ path : npm/${{ matrix.platform }}
170
+ retention-days : 1
171
+ if-no-files-found : error
172
+ build-linuxmusl-arm-64 :
173
+ permissions :
174
+ contents : read
175
+ name : " build-linuxmusl-arm64 [Node.js ${{ matrix.nodejs_version_major }}] ${{ matrix.package && '[package]' }}"
176
+ runs-on : ubuntu-24.04-arm
177
+ container :
178
+ image : ${{ matrix.container }}
179
+ volumes :
180
+ - /:/host
181
+ strategy :
182
+ fail-fast : false
183
+ matrix :
184
+ include :
185
+ - container : node:18-alpine3.17
186
+ nodejs_version_major : 18
187
+ package : true
188
+ - container : node:20-alpine3.18
189
+ nodejs_version_major : 20
190
+ steps :
191
+ - name : Allow Linux musl containers on ARM64 runners # https://github.com/actions/runner/issues/801#issuecomment-2394425757
192
+ shell : sh
196
193
run : |
197
- node -e "require('fs').cpSync('package.json', 'src/package.json')"
198
- cd src
199
- npx prebuild
200
- github-runner-qemu :
194
+ apk add nodejs
195
+ sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release
196
+ cd /host/home/runner/runners/*/externals/
197
+ rm -rf node20/*
198
+ mkdir node20/bin
199
+ ln -s /usr/bin/node node20/bin/node
200
+ - name : Dependencies
201
+ run : apk add build-base git python3 font-noto --update-cache
202
+ - uses : actions/checkout@v4
203
+ - name : Install
204
+ run : npm install --build-from-source
205
+ - name : Test
206
+ run : npm test
207
+ - name : Populate npm package
208
+ if : matrix.package
209
+ run : npm run package-from-local-build
210
+ - uses : actions/upload-artifact@v4
211
+ if : matrix.package
212
+ with :
213
+ name : linuxmusl-arm64
214
+ path : npm/linuxmusl-arm64
215
+ retention-days : 1
216
+ if-no-files-found : error
217
+ build-qemu :
201
218
permissions :
202
- contents : write
203
- name : ${{ matrix.platform }} - Node.js ${{ matrix.nodejs_version_major }} - prebuild
219
+ contents : read
220
+ name : " build- ${{ matrix.platform }} [ Node.js ${{ matrix.nodejs_version_major }}] [package] "
204
221
runs-on : ubuntu-24.04
205
222
strategy :
206
223
fail-fast : false
@@ -233,8 +250,6 @@ jobs:
233
250
with :
234
251
arch : ${{ matrix.run_on_arch }}
235
252
distro : ${{ matrix.distro }}
236
- env : |
237
- prebuild_upload: "${{ startsWith(github.ref, 'refs/tags/') && secrets.GITHUB_TOKEN || '' }}"
238
253
run : |
239
254
apt-get update
240
255
apt-get install -y curl g++ git libatomic1 make python3 xz-utils
@@ -244,20 +259,20 @@ jobs:
244
259
npm install --build-from-source
245
260
npx mocha --no-config --spec=test/unit/io.js --timeout=30000
246
261
npm run package-from-local-build
247
- npm pkg set "optionalDependencies.@img/sharp-${{ matrix.platform }}=file:./npm/${{ matrix.platform }}"
248
- npm run clean
249
- npm install --ignore-scripts
250
- npx mocha --no-config --spec=test/unit/io.js --timeout=30000
251
- [[ -n $prebuild_upload ]] && cd src && ln -s ../package.json && npx prebuild || true
252
- github-runner-emscripten :
262
+ - uses : actions/upload-artifact@v4
263
+ with :
264
+ name : ${{ matrix.platform }}
265
+ path : npm/${{ matrix.platform }}
266
+ retention-days : 1
267
+ if-no-files-found : error
268
+ build-emscripten :
253
269
permissions :
254
- contents : write
255
- name : wasm32 - prebuild
270
+ contents : read
271
+ name : " build- wasm32 [package] "
256
272
runs-on : ubuntu-24.04
257
273
container : " emscripten/emsdk:4.0.10"
258
274
steps :
259
- - name : Checkout
260
- uses : actions/checkout@v4
275
+ - uses : actions/checkout@v4
261
276
- name : Dependencies
262
277
run : apt-get update && apt-get install -y pkg-config
263
278
- name : Dependencies (Node.js)
@@ -275,17 +290,35 @@ jobs:
275
290
test "$EMSCRIPTEN_VERSION_LIBVIPS" = "$EMSCRIPTEN_VERSION_SHARP"
276
291
- name : Test
277
292
run : emmake npm test
278
- - name : Test packaging
279
- run : |
280
- emmake npm run package-from-local-build
281
- npm pkg set "optionalDependencies.@img/sharp-wasm32=file:./npm/wasm32"
282
- npm run clean
283
- rm -rf node_modules/@img/sharp-linux-x64
284
- npm install --cpu=wasm32
285
- npm test
286
- - name : Prebuild
287
- if : startsWith(github.ref, 'refs/tags/')
288
- env :
289
- npm_config_nodedir : emscripten
290
- prebuild_upload : ${{ secrets.GITHUB_TOKEN }}
291
- run : cd src && ln -s ../package.json && emmake npx prebuild --platform=emscripten --arch=wasm32 --strip=0
293
+ - name : Populate npm package
294
+ run : emmake npm run package-from-local-build
295
+ - uses : actions/upload-artifact@v4
296
+ with :
297
+ name : wasm32
298
+ path : npm/wasm32
299
+ retention-days : 1
300
+ if-no-files-found : error
301
+ release :
302
+ permissions :
303
+ contents : write
304
+ runs-on : ubuntu-24.04
305
+ needs :
306
+ - build-native
307
+ - build-linuxmusl-arm-64
308
+ - build-qemu
309
+ - build-emscripten
310
+ steps :
311
+ - uses : actions/checkout@v4
312
+ - uses : actions/download-artifact@v4
313
+ with :
314
+ path : npm
315
+ - name : Create npm workspace tarball
316
+ run : tar -vcaf npm-workspace.tar.xz --directory npm --exclude=from-local-build.js .
317
+ - name : Create GitHub release for tag
318
+ if : startsWith(github.ref, 'refs/tags/v')
319
+ uses : ncipollo/release-action@v1
320
+ with :
321
+ artifacts : npm-workspace.tar.xz
322
+ artifactContentType : application/x-xz
323
+ prerelease : ${{ contains(github.ref, '-rc') }}
324
+ makeLatest : ${{ !contains(github.ref, '-rc') }}
0 commit comments