Skip to content

Commit 51e3bba

Browse files
robertlong13tridge
authored andcommitted
.github: add wheels for other OS
1 parent 6fdf9e2 commit 51e3bba

File tree

1 file changed

+64
-13
lines changed

1 file changed

+64
-13
lines changed

.github/workflows/python-publish.yml

Lines changed: 64 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: Build and Optionally Publish
66
on:
77
push:
88
pull_request:
9+
workflow_dispatch:
910
release:
1011
types: [published]
1112

@@ -14,40 +15,90 @@ concurrency:
1415
cancel-in-progress: true
1516

1617
jobs:
17-
wheels:
18+
prepare:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
matrix: ${{ steps.set-matrix.outputs.matrix }}
22+
steps:
23+
# This allows us to save the more expensive full build for the main branch
24+
# and releases, while using a lighter build for PRs
25+
- name: Set build matrix
26+
id: set-matrix
27+
shell: python
28+
run: |
29+
import json
30+
import os
31+
32+
ref = os.environ.get("GITHUB_REF", "")
33+
event = os.environ.get("GITHUB_EVENT_NAME", "")
34+
35+
if ref in ("refs/heads/main", "refs/heads/master") or event in ("release", "workflow_dispatch"):
36+
machines = [
37+
("linux", "ubuntu-latest", "auto"),
38+
("linux-arm", "ubuntu-24.04-arm", "auto"),
39+
("macos", "macos-latest", "arm64 x86_64 universal2"),
40+
("windows", "windows-latest", "auto"),
41+
# ("windows-arm", "windows-11-arm", "auto"), # Can't do this one yet, as lxml doesn't have Windows ARM wheels, and the runner doesn't have libxml2 pre-installed
42+
]
43+
py_versions = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
44+
else:
45+
machines = [
46+
("linux", "ubuntu-latest", "native"),
47+
("windows", "windows-latest", "native"),
48+
]
49+
py_versions = ["3.8", "3.13"] # Chosing the two most likely to break in PRs
50+
51+
matrix = {"include": []}
52+
for (name, runner, cibw_archs) in machines:
53+
for py in py_versions:
54+
matrix["include"].append({
55+
"name": f"python{py}-{name}",
56+
"os": runner,
57+
"python_version": py,
58+
"cibw_build": f"cp{py.replace('.', '')}-*",
59+
"cibw_archs": cibw_archs,
60+
})
61+
62+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
63+
f.write(f"matrix={json.dumps(matrix)}\n")
64+
65+
build-wheels:
66+
needs: prepare
1867
strategy:
1968
fail-fast: false
20-
matrix:
21-
os: ["ubuntu-latest"]
22-
python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
23-
name: ${{ matrix.os }} ${{ matrix.python }}
69+
matrix: ${{ fromJson(needs.prepare.outputs.matrix) }}
70+
name: ${{ matrix.name }}
2471
runs-on: ${{ matrix.os }}
25-
72+
env:
73+
PYTHON_VERSION: ${{ matrix.python_version }}
2674
steps:
2775
- uses: actions/checkout@v2
28-
- name: Install mavlink messages
76+
- name: Install mavlink definitions
77+
shell: bash
2978
run: |
3079
git clone https://github.com/ArduPilot/mavlink.git
3180
ln -s $PWD/mavlink/message_definitions
3281
- name: Set CIBW_BUILD
33-
run: echo "CIBW_BUILD=cp${PYTHON/./}-*" >> $GITHUB_ENV
34-
env:
35-
PYTHON: ${{ matrix.python }}
82+
shell: bash
83+
run: echo "CIBW_BUILD=cp${PYTHON_VERSION/./}-*" >> $GITHUB_ENV
3684
- name: Build wheels
3785
uses: pypa/[email protected]
3886
env:
87+
PYMAVLINK_FAST_INDEX: "1"
88+
CIBW_BUILD: ${{ matrix.cibw_build }}
89+
CIBW_ARCHS: ${{ matrix.cibw_archs }}
3990
CIBW_BEFORE_BUILD_LINUX: >
4091
if [ "$(uname -m)" = "i686" ] && grep -q musl /lib/libc.musl-*; then
4192
apk add --no-cache libxml2-dev libxslt-dev;
4293
fi
4394
- name: Upload wheels
4495
uses: actions/upload-artifact@v4
4596
with:
46-
name: wheels-${{ matrix.os }}-cp${{ matrix.python }}
97+
name: ${{ matrix.name }}
4798
path: wheelhouse/*.whl
4899
if-no-files-found: error
49100

50-
sdist:
101+
build-sdist:
51102
runs-on: ubuntu-latest
52103
steps:
53104
- uses: actions/checkout@v2
@@ -75,7 +126,7 @@ jobs:
75126
if-no-files-found: error
76127

77128
publish:
78-
needs: [wheels, sdist]
129+
needs: [build-wheels, build-sdist]
79130
runs-on: ubuntu-latest
80131
steps:
81132
- name: Download all artifacts

0 commit comments

Comments
 (0)