forked from TryGhost/node-sqlite3
-
Notifications
You must be signed in to change notification settings - Fork 0
337 lines (304 loc) · 9.86 KB
/
ci.yml
File metadata and controls
337 lines (304 loc) · 9.86 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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- '*'
permissions:
contents: read
env:
FORCE_COLOR: 1
jobs:
verify-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Verify tag version matches package.json
run: |
# Check if we're running on a tag
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Extract tag name from GITHUB_REF (e.g., refs/tags/v6.0.2 -> v6.0.2)
TAG_NAME="${GITHUB_REF#refs/tags/}"
# Remove 'v' prefix if present to get the version number
TAG_VERSION="${TAG_NAME#v}"
# Get version from package.json
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "Tag version: $TAG_VERSION"
echo "Package version: $PACKAGE_VERSION"
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "ERROR: Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
echo "Please update package.json or create a new tag with the correct version"
echo "GitHub release will NOT be created."
exit 1
fi
echo "Version match verified!"
else
echo "Skipping version verification - not a tag event"
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Run lint
run: yarn lint
build:
permissions:
contents: write
needs: [verify-version, lint]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
host: x64
target: x64
platform: macos-x64
node: 20
- os: macos-latest
host: x64
target: x64
platform: macos-x64
node: 22
- os: macos-latest
host: x64
target: x64
platform: macos-x64
node: 24
- os: ubuntu-24.04
host: x64
target: x64
platform: linux-x64
node: 20
- os: ubuntu-24.04
host: x64
target: x64
platform: linux-x64
node: 22
- os: ubuntu-24.04
host: x64
target: x64
platform: linux-x64
node: 24
- os: windows-latest
host: x64
target: x64
platform: win32-x64
node: 20
- os: windows-latest
host: x64
target: x64
platform: win32-x64
node: 22
- os: windows-latest
host: x64
target: x64
platform: win32-x64
node: 24
- os: macos-latest
host: arm64
target: arm64
platform: macos-arm64
node: 20
- os: macos-latest
host: arm64
target: arm64
platform: macos-arm64
node: 22
- os: macos-latest
host: arm64
target: arm64
platform: macos-arm64
node: 24
- os: ubuntu-24.04-arm
host: arm64
target: arm64
platform: linux-arm64
node: 20
- os: ubuntu-24.04-arm
host: arm64
target: arm64
platform: linux-arm64
node: 22
- os: ubuntu-24.04-arm
host: arm64
target: arm64
platform: linux-arm64
node: 24
name: ${{ matrix.os }} (node=${{ matrix.node }}, host=${{ matrix.host }}, target=${{ matrix.target }})
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.host }}
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
if: contains(matrix.os, 'windows')
with:
msbuild-architecture: ${{ matrix.target }}
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Check Node compatibility
run: node tools/semver-check.js
- name: Add env vars
shell: bash
run: |
echo "V=1" >> $GITHUB_ENV
if [ "${{ matrix.target }}" = "x86" ]; then
echo "TARGET=ia32" >> $GITHUB_ENV
else
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV
fi
- name: Add Linux env vars
if: contains(matrix.os, 'ubuntu')
run: |
echo "CFLAGS=${CFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
echo "CXXFLAGS=${CXXFLAGS:-} -include ../src/gcc-preinclude.h" >> $GITHUB_ENV
- name: Build binaries
run: yarn prebuild
- name: Print binary info
if: contains(matrix.os, 'ubuntu')
run: |
BIN=$(find prebuilds -name "*.node" | head -1)
ldd "$BIN"
echo "---"
nm "$BIN" | grep "GLIBC_" | c++filt || true
echo "---"
file "$BIN"
- name: Run tests
run: yarn test
- name: Upload binaries to commit artifacts
uses: actions/upload-artifact@v7
if: matrix.node == 24
with:
name: prebuilt-binaries-${{ matrix.platform }}
path: prebuilds/*
retention-days: 7
- name: Upload binaries to GitHub Release
run: gh release upload ${GITHUB_REF#refs/tags/} prebuilds/* --clobber
if: matrix.node == 24 && startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
build-musl:
permissions:
contents: write
needs: [verify-version]
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/')
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04-arm
platform: linux/arm64
arch: arm64
- runner: ubuntu-24.04
platform: linux/amd64
arch: amd64
runs-on: ${{ matrix.runner }}
name: musl ${{ matrix.arch }}
steps:
- uses: actions/checkout@v6
- name: Build binaries and test
run: |
docker build \
--file ./tools/BinaryBuilder.Dockerfile \
--tag sqlite-builder \
--no-cache \
--build-arg VARIANT=alpine3.20 \
--build-arg NODE_VERSION=24 \
.
CONTAINER_ID=$(docker create -it sqlite-builder)
docker cp $CONTAINER_ID:/usr/src/build/prebuilds/ ./prebuilds
- name: Upload binaries to commit artifacts
uses: actions/upload-artifact@v7
with:
name: prebuilt-binaries-musl-${{ matrix.arch }}
path: prebuilds/*
retention-days: 7
- name: Upload binaries to GitHub Release
run: |
gh release upload ${GITHUB_REF#refs/tags/} prebuilds/* --clobber
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
package:
needs: [build]
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request') || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Download all prebuilt binary artifacts
uses: actions/download-artifact@v5
with:
path: prebuilds-artifacts
merge-multiple: true
- name: Merge prebuilds into package
run: |
mkdir -p prebuilds
# Each artifact may contain platform-specific subdirs
# Copy all prebuilds from artifacts into prebuilds/
cp -r prebuilds-artifacts/*/ prebuilds/ 2>/dev/null || true
# Also handle flat structure (files directly in artifact root)
cp -r prebuilds-artifacts/ prebuilds/ 2>/dev/null || true
# Verify the prebuilds are present
find prebuilds -name '*.node' -type f
- name: Create npm tarball
run: |
npm pack
echo "npm tarball created:"
ls -la *.tgz
- name: Upload npm tarball as commit artifact
uses: actions/upload-artifact@v7
with:
name: npm-package-tarball
path: '*.tgz'
retention-days: 7
test-package:
needs: [package]
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request') || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/'))
uses: ./.github/workflows/test-npm-package.yml
with:
target_run_id: ${{ github.run_id }}
node_version: '22'
publish-npm:
needs: [build, build-musl]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Install dependencies
run: yarn install --frozen-lockfile --ignore-scripts
- name: Download all prebuilt binary artifacts
uses: actions/download-artifact@v5
with:
path: prebuilds-artifacts
merge-multiple: true
- name: Merge prebuilds into package
run: |
mkdir -p prebuilds
cp -r prebuilds-artifacts/*/ prebuilds/ 2>/dev/null || true
cp -r prebuilds-artifacts/ prebuilds/ 2>/dev/null || true
find prebuilds -name '*.node' -type f
- name: Publish to npm
run: npm publish