forked from justinlatimer/node-midi
-
Notifications
You must be signed in to change notification settings - Fork 6
370 lines (319 loc) · 10.1 KB
/
node.yaml
File metadata and controls
370 lines (319 loc) · 10.1 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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
name: Build and publish
on:
push:
tags:
- v*
branches-ignore:
- 'release-please-*'
pull_request:
paths-ignore:
# ingore release-please prs
- CHANGELOG.md
- package.json
- .release-please-manifest.json
env:
NAPI_VERSION: 7
BINDING_NAME: midi
MACOSX_DEPLOYMENT_TARGET: '10.13'
permissions:
contents: read
jobs:
build-and-test:
name: Build ${{ matrix.docker-arch || matrix.arch }} on ${{ matrix.docker-image || matrix.container || matrix.os }} ${{ matrix.libc }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# windows
- os: windows-2022
arch: x64
is-native: true
- os: windows-2022
arch: ia32
is-native: false
- os: windows-2022
arch: arm64
is-native: false
node-version: 20.x # 18.x is missing the arm64 node.lib
# macos
- os: macos-latest
arch: arm64
is-native: true
- os: macos-latest
arch: x64
is-native: false
# linux
- os: ubuntu-latest
arch: x64
is-native: true
docker-arch: linux/amd64
docker-image: node:18-bullseye
# linux-libc
- os: ubuntu-24.04-arm
arch: arm64
is-native: false
docker-arch: linux/arm64
docker-image: node:18-bullseye
- os: ubuntu-24.04-arm
arch: arm
is-native: false
docker-arch: linux/arm/v7
docker-image: node:18-bullseye
# linux-musl
- os: ubuntu-latest
arch: x64
is-native: true
docker-arch: linux/amd64
docker-image: node:18-alpine
libc: musl
steps:
- uses: actions/checkout@v6
with:
submodules: 'recursive'
fetch-depth: 0
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version || '18.x' }}
- name: rebuild
if: ${{ !matrix.docker-arch }}
shell: bash
run: |
corepack enable
yarn
# if [ -n "${{ matrix.is-native }}" ]; then
# yarn test
# fi
yarn run rebuild --arch=${{ matrix.arch }}
yarn pkg-prebuilds-copy --baseDir build/Release --source $BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }}
env:
CI: true
npm_config_build_from_source: true
- name: Login to Docker Hub
uses: docker/login-action@v4
if: ${{ matrix.docker-arch && env.dockerhub_username != '' }}
env:
dockerhub_username: ${{ secrets.DOCKERHUB_USERNAME }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
if: matrix.docker-arch
- name: Pre-fetch image
if: matrix.docker-arch
run: docker pull ${{ matrix.docker-image }} --platform=${{ matrix.docker-arch }}
- name: rebuild (in docker)
uses: addnab/docker-run-action@v3
if: matrix.docker-arch
with:
image: ${{ matrix.docker-image }}
# shell: bash
options: --platform=${{ matrix.docker-arch }} -v ${{ github.workspace }}:/work -e CI=1 -e npm_config_build_from_source=1 -e NAPI_VERSION -e BINDING_NAME
run: |
if command -v apt-get &> /dev/null
then
# # rewrite sources to archive mirrors
# sed -i -E 's#https?://(deb|deb.debian).debian.org/debian#http://archive.debian.org/debian#g' /etc/apt/sources.list || true
# sed -i -E 's#https?://security.debian.org#http://archive.debian.org/debian-security#g' /etc/apt/sources.list || true
apt-get update
apt-get install -y libasound2-dev
elif command -v apk &> /dev/null
then
apk update
apk add python3 make g++ gcc alsa-lib-dev
fi
cd /work
corepack enable
yarn
# yarn test
yarn pkg-prebuilds-copy --baseDir build/Release --source $BINDING_NAME.node --name=$BINDING_NAME --strip --napi_version=$NAPI_VERSION --arch=${{ matrix.arch }} --libc=${{ matrix.libc }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ runner.os }}-${{ matrix.arch }}-${{ matrix.libc }}-prebuilds
path: prebuilds
retention-days: 1
test-nodejs:
name: Test Node.JS ${{matrix.version}} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version: [14, 18, 20, 22, 24]
os: [
# Ubuntu runners don't have alsa enabled
# ubuntu-latest, ubuntu-24.04-arm,
windows-latest,
windows-11-arm,
macos-latest,
]
exclude:
- os: ubuntu-24.04-arm
version: 14
- os: windows-11-arm
version: 14
- os: windows-11-arm
version: 16
- os: windows-11-arm
version: 18
- os: macos-latest
version: 14
steps:
- uses: actions/checkout@v6
with:
submodules: 'recursive'
fetch-depth: 0
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev
# Build with latest Node.js to have the latest build tools
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22.x
- name: Setup Environment
shell: bash
run: |
corepack enable
yarn install
yarn build
env:
npm_config_build_from_source: true
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.version}}
- name: Run tests
shell: bash
run: |
# Don't use yarn, because of possible node version incompatibilities
npm run test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: 'recursive'
fetch-depth: 0
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22.x
- name: Setup Environment
shell: bash
run: |
corepack enable
yarn install
env:
npm_config_build_from_source: true
- name: Run lint
shell: bash
run: |
yarn lint
bundle:
name: Bundle prebuilds
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
path: tmp
- name: Display structure of downloaded files
run: |
mkdir prebuilds
mv tmp/*/* prebuilds/
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: all-prebuilds
path: prebuilds
retention-days: 7
publish:
name: Publish to npm
needs: bundle
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
# only run for tags
if: contains(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name: Use Node.js 18.x
uses: actions/setup-node@v6
with:
node-version: 18.x
- name: Check release is desired
id: do-publish
run: |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
echo "No Token"
else
corepack enable
PUBLISHED_VERSION=$(yarn npm info --json . | jq -c '.version' -r)
THIS_VERSION=$(node -p "require('./package.json').version")
# Simple bash helper to comapre version numbers
verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
verlt() {
[ "$1" = "$2" ] && return 1 || verlte $1 $2
}
if verlt $PUBLISHED_VERSION $THIS_VERSION
then
echo "Publishing latest"
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "Publishing hotfix"
echo "tag=hotfix" >> $GITHUB_OUTPUT
fi
fi
- name: Install Linux dependencies
if: ${{ steps.do-publish.outputs.tag }}
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev
- name: Prepare build
if: ${{ steps.do-publish.outputs.tag }}
run: |
corepack enable
yarn install
env:
CI: true
- uses: actions/download-artifact@v8
with:
name: all-prebuilds
path: prebuilds
- name: Publish to NPM
if: ${{ steps.do-publish.outputs.tag }}
run: |
npm set "//registry.npmjs.org/:_authToken" "$NPM_AUTH_TOKEN"
npm publish --access=public --tag ${{ steps.do-publish.outputs.tag }} --provenance
NEW_VERSION=$(node -p "require('./package.json').version")
echo "**Published:** $NEW_VERSION" >> $GITHUB_STEP_SUMMARY
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
CI: true