Skip to content

Commit 6ed2d37

Browse files
authored
update github workflow to recent
1 parent 54d8f36 commit 6ed2d37

File tree

1 file changed

+188
-104
lines changed

1 file changed

+188
-104
lines changed

.github/workflows/publish.yml

Lines changed: 188 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,242 @@
1-
name: Publish
1+
# Largely references https://github.com/pydantic/pydantic-core/blob/193f5d7a8627c988b1c7fab9a3712c779afbbe94/.github/workflows/ci.yml
2+
3+
name: CI
24

35
on:
46
push:
7+
branches:
8+
- main
9+
- next
510
tags:
611
- 'v[0-9]+.[0-9]+.[0-9]+'
12+
pull_request:
713
workflow_dispatch:
814

915
jobs:
10-
macos:
11-
runs-on: macos-latest
12-
strategy:
13-
matrix:
14-
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11']
16+
clippy:
17+
name: Clippy
18+
runs-on: ubuntu-latest
19+
1520
steps:
1621
- name: Checkout project
17-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
1823

19-
- name: Python setup
20-
uses: actions/setup-python@v4
21-
with:
22-
python-version: ${{ matrix.python_version }}
23-
architecture: x64
24-
25-
- name: Rust setup
26-
uses: actions-rs/toolchain@v1
27-
with:
28-
toolchain: stable
29-
profile: minimal
30-
default: true
24+
- name: Install stable toolchain
25+
uses: dtolnay/rust-toolchain@stable
3126

32-
- name: Build wheels - x86_64
33-
uses: PyO3/maturin-action@v1
34-
with:
35-
target: x86_64
36-
args: --release --out dist --sdist
27+
- name: Cache dependencies
28+
uses: Swatinem/rust-cache@v2
3729

38-
- name: Install built wheel - x86_64
39-
run: |
40-
pip install rina_pp_pyb --no-index --find-links dist --force-reinstall
41-
python -c "import rina_pp_pyb"
30+
- name: Run clippy
31+
run: cargo clippy --all-targets
4232

43-
- name: Build wheels - universal2
33+
build-sdist:
34+
name: Build sdist
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout project
39+
uses: actions/checkout@v4
40+
41+
- name: Build wheels
4442
uses: PyO3/maturin-action@v1
4543
with:
46-
args: --release --universal2 --out dist
47-
48-
- name: Install built wheel - universal2
49-
run: |
50-
pip install rina_pp_pyb --no-index --find-links dist --force-reinstall
51-
python -c "import rina_pp_pyb"
44+
command: sdist
45+
args: --out dist
46+
rust-toolchain: stable
5247

5348
- name: Upload wheels
54-
uses: actions/upload-artifact@v3
49+
uses: actions/upload-artifact@v4
5550
with:
56-
name: wheels
51+
name: pypi_files_sdist
5752
path: dist
5853

59-
windows:
60-
runs-on: windows-latest
54+
build:
55+
name: Build on ${{ matrix.os }} (${{ matrix.target }} - ${{ matrix.interpreter || 'all' }}${{ matrix.os == 'linux' && format(' - {0}', matrix.manylinux == 'auto' && 'manylinux' || matrix.manylinux) || '' }})
56+
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/next'
57+
6158
strategy:
59+
fail-fast: false
6260
matrix:
63-
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11']
64-
target: [x64, x86]
61+
os: [linux, macos, windows]
62+
target: [x86_64, aarch64]
63+
manylinux: [auto]
64+
include:
65+
# manylinux
66+
- os: linux
67+
manylinux: auto
68+
target: aarch64
69+
- os: linux
70+
manylinux: auto
71+
target: armv7
72+
interpreter: 3.8 3.9 3.10 3.11 3.12
73+
- os: linux
74+
manylinux: auto
75+
target: x86_64
76+
77+
# musllinux
78+
- os: linux
79+
manylinux: musllinux_1_1
80+
target: x86_64
81+
- os: linux
82+
manylinux: musllinux_1_1
83+
target: aarch64
84+
85+
# macos
86+
- os: macos
87+
target: x86_64
88+
- os: macos
89+
target: aarch64
90+
91+
# windows
92+
- os: windows
93+
target: x86_64
94+
- os: windows
95+
target: aarch64
96+
interpreter: 3.11 3.12
97+
98+
runs-on: ${{ (matrix.os == 'linux' && 'ubuntu') || matrix.os }}-latest
99+
65100
steps:
66101
- name: Checkout project
67-
uses: actions/checkout@v3
102+
uses: actions/checkout@v4
68103

69-
- name: Python setup
70-
uses: actions/setup-python@v4
104+
- name: Set up python
105+
uses: actions/setup-python@v5
71106
with:
72-
python-version: ${{ matrix.python_version }}
73-
architecture: ${{ matrix.target }}
107+
python-version: '3.11'
108+
architecture: x64
74109

75-
- name: Rust setup
76-
uses: actions-rs/toolchain@v1
77-
with:
78-
toolchain: stable
79-
profile: minimal
80-
default: true
110+
- run: pip install -U twine 'ruff==0.1.3' typing_extensions
81111

82112
- name: Build wheels
83113
uses: PyO3/maturin-action@v1
84114
with:
85115
target: ${{ matrix.target }}
86-
args: --release --out dist
116+
manylinux: ${{ matrix.manylinux }}
117+
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' }}
118+
rust-toolchain: 1.77.0
119+
docker-options: -e CI
120+
sccache: true
87121

