2020 - host : ubuntu-latest
2121 target : x86_64-unknown-linux-gnu
2222 build : npm run build:rust -- --target x86_64-unknown-linux-gnu
23+ - host : ubuntu-24.04-arm
24+ target : aarch64-unknown-linux-gnu
25+ build : npm run build:rust -- --target aarch64-unknown-linux-gnu
26+ - host : ubuntu-latest
27+ target : x86_64-unknown-linux-musl
28+ setup : |
29+ set -eux
30+ TOOLCHAIN_URL="https://github.com/troglobit/misc/releases/download/11-20211120/x86_64-linux-musl-cross.tgz"
31+ TOOLCHAIN_ROOT="$HOME/musl-cross"
32+ TOOLCHAIN_DIR="$TOOLCHAIN_ROOT/x86_64-linux-musl-cross"
33+
34+ if [ ! -d "$TOOLCHAIN_DIR" ]; then
35+ mkdir -p "$TOOLCHAIN_ROOT"
36+ curl -L "$TOOLCHAIN_URL" -o /tmp/x86_64-linux-musl-cross.tgz
37+ tar -xzf /tmp/x86_64-linux-musl-cross.tgz -C "$TOOLCHAIN_ROOT"
38+ fi
39+
40+ echo "$TOOLCHAIN_DIR/bin" >> "$GITHUB_PATH"
41+ build : CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++ AR_x86_64_unknown_linux_musl=x86_64-linux-musl-ar RANLIB_x86_64_unknown_linux_musl=x86_64-linux-musl-ranlib npm run build:rust -- --target x86_64-unknown-linux-musl
2342 - host : windows-latest
2443 target : x86_64-pc-windows-msvc
2544 build : npm run build:rust -- --target x86_64-pc-windows-msvc
4059 with :
4160 targets : ${{ matrix.settings.target }}
4261
62+ - name : Install target toolchain dependencies
63+ if : matrix.settings.setup != ''
64+ run : ${{ matrix.settings.setup }}
65+
4366 - name : Install dependencies
4467 run : npm install
4568
@@ -54,44 +77,132 @@ jobs:
5477 if-no-files-found : error
5578
5679 publish :
57- name : Publish to npm
80+ name : Publish platform package - ${{ matrix.settings.target }}
5881 runs-on : ubuntu-latest
5982 needs : build
6083 if : github.event_name == 'release'
6184 permissions :
6285 contents : read
6386 id-token : write
87+ strategy :
88+ fail-fast : false
89+ matrix :
90+ settings :
91+ - target : x86_64-apple-darwin
92+ - target : aarch64-apple-darwin
93+ - target : x86_64-unknown-linux-gnu
94+ - target : aarch64-unknown-linux-gnu
95+ - target : x86_64-unknown-linux-musl
96+ - target : x86_64-pc-windows-msvc
6497
6598 steps :
6699 - uses : actions/checkout@v4
67100
68101 - name : Setup Node.js
69102 uses : actions/setup-node@v4
70103 with :
71- node-version : 20
104+ node-version : 24
72105 registry-url : ' https://registry.npmjs.org'
73106
107+ - name : Determine npm dist-tag
108+ id : dist_tag
109+ shell : bash
110+ run : |
111+ if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
112+ echo "value=rc" >> "$GITHUB_OUTPUT"
113+ else
114+ echo "value=latest" >> "$GITHUB_OUTPUT"
115+ fi
116+
117+ - name : Determine publish version
118+ id : publish_version
119+ shell : bash
120+ run : |
121+ tag="${{ github.event.release.tag_name }}"
122+ version="${tag#v}"
123+
124+ if [[ -z "$version" ]]; then
125+ echo "Release tag produced an empty version" >&2
126+ exit 1
127+ fi
128+
129+ echo "value=$version" >> "$GITHUB_OUTPUT"
130+
74131 - name : Install dependencies
75132 run : npm ci
76133
77- - name : Download all artifacts
134+ - name : Download artifact
78135 uses : actions/download-artifact@v4
79136 with :
137+ name : bindings-${{ matrix.settings.target }}
80138 path : artifacts
81139
82- - name : Move artifacts to rust directory
140+ - name : Prepare scoped platform package
141+ shell : bash
142+ env :
143+ NODE_WREQ_PUBLISH_VERSION : ${{ steps.publish_version.outputs.value }}
144+ run : |
145+ BINARY_PATH="$(find artifacts -name '*.node' | head -n 1)"
146+ node ./scripts/prepare-platform-package.mjs \
147+ --target "${{ matrix.settings.target }}" \
148+ --binary "$BINARY_PATH" \
149+ --outDir ".release/${{ matrix.settings.target }}"
150+
151+ - name : Publish scoped platform package
152+ run : npm publish ".release/${{ matrix.settings.target }}" --access public --tag "${{ steps.dist_tag.outputs.value }}"
153+
154+ publish-main :
155+ name : Publish main package
156+ runs-on : ubuntu-latest
157+ needs : publish
158+ if : github.event_name == 'release'
159+ permissions :
160+ contents : read
161+ id-token : write
162+
163+ steps :
164+ - uses : actions/checkout@v4
165+
166+ - name : Setup Node.js
167+ uses : actions/setup-node@v4
168+ with :
169+ node-version : 24
170+ registry-url : ' https://registry.npmjs.org'
171+
172+ - name : Determine npm dist-tag
173+ id : dist_tag
83174 shell : bash
84175 run : |
85- mkdir -p rust
86- # Copy all .node files from artifacts to rust/
87- find artifacts -name "*.node" -exec cp {} rust/ \;
88- echo "Collected binaries:"
89- ls -la rust/*.node
176+ if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
177+ echo "value=rc" >> "$GITHUB_OUTPUT"
178+ else
179+ echo "value=latest" >> "$GITHUB_OUTPUT"
180+ fi
181+
182+ - name : Determine publish version
183+ id : publish_version
184+ shell : bash
185+ run : |
186+ tag="${{ github.event.release.tag_name }}"
187+ version="${tag#v}"
188+
189+ if [[ -z "$version" ]]; then
190+ echo "Release tag produced an empty version" >&2
191+ exit 1
192+ fi
193+
194+ echo "value=$version" >> "$GITHUB_OUTPUT"
195+
196+ - name : Install dependencies
197+ run : npm ci
90198
91199 - name : Build TypeScript
92200 run : npm run build:ts
93201
94- - name : Publish to npm
95- run : npm publish --provenance --access public
202+ - name : Prepare main npm package
96203 env :
97- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
204+ NODE_WREQ_PUBLISH_VERSION : ${{ steps.publish_version.outputs.value }}
205+ run : npm run prepare:publish:main -- .release/main-package
206+
207+ - name : Publish main package
208+ run : npm publish .release/main-package --access public --tag "${{ steps.dist_tag.outputs.value }}"
0 commit comments