Skip to content

Commit 263e93d

Browse files
committed
[Github Actions] Linux ARM64 build/release workflow
1 parent 20224e3 commit 263e93d

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

.github/workflows/linux-arm64.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
name: Linux ARM64 build/release workflow
3+
on:
4+
push:
5+
pull_request:
6+
release:
7+
types: [published]
8+
branches: [master]
9+
jobs:
10+
build-v8:
11+
# If Google V8 is in the workflow cache, don't build it.
12+
# Cloning the repository is still necessary in any case
13+
# to calculate the hash for the cache key
14+
name: Build Google V8
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ubuntu-22.04-arm64]
19+
outputs:
20+
v8-hash: ${{ steps.build-v8.outputs.v8-hash }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Clone Google V8
25+
run: |
26+
python -m pip install wheel
27+
echo "::group::Clone Google V8"
28+
python setup.py checkout_v8
29+
echo "::endgroup::"
30+
- name: Restore Google V8 from cache
31+
id: restore-v8
32+
uses: actions/cache/restore@main
33+
with:
34+
path: |
35+
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
36+
v8/out.gn/x64.release.sample/icudtl.dat
37+
v8/include
38+
key: linux-build-v8-${{ hashFiles('v8/src/**') }}
39+
- name: Build Google V8
40+
id: build-v8
41+
if: ${{ steps.restore-v8.outputs.cache-hit != 'true' }}
42+
continue-on-error: false
43+
run: |
44+
echo "v8-hash=${{ hashFiles('v8/src/**') }}" >> "$GITHUB_OUTPUT"
45+
python -m pip install wheel
46+
echo "::group::v8"
47+
python setup.py v8
48+
echo "::endgroup::"
49+
- name: Save Google V8 to cache
50+
uses: actions/cache/save@main
51+
if: ${{ steps.restore-v8.outputs.cache-hit != 'true' }}
52+
with:
53+
# Save compiled binary and header files. This will save an
54+
# additional clone of Google V8 for the linker
55+
path: |
56+
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
57+
v8/out.gn/x64.release.sample/icudtl.dat
58+
v8/include
59+
key: linux-build-v8-${{ hashFiles('v8/src/**') }}
60+
build:
61+
name: Build Linux ARM64 wheel (Python ${{ matrix.python-version }})
62+
needs: build-v8
63+
runs-on: ${{ matrix.os }}
64+
env:
65+
DIST_NAME: stpyv8-linux-py${{ matrix.python-version }}
66+
STPYV8_BOOST_PYTHON: boost_python${{ matrix.python-version }}
67+
strategy:
68+
matrix:
69+
os: [ubuntu-22.04-arm64]
70+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
71+
boost-version: [1.90.0]
72+
boost-version-snake: ['1_90_0']
73+
env:
74+
ARCH: arm64
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
- name: Set up Python
79+
uses: actions/setup-python@v5
80+
with:
81+
python-version: ${{ matrix.python-version }}
82+
- name: Download Boost
83+
id: download-boost
84+
uses: suisei-cn/actions-download-file@v1.6.0
85+
with:
86+
url: https://archives.boost.io/release/${{ matrix.boost-version }}/source/boost_${{matrix.boost-version-snake }}.zip
87+
- name: Install Boost
88+
id: install-boost
89+
run: |
90+
unzip -q ${{ steps.download-boost.outputs.filename }}
91+
cd boost_${{ matrix.boost-version-snake }}
92+
./bootstrap.sh
93+
sudo ./b2 install -j 8 --with-system --with-python --with-filesystem --with-iostreams --with-date_time --with-thread
94+
- name: Restore Google V8 from cache
95+
id: restore-v8
96+
uses: actions/cache/restore@main
97+
with:
98+
path: |
99+
v8/out.gn/x64.release.sample/obj/libv8_monolith.a
100+
v8/out.gn/x64.release.sample/icudtl.dat
101+
v8/include
102+
key: linux-build-v8-${{ needs.build-v8.outputs.v8-hash }}
103+
- name: Install dependencies
104+
run: |
105+
pip install --upgrade pip setuptools wheel auditwheel patchelf pytest pytest-order
106+
- name: Build wheel
107+
run: |
108+
python setup.py sdist bdist_wheel --skip-build-v8 -d stpyv8-linux-wheelhouse-${{ matrix.python-version }}
109+
env:
110+
INCLUDE: ${{ env.INCLUDE }};${{ steps.install-python.outputs.python-path
111+
}}include
112+
V8_DEPS_LINUX: 0
113+
LDFLAGS: -L/usr/lib -L/usr/lib/x86_64-linux-gnu
114+
- name: Repair wheel
115+
run: |
116+
auditwheel repair --plat manylinux_2_35_x86_64 -w stpyv8-linux-${{ matrix.python-version }} stpyv8-linux-wheelhouse-${{ matrix.python-version }}/*.whl
117+
- name: Install wheel
118+
run: |
119+
python -m pip install stpyv8-linux-${{ matrix.python-version }}/*.whl
120+
- name: Test wheel
121+
run: |
122+
pytest -v
123+
- name: Upload wheel
124+
uses: actions/upload-artifact@v4
125+
with:
126+
name: stpyv8-linux-python${{ matrix.python-version }}
127+
path: stpyv8-linux-${{ matrix.python-version }}/*.whl
128+
- name: Release
129+
uses: softprops/action-gh-release@v2
130+
if: ${{ github.event_name == 'release' }}
131+
with:
132+
files: stpyv8-linux-${{ matrix.python-version }}/*.whl
133+
token: ${{ secrets.GITHUB_TOKEN }}
134+
pypi-publish:
135+
name: Upload release to PyPI
136+
if: ${{ github.event_name == 'release' }}
137+
needs: build
138+
runs-on: ubuntu-22.04-arm
139+
environment:
140+
name: pypi
141+
url: https://pypi.org/p/stpyv8
142+
permissions:
143+
id-token: write
144+
steps:
145+
- name: Download wheels
146+
uses: actions/download-artifact@v4
147+
with:
148+
path: stpyv8-linux-dist
149+
pattern: stpyv8-linux*
150+
merge-multiple: true
151+
- name: Publish wheels to PyPI
152+
uses: pypa/gh-action-pypi-publish@release/v1
153+
with:
154+
packages-dir: stpyv8-linux-dist

0 commit comments

Comments
 (0)