Skip to content

Commit 50ed4c1

Browse files
authored
Workflow to build and release to pypi (#202)
* cfg: Workflow to build wheels * cfg: Only on new versions
1 parent b58ffb7 commit 50ed4c1

1 file changed

Lines changed: 132 additions & 0 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: Release Python
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
linux:
17+
runs-on: ${{ matrix.platform.runner }}
18+
strategy:
19+
matrix:
20+
platform:
21+
- runner: ubuntu-latest
22+
target: x86_64
23+
- runner: ubuntu-latest
24+
target: x86
25+
- runner: ubuntu-latest
26+
target: aarch64
27+
- runner: ubuntu-latest
28+
target: armv7
29+
# - runner: ubuntu-latest
30+
# target: s390x
31+
# - runner: ubuntu-latest
32+
# target: ppc64le
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.10'
38+
- name: Build wheels
39+
uses: PyO3/maturin-action@v1
40+
with:
41+
target: ${{ matrix.platform.target }}
42+
args: --release --out dist --find-interpreter
43+
sccache: 'true'
44+
manylinux: auto
45+
- name: Upload wheels
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: wheels-linux-${{ matrix.platform.target }}
49+
path: dist
50+
51+
windows:
52+
runs-on: ${{ matrix.platform.runner }}
53+
strategy:
54+
matrix:
55+
platform:
56+
- runner: windows-latest
57+
target: x64
58+
- runner: windows-latest
59+
target: x86
60+
steps:
61+
- uses: actions/checkout@v4
62+
- uses: actions/setup-python@v5
63+
with:
64+
python-version: '3.10'
65+
architecture: ${{ matrix.platform.target }}
66+
- name: Build wheels
67+
uses: PyO3/maturin-action@v1
68+
with:
69+
target: ${{ matrix.platform.target }}
70+
args: --release --out dist --find-interpreter
71+
sccache: 'true'
72+
- name: Upload wheels
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: wheels-windows-${{ matrix.platform.target }}
76+
path: dist
77+
78+
macos:
79+
runs-on: ${{ matrix.platform.runner }}
80+
strategy:
81+
matrix:
82+
platform:
83+
- runner: macos-latest
84+
target: x86_64
85+
- runner: macos-14
86+
target: aarch64
87+
steps:
88+
- uses: actions/checkout@v4
89+
- uses: actions/setup-python@v5
90+
with:
91+
python-version: '3.10'
92+
- name: Build wheels
93+
uses: PyO3/maturin-action@v1
94+
with:
95+
target: ${{ matrix.platform.target }}
96+
args: --release --out dist --find-interpreter
97+
sccache: 'true'
98+
- name: Upload wheels
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: wheels-macos-${{ matrix.platform.target }}
102+
path: dist
103+
104+
sdist:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v4
108+
- name: Build sdist
109+
uses: PyO3/maturin-action@v1
110+
with:
111+
command: sdist
112+
args: --out dist
113+
- name: Upload sdist
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: wheels-sdist
117+
path: dist
118+
119+
release:
120+
name: Release
121+
runs-on: ubuntu-latest
122+
if: "startsWith(github.ref, 'refs/tags/')"
123+
needs: [linux, windows, macos, sdist]
124+
steps:
125+
- uses: actions/download-artifact@v4
126+
- name: Publish to PyPI
127+
uses: PyO3/maturin-action@v1
128+
env:
129+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
130+
with:
131+
command: upload
132+
args: --non-interactive --skip-existing wheels-*/*

0 commit comments

Comments
 (0)