Skip to content

Commit 68caf9f

Browse files
committed
New GitHub Actions with maturin/uv
1 parent 1dd765f commit 68caf9f

File tree

1 file changed

+155
-93
lines changed

1 file changed

+155
-93
lines changed

.github/workflows/CI.yml

Lines changed: 155 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,158 +3,220 @@ name: CI
33
on: [push, pull_request]
44

55
jobs:
6-
windows:
6+
linux:
77
# Skip building pull requests from the same repository
88
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
9-
runs-on: windows-latest
10-
env:
11-
# Disable output buffering in an attempt to get readable errors
12-
PYTHONUNBUFFERED: '1'
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
target: [x86_64, aarch64]
13+
fail-fast: false
1314
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616
with:
1717
submodules: 'true'
18-
19-
- name: Python environment
20-
uses: actions/setup-python@v5
18+
19+
- name: Update pyproject.toml version
20+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
21+
shell: bash
22+
run: |
23+
# Extract version from tag (strip 'v' prefix if present)
24+
VERSION=${GITHUB_REF#refs/tags/}
25+
VERSION=${VERSION#v}
26+
echo "Extracted version: $VERSION"
27+
28+
# Update version in pyproject.toml (works on both GNU and BSD sed)
29+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
30+
rm pyproject.toml.bak
31+
32+
- name: Install uv
33+
uses: astral-sh/setup-uv@v6
34+
with:
35+
version: "0.9.3"
36+
37+
- name: Set up Python
38+
run: uv python install --default
39+
40+
- name: Run Rust tests
41+
run: cargo run --release
42+
43+
- name: Build wheels
44+
uses: PyO3/maturin-action@v1
45+
with:
46+
target: ${{ matrix.target }}
47+
args: --release --out dist --find-interpreter
48+
sccache: 'true'
49+
manylinux: auto
50+
51+
- name: Run Python tests
52+
run: uv run pytest
53+
54+
- name: Upload wheels
55+
uses: actions/upload-artifact@v4
2156
with:
22-
python-version: '3.12'
57+
name: wheels-linux-${{ matrix.target }}
58+
path: dist
2359

24-
- name: Install Rust toolchain
25-
uses: dtolnay/rust-toolchain@stable
60+
windows:
61+
# Skip building pull requests from the same repository
62+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
63+
runs-on: windows-latest
64+
steps:
65+
- uses: actions/checkout@v5
2666
with:
27-
targets: x86_64-pc-windows-msvc
67+
submodules: 'true'
2868

29-
- name: Build
69+
- name: Update pyproject.toml version
70+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
3071
shell: bash
3172
run: |
32-
pip install -r requirements.txt
33-
python setup.py sdist
34-
python setup.py bdist_wheel --py-limited-api=cp37
35-
pip install --force-reinstall dist/*.whl
36-
python -c "import icicle"
73+
# Extract version from tag (strip 'v' prefix if present)
74+
VERSION=${GITHUB_REF#refs/tags/}
75+
VERSION=${VERSION#v}
76+
echo "Extracted version: $VERSION"
77+
78+
# Update version in pyproject.toml (works on both GNU and BSD sed)
79+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
80+
rm pyproject.toml.bak
81+
82+
- name: Install uv
83+
uses: astral-sh/setup-uv@v7
84+
with:
85+
version: "0.9.3"
86+
87+
- name: Set up Python
88+
run: uv python install --default
89+
90+
- name: Run Rust tests
91+
run: cargo run --release
92+
93+
- name: Build wheels
94+
uses: PyO3/maturin-action@v1
95+
with:
96+
target: x64
97+
args: --release --out dist --find-interpreter
98+
99+
- name: Run Python tests
100+
run: uv run pytest
37101

38-
- name: Test
39-
run: |
40-
pip install -r tests/requirements.txt
41-
python tests/example.py
42-
python tests/invalid.py
43-
44102
- name: Upload wheels
45103
uses: actions/upload-artifact@v4
46104
with:
47-
name: wheels-windows
105+
name: wheels-windows-x64
48106
path: dist
49107

50108
macos:
51109
# Skip building pull requests from the same repository
52110
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
53111
runs-on: macos-latest
54-
env:
55-
# Disable output buffering in an attempt to get readable errors
56-
PYTHONUNBUFFERED: '1'
112+
strategy:
113+
matrix:
114+
target: [x86_64, aarch64]
115+
fail-fast: false
57116
steps:
58-
- name: Checkout
59-
uses: actions/checkout@v4
117+
- uses: actions/checkout@v5
60118
with:
61119
submodules: 'true'
62-
63-
- name: Python environment
64-
uses: actions/setup-python@v5
65-
with:
66-
python-version: '3.12'
67120

68-
- name: Install Rust toolchain
69-
uses: dtolnay/rust-toolchain@stable
70-
with:
71-
targets: aarch64-apple-darwin, x86_64-apple-darwin
72-
73-
- name: Build
121+
- name: Update pyproject.toml version
122+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
74123
shell: bash
75-
env:
76-
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
77-
MACOSX_DEPLOYMENT_TARGET: '10.9'
78-
ARCHFLAGS: -arch x86_64 -arch arm64
79-
PYO3_CROSS_LIB_DIR: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib
80-
run: |
81-
pip install -r requirements.txt
82-
python setup.py bdist_wheel --py-limited-api=cp37
83-
pip install --force-reinstall dist/*_universal2.whl
84-
python -c "import icicle"
85-
86-
- name: Test
87124
run: |
88-
pip install -r tests/requirements.txt
89-
python tests/example.py
90-
python tests/invalid.py
91-
125+
# Extract version from tag (strip 'v' prefix if present)
126+
VERSION=${GITHUB_REF#refs/tags/}
127+
VERSION=${VERSION#v}
128+
echo "Extracted version: $VERSION"
129+
130+
# Update version in pyproject.toml (works on both GNU and BSD sed)
131+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
132+
rm pyproject.toml.bak
133+
134+
- name: Install uv
135+
uses: astral-sh/setup-uv@v7
136+
with:
137+
version: "0.9.3"
138+
139+
- name: Set up Python
140+
run: uv python install --default
141+
142+
- name: Run Rust tests
143+
if: matrix.target == 'aarch64'
144+
run: cargo run --release
145+
146+
- name: Build wheels
147+
uses: PyO3/maturin-action@v1
148+
with:
149+
target: ${{ matrix.target }}
150+
args: --release --out dist --find-interpreter
151+
152+
- name: Run Python tests
153+
if: matrix.target == 'aarch64'
154+
run: uv run pytest
155+
92156
- name: Upload wheels
93157
uses: actions/upload-artifact@v4
94158
with:
95-
name: wheels-macos
159+
name: wheels-macos-${{ matrix.target }}
96160
path: dist
97161

98-
linux:
162+
sdist:
99163
# Skip building pull requests from the same repository
100164
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
101-
runs-on: ubuntu-24.04
102-
container: quay.io/pypa/manylinux_2_28_x86_64
103-
env:
104-
# Disable output buffering in an attempt to get readable errors
105-
PYTHONUNBUFFERED: '1'
165+
runs-on: ubuntu-latest
106166
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v4
167+
- uses: actions/checkout@v5
109168
with:
110169
submodules: 'true'
111-
112-
- name: Build
170+
171+
- name: Update pyproject.toml version
172+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
113173
shell: bash
114174
run: |
115-
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel
116-
export PATH="$PATH:$HOME/.cargo/bin"
117-
export PATH="/opt/python/cp38-cp38/bin:$PATH"
118-
pip install -r requirements.txt
119-
python setup.py bdist_wheel --py-limited-api=cp37 --plat-name manylinux_2_28_x86_64
120-
auditwheel show dist/*.whl
121-
pip install --force-reinstall dist/*.whl
122-
python -c "import icicle"
123-
124-
- name: Test
125-
run: |
126-
export PATH="/opt/python/cp38-cp38/bin:$PATH"
127-
pip install -r tests/requirements.txt
128-
python tests/example.py
129-
python tests/invalid.py
130-
131-
- name: Upload wheels
175+
# Extract version from tag (strip 'v' prefix if present)
176+
VERSION=${GITHUB_REF#refs/tags/}
177+
VERSION=${VERSION#v}
178+
echo "Extracted version: $VERSION"
179+
180+
# Update version in pyproject.toml (works on both GNU and BSD sed)
181+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
182+
rm pyproject.toml.bak
183+
184+
- name: Build sdist
185+
uses: PyO3/maturin-action@v1
186+
with:
187+
command: sdist
188+
args: --out dist
189+
190+
- name: Upload sdist
132191
uses: actions/upload-artifact@v4
133192
with:
134-
name: wheels-linux
193+
name: wheels-sdist
135194
path: dist
136195

137196
release:
138197
if: ${{ startsWith(github.ref, 'refs/tags/') }}
139-
runs-on: ubuntu-24.04
140-
needs: [windows, macos, linux]
198+
runs-on: ubuntu-latest
199+
needs: [linux, windows, macos, sdist]
141200
permissions:
142201
contents: write
143202
discussions: write
144203
id-token: write
145204
steps:
146205
- name: Download wheels
147-
uses: actions/download-artifact@v4
206+
uses: actions/download-artifact@v5
148207
with:
149208
pattern: wheels-*
150209
merge-multiple: true
151210
path: dist
152211

153212
- name: Publish to PyPI
154-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.13
213+
uses: PyO3/maturin-action@v1
214+
with:
215+
command: upload
216+
args: --non-interactive --skip-existing dist/*
155217

156218
- name: Release
157-
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
219+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
158220
with:
159221
generate_release_notes: true
160222
files: dist/*

0 commit comments

Comments
 (0)