88-
- name: Install built wheel
89-
run: |
90-
pip install rina_pp_pyb --no-index --find-links dist --force-reinstall
91-
python -c "import rina_pp_pyb"
122+
- run: twine check --strict dist/*
92123

93124
- name: Upload wheels
94-
uses: actions/upload-artifact@v3
125+
uses: actions/upload-artifact@v4
95126
with:
96-
name: wheels
127+
name: pypi_files_${{ matrix.os }}_${{ matrix.target }}_${{ matrix.interpreter || 'all' }}_${{ matrix.manylinux }}
97128
path: dist
98129

99-
linux:
100-
runs-on: ubuntu-20.04
130+
test-builds-arch:
131+
name: Test build on ${{ matrix.target }}-${{ matrix.distro }}
132+
needs: [build]
133+
runs-on: ubuntu-latest
134+
101135
strategy:
136+
fail-fast: false
102137
matrix:
103-
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11']
104-
target: [x86_64, i686]
138+
target: [aarch64, armv7]
139+
distro: ['ubuntu22.04']
140+
include:
141+
- target: aarch64
142+
distro: alpine_latest
143+
105144
steps:
106-
- name: Checkout project
107-
uses: actions/checkout@v3
108-
109-
- name: Python setup
110-
uses: actions/setup-python@v4
111-
with:
112-
python-version: ${{ matrix.python_version }}
113-
architecture: x64
114-
115-
- name: Build wheels
116-
uses: PyO3/maturin-action@v1
117-
with:
118-
target: ${{ matrix.target }}
119-
manylinux: auto
120-
args: --release --out dist -i ${{ matrix.python_version }}
121-
122-
- name: Install built wheel
123-
if: matrix.target == 'x86_64'
124-
run: |
125-
pip install rina_pp_pyb --no-index --find-links dist --force-reinstall
126-
python -c "import rina_pp_pyb"
127-
128-
- name: Upload wheels
129-
uses: actions/upload-artifact@v3
130-
with:
131-
name: wheels
132-
path: dist
145+
- name: Checkout project
146+
uses: actions/checkout@v4
147+
148+
- name: Get artifacts
149+
uses: actions/download-artifact@v4
150+
with:
151+
pattern: pypi_files_linux_*
152+
merge-multiple: true
153+
path: dist
154+
155+
- name: Install & test
156+
uses: uraimo/run-on-arch-action@v2.7.1
157+
with:
158+
arch: ${{ matrix.target }}
159+
distro: ${{ matrix.distro }}
160+
githubToken: ${{ github.token }}
161+
install: |
162+
set -x
163+
if command -v apt-get &> /dev/null; then
164+
echo "installing python & pip with apt-get..."
165+
apt-get update
166+
apt-get install -y --no-install-recommends python3 python3-pip python3-venv git
167+
else
168+
echo "installing python & pip with apk..."
169+
apk update
170+
apk add python3 py3-pip git
171+
fi
172+
run: |
173+
set -x
174+
# typing-extensions isn't automatically installed because of `--no-index --no-deps`
175+
python3 -m venv venv
176+
source venv/bin/activate
177+
python3 -m pip install -U pip typing-extensions
178+
python3 -m pip install rina_pp_pyb --no-index --no-deps --find-links dist --force-reinstall
179+
python3 -c "import rina_pp_pyb"
180+
181+
test-builds-os:
182+
name: Test build on ${{ matrix.os }}
183+
needs: [build]
133184

134-
release:
135-
name: Release
136-
runs-on: ubuntu-latest
137185
strategy:
186+
fail-fast: false
138187
matrix:
139-
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11']
140-
needs: [ macos, windows, linux ]
188+
os: [ubuntu, macos, windows]
189+
190+
runs-on: ${{ matrix.os }}-latest
141191
steps:
192+
- name: Checkout project
193+
uses: actions/checkout@v4
194+
195+
- name: Set up python
196+
uses: actions/setup-python@v5
197+
with:
198+
python-version: '3.11'
199+
142200
- name: Get artifacts
143-
uses: actions/download-artifact@v3
201+
uses: actions/download-artifact@v4
202+
with:
203+
pattern: pypi_files_*
204+
merge-multiple: true
205+
path: dist
206+
207+
- run: |
208+
pip install typing-extensions
209+
pip install rina_pp_pyb --no-index --no-deps --find-links dist --force-reinstall
210+
python -c "import rina_pp_pyb"
211+
212+
release:
213+
name: Release
214+
needs: [clippy, test-builds-arch, test-builds-os, build-sdist]
215+
if: success() && startsWith(github.ref, 'refs/tags/')
216+
runs-on: ubuntu-latest
217+
218+
steps:
219+
- name: Checkout project
220+
uses: actions/checkout@v4
221+
222+
- name: Set up python
223+
uses: actions/setup-python@v5
144224
with:
145-
name: wheels
225+
python-version: '3.10'
226+
227+
- run: pip install -U twine
146228

147-
- name: Python setup
148-
uses: actions/setup-python@v2
229+
- name: Get artifacts
230+
uses: actions/download-artifact@v4
149231
with:
150-
python-version: ${{ matrix.python_version }}
232+
pattern: pypi_files_*
233+
merge-multiple: true
234+
path: dist
235+
236+
- run: twine check --strict dist/*
151237

152-
- name: Publish to PyPi
238+
- name: Upload to PyPI
239+
run: twine upload dist/*
153240
env:
154241
TWINE_USERNAME: __token__
155242
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
156-
run: |
157-
pip install --upgrade twine
158-
twine upload --skip-existing *

0 commit comments

Comments
 (0)