Skip to content

Commit a28f8fa

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

1 file changed

Lines changed: 165 additions & 93 deletions

File tree

.github/workflows/CI.yml

Lines changed: 165 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,159 +2,231 @@ 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+
# NOTE: On Linux we need to manually export LD_LIBRARY_PATH
43+
- name: Set up Python
44+
run: |
45+
uv python install --default
46+
LIBDIR=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
47+
echo "LD_LIBRARY_PATH=${LIBDIR}:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
2348
24-
- name: Install Rust toolchain
25-
uses: dtolnay/rust-toolchain@stable
49+
- name: Run Rust tests
50+
run: |
51+
cargo run --release
52+
cargo clean
53+
54+
- name: Build wheels
55+
uses: PyO3/maturin-action@v1
2656
with:
27-
targets: x86_64-pc-windows-msvc
57+
target: ${{ matrix.target }}
58+
args: --release --out dist --find-interpreter
59+
manylinux: auto
60+
61+
- name: Run Python tests
62+
run: uv run pytest
2863

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

38-
- name: Test
39-
run: |
40-
pip install -r tests/requirements.txt
41-
python tests/example.py
42-
python tests/invalid.py
43-
44112
- name: Upload wheels
45113
uses: actions/upload-artifact@v4
46114
with:
47-
name: wheels-windows
115+
name: wheels-windows-x64
48116
path: dist
49117

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

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

98-
linux:
172+
sdist:
99173
# Skip building pull requests from the same repository
100174
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'
175+
runs-on: ubuntu-latest
106176
steps:
107-
- name: Checkout
108-
uses: actions/checkout@v4
177+
- uses: actions/checkout@v5
109178
with:
110179
submodules: 'true'
111-
112-
- name: Build
180+
181+
- name: Update pyproject.toml version
182+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
113183
shell: bash
114184
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
185+
# Extract version from tag (strip 'v' prefix if present)
186+
VERSION=${GITHUB_REF#refs/tags/}
187+
VERSION=${VERSION#v}
188+
echo "Extracted version: $VERSION"
189+
190+
# Update version in pyproject.toml (works on both GNU and BSD sed)
191+
sed -i.bak "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
192+
rm pyproject.toml.bak
193+
194+
- name: Build sdist
195+
uses: PyO3/maturin-action@v1
196+
with:
197+
command: sdist
198+
args: --out dist
199+
200+
- name: Upload sdist
132201
uses: actions/upload-artifact@v4
133202
with:
134-
name: wheels-linux
203+
name: wheels-sdist
135204
path: dist
136205

137206
release:
138207
if: ${{ startsWith(github.ref, 'refs/tags/') }}
139-
runs-on: ubuntu-24.04
140-
needs: [windows, macos, linux]
208+
runs-on: ubuntu-latest
209+
needs: [linux, windows, macos, sdist]
141210
permissions:
142211
contents: write
143212
discussions: write
144213
id-token: write
145214
steps:
146215
- name: Download wheels
147-
uses: actions/download-artifact@v4
216+
uses: actions/download-artifact@v5
148217
with:
149218
pattern: wheels-*
150219
merge-multiple: true
151220
path: dist
152221

153222
- name: Publish to PyPI
154-
uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.13
223+
uses: PyO3/maturin-action@v1
224+
with:
225+
command: upload
226+
args: --non-interactive --skip-existing dist/*
155227

156228
- name: Release
157-
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9
229+
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
158230
with:
159231
generate_release_notes: true
160232
files: dist/*

0 commit comments

Comments
 (0)