-
Notifications
You must be signed in to change notification settings - Fork 7
148 lines (125 loc) · 4.09 KB
/
Copy pathprebuild.yml
File metadata and controls
148 lines (125 loc) · 4.09 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
name: Prebuild & Publish
on:
release:
types: [published]
jobs:
prebuild:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
arch: x64
- os: ubuntu-24.04-arm
arch: arm64
- os: macos-latest
arch: arm64
- os: windows-latest
arch: x64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install deps (macOS)
if: runner.os == 'macOS'
run: brew install re2 abseil mimalloc
- name: Install deps (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libre2-dev libabsl-dev
- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Setup vcpkg
if: runner.os == 'Windows'
run: |
C:\vcpkg\bootstrap-vcpkg.bat
shell: cmd
- name: Install deps (Windows)
if: runner.os == 'Windows'
run: |
C:\vcpkg\vcpkg install re2:x64-windows-static
C:\vcpkg\vcpkg install abseil:x64-windows-static
shell: cmd
- name: Set Toolchain and Triplet
if: runner.os == 'Windows'
run: |
echo "CMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "VCPKG_TARGET_TRIPLET=x64-windows-static" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install dependencies
run: npm install
- name: Prebuild
run: npm run prebuild
# `strip -Sx` rewrites the Mach-O and invalidates the ad-hoc signature
# the linker applied. arm64 macOS refuses to load unsigned code, so the
# binary must be re-signed and verified before it ships.
- name: Re-sign and verify macOS prebuild
if: runner.os == 'macOS'
run: |
for f in prebuilds/*/node-napi-v10.node; do
codesign --force --sign - "$f"
codesign --verify --verbose "$f"
done
- name: Upload prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuild-${{ matrix.os }}-${{ matrix.arch }}
path: prebuilds/
prebuild-musl:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- arch: x64
platform: linux/amd64
- arch: arm64
platform: linux/arm64
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
if: matrix.arch == 'arm64'
- name: Build in Alpine container
run: |
docker run --rm --platform ${{ matrix.platform }} \
-v ${{ github.workspace }}:/work -w /work \
node:22-alpine sh -c "
apk add --no-cache git python3 make g++ cmake re2-dev abseil-cpp-dev linux-headers &&
npm install &&
npx pkg-prebuilds-copy --baseDir build/Release --source ata.node --name=ata --strip --napi_version=10 --libc=musl
"
- name: Upload prebuilds
uses: actions/upload-artifact@v4
with:
name: prebuild-linux-musl-${{ matrix.arch }}
path: prebuilds/
publish:
needs: [prebuild, prebuild-musl]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: npm install --ignore-scripts
- name: Download all prebuilds
uses: actions/download-artifact@v4
with:
path: prebuilds/
pattern: prebuild-*
merge-multiple: true
- name: List prebuilds
run: |
echo "=== Prebuild contents ==="
find prebuilds -type f -name "*.node"
echo "=== Total size ==="
du -sh prebuilds/
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}