forked from sqreen/PyMiniRacer
-
Notifications
You must be signed in to change notification settings - Fork 14
294 lines (249 loc) · 7.78 KB
/
Copy pathbuild.yml
File metadata and controls
294 lines (249 loc) · 7.78 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
name: pypi-build
on:
# For PRs:
pull_request: {}
# For releases:
push:
branches:
- 'release/*'
concurrency:
group: build-${{ github.head_ref }}
defaults:
run:
shell: bash
jobs:
sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: astral-sh/setup-uv@v7
- uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0
- name: Build
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*
if-no-files-found: error
build-dll:
name: Build dll for ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: win-x64_64
os: windows-2022
target_cpu: x64
- name: win-aarch64
os: windows-2022
target_cpu: arm64
- name: linux-x64_64
os: ubuntu-24.04
target_cpu: x64
- name: linux-aarch64
os: ubuntu-24.04
target_cpu: arm64
- name: macos-x64_64
os: macos-15-intel
target_cpu: x64
- name: macos-aarch64
os: macos-15
target_cpu: arm64
- name: linux-aarch64-musl-compat
os: ubuntu-24.04
target_cpu: arm64
steps:
- uses: extractions/setup-just@v3
- uses: astral-sh/setup-uv@v7
- uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0
- uses: actions/setup-python@v5
with:
# the v8 build still doesn't work with a system Python > 3.11:
python-version: '3.11'
- run: just git-config-global
- uses: maxim-lobanov/setup-xcode@v1
if: contains(matrix.config.os, 'macos')
with:
xcode-version: latest-stable
- name: Build dll with v8
run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}"
if: matrix.config.name != 'linux-aarch64-musl-compat'
- name: Build dll with v8
run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}" --aarch64-musl-compat
if: matrix.config.name == 'linux-aarch64-musl-compat'
- uses: actions/upload-artifact@v4
with:
name: dll-${{ matrix.config.name }}
path: _dll
if-no-files-found: error
build-wheel:
name: Build and test wheel for ${{ matrix.config.name }}
needs: build-dll
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- name: win-x64_64
os: windows-2022
- name: win-aarch64
os: windows-11-arm
- name: linux-x64_64
os: ubuntu-24.04
- name: linux-aarch64
os: ubuntu-24.04-arm
- name: macos-x64_64
os: macos-15-intel
- name: macos-aarch64
os: macos-15
steps:
- uses: extractions/setup-just@v3
if: matrix.config.os != 'windows-11-arm'
- run: choco install just # no Github cargo action for windows-11-arm yet; use choco:
if: matrix.config.os == 'windows-11-arm'
- uses: astral-sh/setup-uv@v7
- uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: dll-${{ matrix.config.name }}
path: src/py_mini_racer
- run: just build-wheel
if: matrix.config.os != 'windows-11-arm'
# By default, uv still uses the x86_64 python in emulation on Windows.
# https://github.com/astral-sh/uv/issues/12906
# Override this behavior to build an actual aarch64 wheel:
- run: UV_PYTHON=arm64 just build-wheel
if: matrix.config.os == 'windows-11-arm'
- name: Test wheel
if: matrix.config.os != 'windows-11-arm'
run: just test-matrix
# As above; uv on Windows aarch64 likes to do emulation by default
# (and uv has no 3.10 Python build):
- name: Test wheel
if: matrix.config.os == 'windows-11-arm'
run: |
uv run --python cpython-3.11-windows-aarch64-none pytest tests
uv run --python cpython-3.12-windows-aarch64-none pytest tests
uv run --python cpython-3.13-windows-aarch64-none pytest tests
uv run --python cpython-3.14-windows-aarch64-none pytest tests
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.config.name }}
path: dist/*
if-no-files-found: error
build-alpine-wheel:
name: Build wheel for ${{ matrix.config.name }}
needs: build-dll
runs-on: ${{ matrix.config.image }}
strategy:
fail-fast: false
matrix:
config:
- name: alpine-x64_64
image: ubuntu-22.04
dll: linux-x64_64
- name: alpine-aarch64
image: ubuntu-22.04-arm
dll: linux-aarch64-musl-compat
container:
image: alpine
options: --user root
# From https://github.com/actions/runner/issues/801?timeline_page=1
volumes:
- /opt:/opt:rw,rshared
- /opt:/__e/node20:ro,rshared
steps:
# From https://github.com/actions/runner/issues/801?timeline_page=1
- name: Allow Linux musl containers on ARM64 runners
shell: /bin/sh {0}
if: contains(matrix.config.image, 'arm')
run: |
sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release
apk add nodejs --update-cache
mkdir /opt/bin
ln -s /usr/bin/node /opt/bin/node
- name: Install deps
shell: /bin/sh {0}
run: |
apk update
apk add bash curl gcompat libgcc uv just
- uses: actions/checkout@v3
with:
# Fetch all tags
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: dll-${{ matrix.config.dll }}
path: src/py_mini_racer
- run: just build-wheel
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.config.name }}
path: dist/*
if-no-files-found: error
- name: Test wheel
run: |
# We have to use this twisted formulation of sync and then run, splitting
# up what uv normally does for us, because the LD_PRELOAD accidentally
# confuses uv into thinking we're on a glibc Linux and thus it rejects our
# musl wheel.
uv sync --python 3.10
uv sync --python 3.11
uv sync --python 3.12
uv sync --python 3.13
uv sync --python 3.14
LD_PRELOAD="/lib/libgcompat.so.0" just test-matrix --frozen
release:
name: Create GitHub release
if: startsWith(github.ref, 'refs/heads/release')
needs:
- build-wheel
- build-alpine-wheel
- sdist
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Compute release version
run: |
VERSION=${GITHUB_REF_NAME#release/}
echo Version: $VERSION
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Make release
uses: ncipollo/release-action@v1
with:
artifacts: "wheels/*,sdist/*"
commit: ${{ github.ref }}
tag: ${{ env.VERSION }}
publish:
name: Upload release to PyPI
if: startsWith(github.ref, 'refs/heads/release')
needs:
- release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mini-racer
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- uses: actions/download-artifact@v5
with:
path: artifacts
- name: List artifacts
run: find artifacts/
- name: Make dist directory
run: mkdir dist && cp artifacts/wheels-*/*.whl artifacts/sdist/* dist/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1