forked from microsoft/node-pty
-
Notifications
You must be signed in to change notification settings - Fork 15
433 lines (368 loc) · 15.4 KB
/
Prepare prebuild environment.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
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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
name: "Run prebuild's and Create GitHub and NPM release"
run-name: Package against ${{ github.ref_name }}
# Create branch for release
# update package.json for package version
on:
workflow_dispatch:
inputs:
Beta:
description: "Beta Release"
required: true
default: true
type: boolean
env:
oldNodeBuildTargets: -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 -t 17.0.1 -t 18.0.0
nodeBuildTargets: -t 19.0.0 -t 20.0.0 -t 21.0.0
oldElectronBuildTargets: -t 5.0.0 -t 6.0.0 -t 7.0.0 -t 8.0.0 -t 9.0.0 -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.2 -t 15.0.0 -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0
electronBuildTargets: -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0
winIA32nodeBuildTargets: -t 10.0.0 -t 11.0.0 -t 12.0.0 -t 13.0.0 -t 14.0.0 -t 15.0.0 -t 16.0.0 -t 17.0.1
winIA32electronBuildTargets: -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0
ReleasePrebuildCount: 392
ReleasePrebuildifyCount: 84
jobs:
Prepare_prebuild_environment:
name: Prepare prebuild environment ${{ github.ref_name }}
runs-on: ubuntu-latest
steps:
- name: Delete pr-* branches
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: "release-candidate"
- uses: actions/checkout@v4
- name: Create Branch
uses: peterjgrainger/action-create-branch@v2.2.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Fetch Adjust version script
if: ${{ inputs.Beta }}
run: wget https://raw.githubusercontent.com/homebridge/.github/latest/.github/npm-version-script.js
working-directory: .github
- if: ${{ inputs.Beta }}
run: npm install semver
- name: Adjust version
if: ${{ inputs.Beta }}
run: node .github/npm-version-script.js ${{ github.ref }} beta
- name: npm version (without git commit)
if: ${{ inputs.Beta }}
run: npm version pre --preid=beta --no-git-tag-version
- name: Allow prebuilds to be stored on github
run: sed -i.bak '/prebuilds/d' .gitignore
- name: Commit & Push changes
uses: actions-js/push@master
with:
author_name: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "release-candidate"
message: "Prepare prebuild environment ${{ github.ref_name }}"
prebuild:
name: ${{ matrix.name }} - Prebuild NPM and GitHub Release artifacts
needs: Prepare_prebuild_environment
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name:
[
darwin-x64,
darwin-arm64,
linux-arm,
linux-arm64,
linux-arm64-older,
linux-ia32,
linux-ia32-older,
linux-x64,
linux-x64-older,
linuxmusl-arm,
linuxmusl-arm64,
linuxmusl-x64,
win32-ia32,
win32-x64,
]
include:
- name: linuxmusl-x64
os: ubuntu-latest
BASE_IMAGE: library/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: x86_64
CMD: BuildAllCMD
COUNT: 35
NPMCOUNT: 12
- name: linuxmusl-arm
os: ubuntu-latest
BASE_IMAGE: arm32v6/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 35
NPMCOUNT: 12
- name: linuxmusl-arm64
os: ubuntu-latest
BASE_IMAGE: arm64v8/node:16-alpine
DOCKERFILE: Dockerfile.alpine
QEMU_ARCH: aarch64
CMD: BuildAllCMD
COUNT: 35
NPMCOUNT: 12
- name: linux-arm
os: ubuntu-latest
BASE_IMAGE: balenalib/raspberry-pi-debian:buster
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: arm
CMD: BuildAllCMD
COUNT: 34
NPMCOUNT: 12
# Builds for NodeJS 19+
- name: linux-x64
os: ubuntu-latest
BASE_IMAGE: library/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: x86_64
CMD: BuildNewCMD
COUNT: 11
NPMCOUNT: 3
- name: linux-ia32
os: ubuntu-latest
BASE_IMAGE: i386/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: i386
CMD: BuildNewCMD
COUNT: 11
NPMCOUNT: 3
- name: linux-arm64
os: ubuntu-latest
BASE_IMAGE: arm64v8/debian:buster-slim
DOCKERFILE: Dockerfile.debian
QEMU_ARCH: aarch64
CMD: BuildNewCMD
COUNT: 11
NPMCOUNT: 3
# Builds for NodeJS 18 or lower
- name: linux-x64-older
os: ubuntu-latest
BASE_IMAGE: library/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: x86_64
CMD: BuildOldCMD
COUNT: 24
NPMCOUNT: 9
- name: linux-ia32-older
os: ubuntu-latest
BASE_IMAGE: i386/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: i386
CMD: BuildOldCMD
COUNT: 24
NPMCOUNT: 9
- name: linux-arm64-older
os: ubuntu-latest
BASE_IMAGE: arm64v8/debian:9.6-slim
DOCKERFILE: Dockerfile.oldDebian
QEMU_ARCH: aarch64
CMD: BuildOldCMD
COUNT: 24
NPMCOUNT: 9
# Other OS's
- name: darwin-x64
os: macOS-latest
COUNT: 35
NPMCOUNT: 11
- name: darwin-arm64
os: [self-hosted, macOS, ARM64]
COUNT: 35
NPMCOUNT: 11
- name: win32-ia32
os: windows-2019
arch: ia32
COUNT: 31
NPMCOUNT: 0
- name: win32-x64
os: windows-2019
arch: x64
COUNT: 35
NPMCOUNT: 0
steps:
- uses: actions/checkout@v4
with:
ref: "release-candidate"
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: get-npm-version
if: runner.os == 'Linux'
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Linux - Setup Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get --yes --no-install-recommends install binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static:register --reset
# Hackery to setup builds
- name: Setup Build Commands
if: runner.os == 'Linux'
run: |
echo "BuildOldCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${oldNodeBuildTargets} && \
./.prebuild/build.sh .prebuild/electron.js ${oldElectronBuildTargets}\"" >> $GITHUB_ENV
echo "BuildNewCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${nodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${nodeBuildTargets}&& \
./.prebuild/build.sh .prebuild/electron.js ${electronBuildTargets}\"" >> $GITHUB_ENV
echo "BuildAllCMD=\"./.prebuild/build.sh .prebuild/prebuild.js ${oldNodeBuildTargets} ${nodeBuildTargets} && \
./.prebuild/build.sh .prebuild/prebuildify.js ${oldNodeBuildTargets} ${nodeBuildTargets} && \
./.prebuild/build.sh .prebuild/electron.js ${oldElectronBuildTargets} ${electronBuildTargets}\"" >> $GITHUB_ENV
echo "CMD=${{ matrix.CMD }}" >> $GITHUB_ENV
- name: Linux - Prep Build EXECCMD = ${{ env.CMD }}
if: runner.os == 'Linux'
run: |
echo "${{ env.CMD }}"
echo "EXECCMD=${!CMD}" >> $GITHUB_ENV
# Linux builds
- name: Linux - Build Docker Image ${{ matrix.DOCKERFILE }} - ${{ matrix.BASE_IMAGE }} - ${{ matrix.QEMU_ARCH }}
if: runner.os == 'Linux'
run: |
docker build -f .prebuild/${{ matrix.DOCKERFILE }} --build-arg BASE_IMAGE=${{ matrix.BASE_IMAGE }} --build-arg QEMU_ARCH=${{ matrix.QEMU_ARCH }} -t multiarch-build .
- name: Linux - Prebuild Binaries - ${{ env.EXECCMD }}
if: runner.os == 'Linux'
run: |
docker run --rm -v $(pwd):/node-pty multiarch-build sh -c ${{ env.EXECCMD }}
# Mac OS
- name: macOS - Prebuild Binaries
if: runner.os == 'macOS'
run: |
python3 -m pip install packaging setuptools
npm ci --ignore-scripts
env JOBS=max node .prebuild/prebuild.js ${oldNodeBuildTargets} ${nodeBuildTargets}
env JOBS=max node .prebuild/electron.js ${oldElectronBuildTargets} ${electronBuildTargets}
# buildify doesn't work on Mac due to missing spawn_helper
# env JOBS=max node .prebuild/buildify.js
# Windows
- name: Windows ia32 - Prebuild Binaries
if: ${{ (runner.os == 'Windows') && (matrix.arch == 'ia32') }}
shell: bash
run: |
npm ci --ignore-scripts
env JOBS=max node_modules/.bin/prebuild ${winIA32nodeBuildTargets} --include-regex "\.(node|exe|dll|pdb)" --arch ${{ matrix.arch }}
env JOBS=max node_modules/.bin/prebuild ${oldElectronBuildTargets} ${winIA32electronBuildTargets} --include-regex "\.(node|exe|dll|pdb)" -r electron -a ${{ matrix.arch }}
- name: Windows x64 - Prebuild Binaries
if: ${{ (runner.os == 'Windows') && (matrix.arch == 'x64') }}
shell: bash
run: |
npm ci --ignore-scripts
env JOBS=max node_modules/.bin/prebuild ${oldNodeBuildTargets} ${nodeBuildTargets} --include-regex "\.(node|exe|dll|pdb)" --arch ${{ matrix.arch }}
env JOBS=max node_modules/.bin/prebuild ${oldElectronBuildTargets} ${electronBuildTargets} --include-regex "\.(node|exe|dll|pdb)" -r electron --arch ${{ matrix.arch }}
# Start of Checks
- name: Check Release prebuilds exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/node-pty*tar.gz | wc -l)
echo "Release Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${{ matrix.COUNT }} ]; then echo "::warning::Release Prebuild count ${fileCount}, expected ${{ matrix.COUNT }}"; else echo "::notice::Release Prebuild count ${fileCount}, expected ${{ matrix.COUNT }}"; fi
- name: "Check file existence"
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "prebuilds/*/node*node"
- name: Check NPM prebuilds exist
if: steps.check_files.outputs.files_exists == 'true'
shell: bash
run: |
fileCount=$(ls prebuilds/*/node*node | wc -l)
echo "NPM Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${{ matrix.NPMCOUNT }} ]; then echo "::warning::Release NPM Prebuild count ${fileCount}, expected ${{ matrix.NPMCOUNT }}"; else echo "::notice::Release NPM Prebuild count ${fileCount}, expected ${{ matrix.NPMCOUNT }}"; fi
- if: runner.os == 'Linux'
run: sudo chown -R $USER:$USER .
- name: Commit & Push changes
uses: actions-js/push@be2c6e7c16dba301499992e84b3b32aaaa56507c
with:
author_name: ${{ github.actor }}
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "release-candidate"
message: "Prebuilds for ${{ steps.package-version.outputs.current-version}} - ${{ matrix.name }}"
pull: true
publish:
name: Publish GitHub and NPM Release
needs: prebuild
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: "release-candidate"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: lts/*
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: NPM build
run: |
npm ci --ignore-scripts
npm run build
- name: Check Release prebuilds exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/node-pty*tar.gz | wc -l)
echo "Release Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${ReleasePrebuildCount} ]; then echo "::error::Release Prebuild count ${fileCount}, expected ${ReleasePrebuildCount}"; exit 1; else echo "::notice::Release Prebuild count ${fileCount}, expected ${ReleasePrebuildCount}"; fi
- name: Check Release prebuildify`s exist
shell: bash
run: |
fileCount=$(ls prebuilds/*/node*node | wc -l)
echo "Release Prebuild count ${fileCount}"
if [ "$fileCount" -ne ${ReleasePrebuildifyCount} ]; then echo "::error::Release Prebuildify count ${fileCount}, expected ${ReleasePrebuildifyCount}"; exit 1; else echo "::notice::Release Prebuildify count ${fileCount}, expected ${ReleasePrebuildifyCount}"; fi
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.package-version.outputs.current-version}}
release_name: Release v${{ steps.package-version.outputs.current-version}}
body: |
Changes in this Release
- First Change
- Second Change
draft: false
prerelease: true
- uses: AButler/upload-release-assets@v2.0
name: Upload Prebuild Artifacts to ${{ steps.package-version.outputs.current-version}}
with:
files: "prebuilds/*/node-pty*tar.gz"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ steps.package-version.outputs.current-version}}
- name: NPM Pack Release
run: |
npm pack
- uses: AButler/upload-release-assets@v2.0
name: Upload NPM Release to ${{ steps.package-version.outputs.current-version}}
with:
files: "*node-pty-prebuilt-multiarch*.tgz"
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: v${{ steps.package-version.outputs.current-version}}
- name: "Check file existence"
id: check_files
uses: andstor/file-existence-action@v2
with:
files: "prebuilds/*/node-pty-prebuilt-multiarch-*-node-*-darwin-arm64.tar.gz"
- name: Check MacOS ARM prebuilds exist
if: steps.check_files.outputs.files_exists == 'false'
run: |
echo "Missing MacOS ARM prebuilds, please remove release Artifats, and reun"
exit 1
- name: npm publish beta
if: ${{ github.repository == 'homebridge/node-pty-prebuilt-multiarch' && inputs.Beta }}
run: npm publish --access public --tag=beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: npm publish production
if: ${{ github.repository == 'homebridge/node-pty-prebuilt-multiarch' && ! inputs.Beta }}
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}