-
Notifications
You must be signed in to change notification settings - Fork 5
283 lines (257 loc) · 9.54 KB
/
release-node-bindings.yml
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: Node Napi Cross compile testing
env:
DEBUG: napi:*
APP_NAME: peerdas-kzg
MACOSX_DEPLOYMENT_TARGET: '10.13'
permissions:
contents: write
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
ref:
description: The reference (branch/tag/commit) to checkout
required: true
release-type:
type: choice
required: false
default: none
description: Indicates whether we want to make a release and if which one
options:
- pre-release # Release a pre-release version to npm
- release # release an official version to npm
- none # Make no release
jobs:
build:
strategy:
fail-fast: false
matrix:
settings:
# - host: macos-13
# target: x86_64-apple-darwin
# - host: macos-14
# target: aarch64-apple-darwin
# - host: ubuntu-latest
# target: x86_64-unknown-linux-gnu
# - host: ubuntu-latest
# target: aarch64-unknown-linux-gnu
# - host: ubuntu-latest
# target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: aarch64-pc-windows-msvc
name: Build - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.settings.target }}
# llvm-preview-tools are needed for xwin, because we are compiling assembly (blst)
# Alternatively, you can install llvm
- name: Install llvm-preview-tools
if: runner.os == 'Linux' && contains(matrix.settings.target, 'windows')
run: rustup component add llvm-tools-preview
- name: Install dependencies
run: yarn install
working-directory: bindings/node
- name: Setup Zig (Linux only)
uses: goto-bus-stop/setup-zig@v2
with:
version: 0.13.0
- name: Install cargo-zigbuild (Linux only)
if: runner.os == 'Linux'
run: cargo install cargo-zigbuild
- name: Install cargo-xwin (Windows on Linux only)
if: runner.os == 'Linux' && contains(matrix.settings.target, 'windows')
run: cargo install cargo-xwin
- name: Build (macOS)
if: runner.os == 'macOS'
run: |
rustup target add ${{ matrix.settings.target }}
yarn build --release --target ${{ matrix.settings.target }}
working-directory: bindings/node
- name: Build (Linux)
if: runner.os == 'Linux' && !contains(matrix.settings.target, 'windows')
run: yarn build --zig --release --target ${{ matrix.settings.target }}
working-directory: bindings/node
- name: Build (Windows on Linux)
if: runner.os == 'Linux' && contains(matrix.settings.target, 'windows')
run: yarn build --release --target ${{ matrix.settings.target }}
working-directory: bindings/node
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: bindings/node/${{ env.APP_NAME }}.*.node
if-no-files-found: error
test:
needs: build
strategy:
fail-fast: false
matrix:
settings:
- host: macos-13
target: x86_64-apple-darwin
- host: macos-14
target: aarch64-apple-darwin
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
- host: linux-arm64
target: aarch64-unknown-linux-gnu
- host: windows-latest
target: x86_64-pc-windows-msvc
- host: win-arm64
target: aarch64-pc-windows-msvc
node:
- '20'
name: Test - ${{ matrix.settings.target }} - node@${{ matrix.node }}
runs-on: ${{ matrix.settings.host }}
steps:
# Windows arm64 doesn't have git it seems or choco.
# We install choco and then git
- name: Install Chocolatey
if: matrix.settings.host == 'win-arm64'
shell: powershell
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
- name: Add Chocolatey to PATH
if: matrix.settings.host == 'win-arm64'
shell: powershell
run: |
$chocoPath = "C:\ProgramData\chocolatey\bin"
$env:Path = "$chocoPath;$env:Path"
echo "$chocoPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Verify Chocolatey installation
if: matrix.settings.host == 'win-arm64'
shell: powershell
run: choco --version
- name: Install Git using Chocolatey Action
if: matrix.settings.host == 'win-arm64'
uses: crazy-max/ghaction-chocolatey@v2
with:
args: install git -y
- name: Add Git to PATH and verify installation
if: matrix.settings.host == 'win-arm64'
shell: powershell
run: |
$gitPath = "C:\Program Files\Git\cmd"
$env:Path = "$gitPath;$env:Path"
echo "$gitPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
git --version
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install Yarn
if: matrix.settings.host == 'win-arm64'
run: |
npm install -g yarn
echo "$(npm config get prefix)/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Verify Yarn installation
if: matrix.settings.host == 'win-arm64'
run: |
yarn --version
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Install dependencies
run: yarn install
working-directory: bindings/node
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: bindings-${{ matrix.settings.target }}
path: bindings/node
- name: List files
run: Get-ChildItem -Force -Recurse | Select-Object Mode, LastWriteTime, Length, FullName
shell: powershell
# Native testing for macOS (both Intel and ARM)
- name: Test bindings (macOS)
if: startsWith(matrix.settings.host, 'macos')
run: yarn test
working-directory: bindings/node
# Native testing for x86_64 Linux
- name: Test bindings (Linux x86_64)
if: matrix.settings.target == 'x86_64-unknown-linux-gnu'
run: yarn test
working-directory: bindings/node
- name: Test bindings (Linux ARM64)
if: matrix.settings.target == 'aarch64-unknown-linux-gnu'
run: yarn test
working-directory: bindings/node
# Native testing for x86_64 Windows
- name: Test bindings (Windows x86_64)
if: matrix.settings.target == 'x86_64-pc-windows-msvc'
run: yarn test
working-directory: bindings/node
# Native testing for arm64 Windows
- name: Test bindings (Windows arm64)
if: matrix.settings.target == 'aarch64-pc-windows-msvc'
run: yarn test
working-directory: bindings/node
publish:
name: Publish
runs-on: ubuntu-latest
needs:
- test
defaults:
run:
working-directory: bindings/node
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: yarn install
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: bindings/node/artifacts
- name: Move artifacts
run: yarn artifacts
- name: Publish
if: ${{ inputs.release-type != 'none' }}
run: |
# TODO: We could remove the yarnpkg registry and set the npmregistry
# TODO: globally, by doing: yarn config set registry <registry-url>
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
echo "//registry.yarnpkg.com/:_authToken=$NPM_TOKEN" >> ~/.npmrc
if [ "${{inputs.release-type}}" = "release" ]; then
SHOULD_PUBLISH=true
elif [ "${{inputs.release-type}}" = "pre-release" ]; then
# Prepend the commit hash to the package.json files
# so we can publish a pre-release version
yarn prereleaseVersion
SHOULD_PUBLISH=true
else
echo "No release has been made"
SHOULD_PUBLISH=false
fi
if [ "$SHOULD_PUBLISH" = true ]; then
# Prepare and publish the platform specific packages
yarn prepareAndPublishAddons
# Publish the base package, setting provenance
# to true as it's recommended. The platform specific packages
# don't need to have it, TODO but we could edit them to pass provenance.
npm config set provenance true
npm publish --access public
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_RELEASE_TOKEN }}