Skip to content

Commit cab0246

Browse files
committed
Remove prebuild dependency
Every CI build task tagged with 'package' now populates and publishes the relevant npm/platform directory as an artefact. These are aggregated by a fan-in release task at the end to create a complete npm workspace zipfile. If the commit is tagged, a release is created and the npm workspace attached.
1 parent 5374b03 commit cab0246

File tree

6 files changed

+173
-181
lines changed

6 files changed

+173
-181
lines changed

.github/workflows/ci.yml

Lines changed: 114 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ on:
44
- pull_request
55
permissions: {}
66
jobs:
7-
github-runner:
7+
build-native:
88
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]' }}"
1111
runs-on: ${{ matrix.os }}
12-
container:
13-
image: ${{ matrix.container }}
14-
volumes:
15-
- /:/host
12+
container: ${{ matrix.container }}
1613
strategy:
1714
fail-fast: false
1815
matrix:
@@ -23,7 +20,7 @@ jobs:
2320
nodejs_version: "^18.17.0"
2421
nodejs_version_major: 18
2522
platform: linux-x64
26-
prebuild: true
23+
package: true
2724
- os: ubuntu-24.04
2825
container: rockylinux:8
2926
nodejs_arch: x64
@@ -40,7 +37,7 @@ jobs:
4037
container: node:18-alpine3.17
4138
nodejs_version_major: 18
4239
platform: linuxmusl-x64
43-
prebuild: true
40+
package: true
4441
- os: ubuntu-24.04
4542
container: node:20-alpine3.18
4643
nodejs_version_major: 20
@@ -55,28 +52,19 @@ jobs:
5552
nodejs_version: "^18.17.0"
5653
nodejs_version_major: 18
5754
platform: linux-arm64
58-
prebuild: true
55+
package: true
5956
- os: ubuntu-24.04-arm
6057
container: arm64v8/rockylinux:8
6158
nodejs_arch: arm64
6259
nodejs_version: "^20.3.0"
6360
nodejs_version_major: 20
6461
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
7462
- os: macos-13
7563
nodejs_arch: x64
7664
nodejs_version: "^18.17.0"
7765
nodejs_version_major: 18
7866
platform: darwin-x64
79-
prebuild: true
67+
package: true
8068
- os: macos-13
8169
nodejs_arch: x64
8270
nodejs_version: "^20.3.0"
@@ -92,7 +80,7 @@ jobs:
9280
nodejs_version: "^18.17.0"
9381
nodejs_version_major: 18
9482
platform: darwin-arm64
95-
prebuild: true
83+
package: true
9684
- os: macos-14
9785
nodejs_arch: arm64
9886
nodejs_version: "^20.3.0"
@@ -108,7 +96,7 @@ jobs:
10896
nodejs_version: "18.18.2" # pinned to avoid 18.19.0 and npm 10
10997
nodejs_version_major: 18
11098
platform: win32-ia32
111-
prebuild: true
99+
package: true
112100
- os: windows-2022
113101
nodejs_arch: x86
114102
nodejs_version: "^20.3.0"
@@ -124,7 +112,7 @@ jobs:
124112
nodejs_version: "^18.17.0"
125113
nodejs_version_major: 18
126114
platform: win32-x64
127-
prebuild: true
115+
package: true
128116
- os: windows-2022
129117
nodejs_arch: x64
130118
nodejs_version: "^20.3.0"
@@ -140,28 +128,18 @@ jobs:
140128
nodejs_version: "^20.3.0"
141129
nodejs_version_major: 20
142130
platform: win32-arm64
143-
prebuild: true
131+
package: true
144132
- os: windows-11-arm
145133
nodejs_arch: arm64
146134
nodejs_version: "^22.9.0"
147135
nodejs_version_major: 22
148136
platform: win32-arm64
149137
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
160138
- name: Dependencies (Rocky Linux glibc)
161139
if: contains(matrix.container, 'rockylinux')
162140
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
165143
- name: Dependencies (Linux musl)
166144
if: contains(matrix.container, 'alpine')
167145
run: apk add build-base git python3 font-noto --update-cache
@@ -176,31 +154,70 @@ jobs:
176154
with:
177155
node-version: ${{ matrix.nodejs_version }}
178156
architecture: ${{ matrix.nodejs_arch }}
179-
- name: Checkout
180-
uses: actions/checkout@v4
157+
- uses: actions/checkout@v4
181158
- name: Install
182159
run: npm install --build-from-source
183160
- name: Test
184161
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
196193
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:
201218
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]"
204221
runs-on: ubuntu-24.04
205222
strategy:
206223
fail-fast: false
@@ -233,8 +250,6 @@ jobs:
233250
with:
234251
arch: ${{ matrix.run_on_arch }}
235252
distro: ${{ matrix.distro }}
236-
env: |
237-
prebuild_upload: "${{ startsWith(github.ref, 'refs/tags/') && secrets.GITHUB_TOKEN || '' }}"
238253
run: |
239254
apt-get update
240255
apt-get install -y curl g++ git libatomic1 make python3 xz-utils
@@ -244,20 +259,20 @@ jobs:
244259
npm install --build-from-source
245260
npx mocha --no-config --spec=test/unit/io.js --timeout=30000
246261
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:
253269
permissions:
254-
contents: write
255-
name: wasm32 - prebuild
270+
contents: read
271+
name: "build-wasm32 [package]"
256272
runs-on: ubuntu-24.04
257273
container: "emscripten/emsdk:4.0.10"
258274
steps:
259-
- name: Checkout
260-
uses: actions/checkout@v4
275+
- uses: actions/checkout@v4
261276
- name: Dependencies
262277
run: apt-get update && apt-get install -y pkg-config
263278
- name: Dependencies (Node.js)
@@ -275,17 +290,35 @@ jobs:
275290
test "$EMSCRIPTEN_VERSION_LIBVIPS" = "$EMSCRIPTEN_VERSION_SHARP"
276291
- name: Test
277292
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') }}

.prebuildrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

npm/from-github-release.js

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)