Skip to content

Commit 718adb0

Browse files
committed
New GitHub Actions with maturin/uv
1 parent 1dd765f commit 718adb0

File tree

1 file changed

+162
-93
lines changed

1 file changed

+162
-93
lines changed

.github/workflows/CI.yml

Lines changed: 162 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,159 +2,228 @@ name: CI
22

33
on: [push, pull_request]
44

5+
# Automatically cancel previous runs of this workflow on the same branch
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
510
jobs:
6-
windows:
11+
linux:
712
# Skip building pull requests from the same repository
813
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'
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
target: [x86_64, aarch64]
18+
fail-fast: false
1319
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
20+
- uses: actions/checkout@v5
1621
with:
1722
submodules: 'true'
18-
19-
- name: Python environment
20-
uses: actions/setup-python@v5
23+
24+
- name: Update pyproject.toml version
25+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
26+
shell: bash
27+
run: |
28+
# Extract version from tag (strip 'v' prefix if present)
29+
VERSION=${GITHUB_REF#refs/tags/}
30+
VERSION=${VERSION#v}
31+
echo "Extracted version: $VERSION"
32+
33+
# Update version in pyproject.toml (works on both GNU and BSD sed)
34+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
35+
rm pyproject.toml.bak
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v6
2139
with:
22-
python-version: '3.12'
40+
version: "0.9.3"
41+
42+
- name: Set up Python
43+
run: uv python install --default
44+
45+
- name: Run Rust tests
46+
run: |
47+
export LD_LIBRARY_PATH=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
48+
cargo run --release
2349
24-
- name: Install Rust toolchain
25-
uses: dtolnay/rust-toolchain@stable
50+
- name: Build wheels
51+
uses: PyO3/maturin-action@v1
2652
with:
27-
targets: x86_64-pc-windows-msvc
53+
target: ${{ matrix.target }}
54+
args: --release --out dist --find-interpreter
55+
sccache: 'true'
56+
manylinux: auto
2857

29-
- name: Build
58+
- name: Run Python tests
59+
run: uv run pytest
60+
61+
- name: Upload wheels
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: wheels-linux-${{ matrix.target }}
65+
path: dist
66+
67+
windows:
68+
# Skip building pull requests from the same repository
69+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
70+
runs-on: windows-latest
71+
steps:
72+
- uses: actions/checkout@v5
73+
with:
74+
submodules: 'true'
75+
76+
- name: Update pyproject.toml version
77+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
3078
shell: bash
3179
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"
80+
# Extract version from tag (strip 'v' prefix if present)
81+
VERSION=${GITHUB_REF#refs/tags/}
82+
VERSION=${VERSION#v}
83+
echo "Extracted version: $VERSION"
84+
85+
# Update version in pyproject.toml (works on both GNU and BSD sed)
86+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
87+
rm pyproject.toml.bak
88+
89+
- name: Install uv
90+
uses: astral-sh/setup-uv@v7
91+
with:
92+
version: "0.9.3"
93+
94+
- name: Set up Python
95+
run: uv python install --default
96+
97+
- name: Run Rust tests
98+
run: cargo run --release
99+
100+
- name: Build wheels
101+
uses: PyO3/maturin-action@v1
102+
with:
103+
target: x64
104+
args: --release --out dist --find-interpreter
105+
106+
- name: Run Python tests
107+
run: uv run pytest
37108

38-
- name: Test
39-
run: |
40-
pip install -r tests/requirements.txt
41-
python tests/example.py
42-
python tests/invalid.py
43-
44109
- name: Upload wheels
45110
uses: actions/upload-artifact@v4
46111
with:
47-
name: wheels-windows
112+
name: wheels-windows-x64
48113
path: dist
49114

50115
macos:
51116
# Skip building pull requests from the same repository
52117
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
53118
runs-on: macos-latest
54-
env:
55-
# Disable output buffering in an attempt to get readable errors
56-
PYTHONUNBUFFERED: '1'
119+
strategy:
120+
matrix:
121+
target: [x86_64, aarch64]
122+
fail-fast: false
57123
steps:
58-
- name: Checkout
59-
uses: actions/checkout@v4
124+
- uses: actions/checkout@v5
60125
with:
61126
submodules: 'true'
62-
63-
- name: Python environment
64-
uses: actions/setup-python@v5
65-
with:
66-
python-version: '3.12'
67127

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
128+
- name: Update pyproject.toml version
129+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
74130
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
87131
run: |
88-
pip install -r tests/requirements.txt
89-
python tests/example.py
90-
python tests/invalid.py
91-
132+
# Extract version from tag (strip 'v' prefix if present)
133+
VERSION=${GITHUB_REF#refs/tags/}
134+
VERSION=${VERSION#v}
135+
echo "Extracted version: $VERSION"
136+
137+
# Update version in pyproject.toml (works on both GNU and BSD sed)
138+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
139+
rm pyproject.toml.bak
140+
141+
- name: Install uv
142+
uses: astral-sh/setup-uv@v7
143+
with:
144+
version: "0.9.3"
145+
146+
- name: Set up Python
147+
run: uv python install --default
148+
149+
- name: Run Rust tests
150+
if: matrix.target == 'aarch64'
151+
run: cargo run --release
152+
153+
- name: Build wheels
154+
uses: PyO3/maturin-action@v1
155+
with:
156+
target: ${{ matrix.target }}
157+
args: --release --out dist --find-interpreter
158+
159+
- name: Run Python tests
160+
if: matrix.target == 'aarch64'
161+
run: uv run pytest
162+
92163
- name: Upload wheels
93164
uses: actions/upload-artifact@v4
94165
with:
95-
name: wheels-macos
166+
name: wheels-macos-${{ matrix.target }}
96167
path: dist
97168

98-
linux:
169+
sdist:
99170
# Skip building pull requests from the same repository
100171
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'
172+
runs-on: ubuntu-latest
106173
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v4
174+
- uses: actions/checkout@v5
109175
with:
110176
submodules: 'true'
111-
112-
- name: Build
177+
178+
- name: Update pyproject.toml version
179+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
113180
shell: bash
114181
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
182+
# Extract version from tag (strip 'v' prefix if present)
183+
VERSION=${GITHUB_REF#refs/tags/}
184+
VERSION=${VERSION#v}
185+
echo "Extracted version: $VERSION"
186+
187+
# Update version in pyproject.toml (works on both GNU and BSD sed)
188+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
189+
rm pyproject.toml.bak
190+
191+
- name: Build sdist
192+
uses: PyO3/maturin-action@v1
193+
with:
194+
command: sdist
195+
args: --out dist
196+
197+
- name: Upload sdist
132198
uses: actions/upload-artifact@v4
133199
with:
134-
name: wheels-linux
200+
name: wheels-sdist
135201
path: dist
136202

137203
release:
138204
if: ${{ startsWith(github.ref, 'refs/tags/') }}
139-
runs-on: ubuntu-24.04
140-
needs: [windows, macos, linux]
205+
runs-on: ubuntu-latest
206+
needs: [linux, windows, macos, sdist]
141207
permissions:
142208
contents: write
143209
discussions: write
144210
id-token: write
145211
steps:
146212
- name: Download wheels
147-
uses: actions/download-artifact@v4
213+
uses: actions/download-artifact@v5
148214
with:
149215
pattern: wheels-*
150216
merge-multiple: true
151217
path: dist
152218

153219
- name: Publish to PyPI
154-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.13
220+
uses: PyO3/maturin-action@v1
221+
with:
222+
command: upload
223+
args: --non-interactive --skip-existing dist/*
155224

156225
- name: Release
157-
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
226+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
158227
with:
159228
generate_release_notes: true
160229
files: dist/*

0 commit comments

Comments
 (0)