Skip to content

Commit 3466994

Browse files
authored
🔧 (CI): Update maturin release CI workflow (#81)
1 parent b0fb0e1 commit 3466994

File tree

3 files changed

+94
-101
lines changed

3 files changed

+94
-101
lines changed

.github/workflows/release.yml

Lines changed: 86 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is autogenerated by maturin v1.2.3
1+
# This file is autogenerated by maturin v1.7.4
22
# To update, run
33
#
44
# maturin generate-ci github
@@ -9,7 +9,6 @@ on:
99
push:
1010
branches:
1111
- main
12-
- dev
1312
tags:
1413
- '*'
1514
pull_request:
@@ -22,137 +21,130 @@ permissions:
2221

2322
jobs:
2423
linux:
25-
runs-on: ubuntu-latest
26-
timeout-minutes: 60
24+
runs-on: ${{ matrix.platform.runner }}
2725
strategy:
2826
matrix:
29-
# todo: enable aarch64, armv7, s390x, ppc64le
30-
target: [auto]
31-
27+
platform:
28+
- runner: ubuntu-latest
29+
target: x86_64
30+
- runner: ubuntu-latest
31+
target: x86
32+
# - runner: ubuntu-latest
33+
# target: aarch64
34+
# - runner: ubuntu-latest
35+
# target: armv7
36+
# - runner: ubuntu-latest
37+
# target: s390x
38+
# - runner: ubuntu-latest
39+
# target: ppc64le
3240
steps:
3341
- uses: actions/checkout@v4
42+
- uses: actions/setup-python@v5
43+
with:
44+
python-version: 3.x
45+
- name: Setup QEMU
46+
if: ${{ matrix.platform.target != 'x86_64' && matrix.platform.target != 'x86' }}
47+
uses: docker/setup-qemu-action@v1
48+
- name: Build wheels
49+
uses: PyO3/maturin-action@v1
50+
with:
51+
target: ${{ matrix.platform.target }}
52+
args: --release --out dist --interpreter 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 --features vendored
53+
sccache: 'true'
54+
manylinux: auto
55+
- name: Upload wheels
56+
uses: actions/upload-artifact@v4
3457
with:
35-
submodules: recursive
58+
name: wheels-linux-${{ matrix.platform.target }}
59+
path: dist
3660

61+
musllinux:
62+
runs-on: ${{ matrix.platform.runner }}
63+
strategy:
64+
matrix:
65+
platform:
66+
- runner: ubuntu-latest
67+
target: x86_64
68+
- runner: ubuntu-latest
69+
target: x86
70+
- runner: ubuntu-latest
71+
target: aarch64
72+
- runner: ubuntu-latest
73+
target: armv7
74+
steps:
75+
- uses: actions/checkout@v4
3776
- uses: actions/setup-python@v5
3877
with:
39-
python-version: '3.10'
40-
41-
# todo: enable for aarch64, armv7, s390x, ppc64le
42-
# - name: Set up QEMU
43-
# if: runner.os == 'Linux'
44-
# uses: docker/setup-qemu-action@v3
45-
# with:
46-
# platforms: all
47-
48-
- name: Setup Rust in containers
49-
if: runner.os == 'Linux'
50-
run: |
51-
echo "CIBW_BEFORE_ALL=curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal" >> $GITHUB_ENV
52-
echo "CARGO_HOME=/usr/local/" >> $GITHUB_ENV
53-
78+
python-version: 3.x
79+
- name: Setup QEMU
80+
if: ${{ matrix.platform.target != 'x86_64' && matrix.platform.target != 'x86' }}
81+
uses: docker/setup-qemu-action@v1
5482
- name: Build wheels
55-
uses: pypa/cibuildwheel@v2.21.2
56-
env:
57-
CIBW_SKIP: '*-musllinux_i686'
58-
CIBW_ARCHS_LINUX: ${{ matrix.target }}
59-
CIBW_ENVIRONMENT_PASS_LINUX: CARGO_HOME
60-
CIBW_BUILD_VERBOSITY: 1
61-
CIBW_BUILD_FRONTEND: "pip; args: --config-settings=build-args='--features=vendored'"
62-
83+
uses: PyO3/maturin-action@v1
84+
with:
85+
target: ${{ matrix.platform.target }}
86+
args: --release --out dist --interpreter 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 --features vendored
87+
sccache: 'true'
88+
manylinux: musllinux_1_2
6389
- name: Upload wheels
6490
uses: actions/upload-artifact@v4
6591
with:
66-
name: wheels-linux-${{ matrix.target }}
67-
path: ./wheelhouse/*.whl
92+
name: wheels-musllinux-${{ matrix.platform.target }}
93+
path: dist
6894

6995
windows:
70-
runs-on: windows-latest
71-
timeout-minutes: 60
96+
runs-on: ${{ matrix.platform.runner }}
7297
strategy:
7398
matrix:
74-
target: [x64]
99+
platform:
100+
- runner: windows-latest
101+
target: x64
102+
- runner: windows-latest
103+
target: x86
75104
steps:
76-
- name: Install dependencys
77-
uses: msys2/setup-msys2@v2
78-
with:
79-
update: true
80-
install: >-
81-
mingw-w64-x86_64-toolchain
82-
mingw-w64-x86_64-libjxl
83-
84-
- name: Put MSYS2_MinGW64 on PATH
85-
# there is not yet an environment variable for this path from msys2/setup-msys2
86-
run: echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
87-
88105
- uses: actions/checkout@v4
89-
with:
90-
submodules: recursive
91-
92106
- uses: actions/setup-python@v5
93107
with:
94-
python-version: '>=3.9 <=3.13'
95-
architecture: ${{ matrix.target }}
96-
108+
python-version: 3.13
109+
architecture: ${{ matrix.platform.target }}
97110
- name: Build wheels
98111
uses: PyO3/maturin-action@v1
99-
env:
100-
RUST_BACKTRACE: 1
101112
with:
102-
rust-toolchain: stable-x86_64-pc-windows-gnu
103-
target: x86_64-pc-windows-gnu
104-
args: --release --out wheels --find-interpreter --features dynamic
113+
target: ${{ matrix.platform.target }}
114+
args: --release --out dist --interpreter 3.9 3.10 3.11 3.12 3.13 --features vendored
105115
sccache: 'true'
106-
107-
- name: Fix wheels with delvewheel
108-
run: |
109-
pip install delvewheel
110-
Get-ChildItem ${{ github.workspace }}/wheels/*win_amd64.whl | ForEach-Object -Process {delvewheel repair $PSItem -w dist}
111-
112116
- name: Upload wheels
113117
uses: actions/upload-artifact@v4
114118
with:
115-
name: wheels-windows-${{ matrix.target }}
119+
name: wheels-windows-${{ matrix.platform.target }}
116120
path: dist
117121

118122
macos:
119123
runs-on: ${{ matrix.platform.runner }}
120124
strategy:
121125
matrix:
122126
platform:
123-
- runner: macos-latest
127+
- runner: macos-12
124128
target: x86_64
125129
- runner: macos-14
126130
target: aarch64
127131
steps:
128-
- uses: actions/checkout@v4
129-
with:
130-
submodules: recursive
131-
132-
- uses: actions/setup-python@v5
133-
with:
134-
python-version: '>=3.9 <=3.13'
135-
136132
- name: Check dependencys
137133
run: |
138134
brew install jpeg-xl
139135
echo DEP_JXL_LIB=$(brew --prefix jpeg-xl)'/lib' >> $GITHUB_ENV
140136
echo DEP_BROTLI_LIB=$(brew --prefix brotli)'/lib' >> $GITHUB_ENV
141137
echo DEP_HWY_LIB=$(brew --prefix highway)'/lib' >> $GITHUB_ENV
142-
138+
- uses: actions/checkout@v4
139+
- uses: actions/setup-python@v5
140+
with:
141+
python-version: 3.x
143142
- name: Build wheels
144143
uses: PyO3/maturin-action@v1
145-
env:
146-
RUST_BACKTRACE: 1
147-
MACOSX_DEPLOYMENT_TARGET: 12.7
148-
DEP_JXL_LIB: ${{ env.DEP_JXL_LIB }}
149-
DEP_BROTLI_LIB: ${{ env.DEP_BROTLI_LIB }}
150-
DEP_HWY_LIB: ${{ env.DEP_HWY_LIB }}
151144
with:
152145
target: ${{ matrix.platform.target }}
153-
args: --release --out dist --find-interpreter --features dynamic
146+
args: --release --out dist --interpreter 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10 --features dynamic
154147
sccache: 'true'
155-
156148
- name: Upload wheels
157149
uses: actions/upload-artifact@v4
158150
with:
@@ -161,17 +153,13 @@ jobs:
161153

162154
sdist:
163155
runs-on: ubuntu-latest
164-
timeout-minutes: 60
165156
steps:
166157
- uses: actions/checkout@v4
167-
with:
168-
submodules: recursive
169158
- name: Build sdist
170159
uses: PyO3/maturin-action@v1
171160
with:
172161
command: sdist
173162
args: --out dist
174-
rust-toolchain:
175163
- name: Upload sdist
176164
uses: actions/upload-artifact@v4
177165
with:
@@ -181,15 +169,21 @@ jobs:
181169
release:
182170
name: Release
183171
runs-on: ubuntu-latest
184-
timeout-minutes: 10
172+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
173+
needs: [linux, musllinux, windows, macos, sdist]
185174
permissions:
175+
# Use to sign the release artifacts
176+
id-token: write
177+
# Used to upload release artifacts
186178
contents: write
187-
if: "startsWith(github.ref, 'refs/tags/')"
188-
needs: [linux, windows, macos, sdist]
179+
# Used to generate artifact attestation
180+
attestations: write
189181
steps:
190182
- uses: actions/download-artifact@v4
183+
- name: Generate artifact attestation
184+
uses: actions/attest-build-provenance@v1
191185
with:
192-
pattern: wheels-*
186+
subject-path: 'wheels-*/*'
193187
- name: upload to github release
194188
uses: softprops/action-gh-release@v2
195189
with:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ crate-type = ["cdylib"]
1111

1212
[dependencies]
1313
pyo3 = { version="0.22.0", features = ["extension-module"] }
14-
jpegxl-rs = { version="0.11.0" }
14+
jpegxl-rs = { version="0.11.0", default-features = false }
1515

1616
[features]
1717
# Enables parallel processing support by enabling the "rayon" feature of jpeg-decoder.

build.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ fn main() {
4444
dynamic_link();
4545

4646
// Dynamic link c++
47-
// TODO: Support MSVC and use Cargo
48-
let platform = env::consts::OS;
49-
match platform {
50-
// Since MSVC will stuck on building libjxl
51-
// Linux and Windows should all use GNU toolchain
52-
"linux" | "windows" => println!("cargo:rustc-link-lib=stdc++"),
53-
"macos" => println!("cargo:rustc-link-lib=c++"),
54-
_ => panic!("Not implemented c++ link on {}", platform),
47+
#[cfg(target_os = "linux")]
48+
{
49+
println!("cargo:rustc-link-lib=stdc++");
50+
}
51+
#[cfg(target_os = "macos")]
52+
{
53+
println!("cargo:rustc-link-lib=c++");
5554
}
5655
}

0 commit comments

Comments
 (0)