Skip to content

Commit 909c93c

Browse files
committed
Improve CD pipeline
1 parent 75b2b7d commit 909c93c

File tree

1 file changed

+110
-43
lines changed

1 file changed

+110
-43
lines changed

.github/workflows/python-bindings.yml

Lines changed: 110 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,72 +5,139 @@ on:
55

66
name: Publish Python bindings
77

8+
env:
9+
MIN_PYTHON_VERSION: 3.9
10+
811
jobs:
9-
build-wheels:
10-
runs-on: ${{ matrix.os }}
12+
macos-wheels:
13+
runs-on: macos-latest
1114
strategy:
15+
fail-fast: false
1216
matrix:
13-
include:
14-
- os: macos-latest
15-
python-arch: x64
16-
rust-target: x86_64
17-
- os: macos-latest
18-
python-arch: x64
19-
rust-target: universal2-apple-darwin
20-
- os: ubuntu-latest
21-
python-arch: x64
22-
rust-target: x86_64
23-
- os: ubuntu-latest
24-
python-arch: x64
25-
rust-target: i686
26-
skip-wheel-installation: true
27-
- os: windows-latest
28-
python-arch: x64
29-
rust-target: x64
30-
- os: windows-latest
31-
python-arch: x86
32-
rust-target: x86
17+
target: [x86_64, aarch64]
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ env.MIN_PYTHON_VERSION }}
23+
- name: Build wheels
24+
uses: PyO3/maturin-action@v1
25+
with:
26+
target: ${{ matrix.target }}
27+
args: --release --out dist
28+
sccache: 'true'
29+
- name: Test wheel installation
30+
if: matrix.target == 'x86_64'
31+
run: |
32+
pip install accesskit --no-index --find-links dist --force-reinstall
33+
python -c "import accesskit"
34+
- name: Upload wheels
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: wheels
38+
path: dist
3339

40+
unix-wheels:
41+
runs-on: ubuntu-latest
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
target: [x86_64, x86, aarch64]
3446
steps:
3547
- uses: actions/checkout@v3
36-
- uses: actions/setup-python@v4
48+
- uses: actions/setup-python@v5
3749
with:
38-
python-version: 3.7
39-
architecture: ${{ matrix.python-arch }}
40-
- uses: dtolnay/rust-toolchain@stable
41-
- name: Build wheel
50+
python-version: ${{ env.MIN_PYTHON_VERSION }}
51+
- name: Build wheels
4252
uses: PyO3/maturin-action@v1
4353
with:
44-
target: ${{ matrix.rust-target }}
54+
target: ${{ matrix.target }}
55+
args: --release --out dist
56+
sccache: 'true'
4557
manylinux: auto
46-
args: --release --out dist --sdist
4758
- name: Test wheel installation
48-
if: matrix.skip-wheel-installation != true
59+
if: matrix.target == 'x86_64'
60+
run: |
61+
pip install accesskit --no-index --find-links dist --force-reinstall
62+
python -c "import accesskit"
63+
- name: Upload wheels
64+
uses: actions/upload-artifact@v3
65+
with:
66+
name: wheels
67+
path: dist
68+
69+
windows-wheels:
70+
runs-on: windows-latest
71+
strategy:
72+
fail-fast: false
73+
matrix:
74+
target: [x64, x86]
75+
steps:
76+
- uses: actions/checkout@v3
77+
- uses: actions/setup-python@v5
78+
with:
79+
python-version: ${{ env.MIN_PYTHON_VERSION }}
80+
architecture: ${{ matrix.target }}
81+
- name: Build wheels
82+
uses: PyO3/maturin-action@v1
83+
with:
84+
target: ${{ matrix.target }}
85+
args: --release --out dist
86+
sccache: 'true'
87+
- name: Test wheel installation
4988
run: |
5089
pip install accesskit --no-index --find-links dist --force-reinstall
5190
python -c "import accesskit"
52-
- name: Upload wheel
91+
- name: Upload wheels
92+
uses: actions/upload-artifact@v3
93+
with:
94+
name: wheels
95+
path: dist
96+
97+
sdist:
98+
runs-on: ubuntu-latest
99+
steps:
100+
- uses: actions/checkout@v3
101+
- name: Build sdist
102+
uses: PyO3/maturin-action@v1
103+
with:
104+
command: sdist
105+
args: --out dist
106+
- name: Upload sdist
53107
uses: actions/upload-artifact@v3
54108
with:
55109
name: wheels
56110
path: dist
57111

58-
release:
59-
name: Release
112+
pypi-release:
113+
name: Publish to PyPI
114+
if: "startsWith(github.ref, 'refs/tags/')"
115+
needs: [macos-wheels, unix-wheels, windows-wheels, sdist]
60116
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/download-artifact@v3
119+
with:
120+
name: wheels
121+
- uses: PyO3/maturin-action@v1
122+
env:
123+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
124+
with:
125+
command: upload
126+
args: --non-interactive --skip-existing *
127+
128+
github-release:
129+
name: Add to GitHub release
61130
if: "startsWith(github.ref, 'refs/tags/')"
62-
needs: [build-wheels]
131+
needs: [macos-wheels, unix-wheels, windows-wheels, sdist]
132+
runs-on: ubuntu-latest
63133
steps:
64134
- uses: actions/download-artifact@v3
65135
with:
66136
name: wheels
67-
- uses: actions/setup-python@v4
137+
path: dist
138+
139+
- uses: AButler/[email protected]
68140
with:
69-
python-version: 3.9
70-
- name: Publish to PyPI
71-
env:
72-
TWINE_USERNAME: __token__
73-
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
74-
run: |
75-
pip install --upgrade twine
76-
twine upload --skip-existing *
141+
files: "dist/*"
142+
repo-token: ${{ secrets.GITHUB_TOKEN }}
143+
release-tag: ${{ github.ref_name }}

0 commit comments

Comments
 (0)