| 1 |
use std::collections::BTreeSet; |
| 2 |
use std::fmt; |
| 3 |
use std::path::{Path, PathBuf}; |
| 4 |
|
| 5 |
use anyhow::Result; |
| 6 |
use clap::{ArgAction, Parser, ValueEnum}; |
| 7 |
use fs_err as fs; |
| 8 |
|
| 9 |
use crate::build_options::find_bridge; |
| 10 |
use crate::project_layout::ProjectResolver; |
| 11 |
use crate::{BridgeModel, CargoOptions}; |
| 12 |
|
| 13 |
/// CI providers |
| 14 |
#[derive(Debug, Clone, Copy, ValueEnum)] |
| 15 |
#[clap(rename_all = "lower")] |
| 16 |
pub enum Provider { |
| 17 |
/// GitHub |
| 18 |
GitHub, |
| 19 |
} |
| 20 |
|
| 21 |
/// Platform |
| 22 |
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] |
| 23 |
#[clap(rename_all = "lower")] |
| 24 |
pub enum Platform { |
| 25 |
/// All |
| 26 |
All, |
| 27 |
/// Manylinux |
| 28 |
#[clap(alias = "linux")] |
| 29 |
ManyLinux, |
| 30 |
/// Musllinux |
| 31 |
Musllinux, |
| 32 |
/// Windows |
| 33 |
Windows, |
| 34 |
/// macOS |
| 35 |
Macos, |
| 36 |
/// Emscripten |
| 37 |
Emscripten, |
| 38 |
} |
| 39 |
|
| 40 |
impl Platform { |
| 41 |
fn defaults() -> Vec<Self> { |
| 42 |
vec![ |
| 43 |
Platform::ManyLinux, |
| 44 |
Platform::Musllinux, |
| 45 |
Platform::Windows, |
| 46 |
Platform::Macos, |
| 47 |
] |
| 48 |
} |
| 49 |
|
| 50 |
fn all() -> Vec<Self> { |
| 51 |
vec![ |
| 52 |
Platform::ManyLinux, |
| 53 |
Platform::Musllinux, |
| 54 |
Platform::Windows, |
| 55 |
Platform::Macos, |
| 56 |
Platform::Emscripten, |
| 57 |
] |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
impl fmt::Display for Platform { |
| 62 |
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 63 |
match self { |
| 64 |
Platform::All => write!(f, "all"), |
| 65 |
Platform::ManyLinux => write!(f, "linux"), |
| 66 |
Platform::Musllinux => write!(f, "musllinux"), |
| 67 |
Platform::Windows => write!(f, "windows"), |
| 68 |
Platform::Macos => write!(f, "macos"), |
| 69 |
Platform::Emscripten => write!(f, "emscripten"), |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
struct MatrixPlatform { |
| 75 |
runner: &'static str, |
| 76 |
target: &'static str, |
| 77 |
} |
| 78 |
|
| 79 |
/// Generate CI configuration |
| 80 |
#[derive(Debug, Parser)] |
| 81 |
pub struct GenerateCI { |
| 82 |
/// CI provider |
| 83 |
#[arg(value_enum, value_name = "CI")] |
| 84 |
pub ci: Provider, |
| 85 |
/// Path to Cargo.toml |
| 86 |
#[arg(short = 'm', long, value_name = "PATH")] |
| 87 |
pub manifest_path: Option<PathBuf>, |
| 88 |
/// Output path |
| 89 |
#[arg(short = 'o', long, value_name = "PATH", default_value = "-")] |
| 90 |
pub output: PathBuf, |
| 91 |
/// Platform support |
| 92 |
#[arg( |
| 93 |
id = "platform", |
| 94 |
long, |
| 95 |
action = ArgAction::Append, |
| 96 |
num_args = 1.., |
| 97 |
default_values_t = vec![ |
| 98 |
Platform::ManyLinux, |
| 99 |
Platform::Musllinux, |
| 100 |
Platform::Windows, |
| 101 |
Platform::Macos, |
| 102 |
], |
| 103 |
)] |
| 104 |
pub platforms: Vec<Platform>, |
| 105 |
/// Enable pytest |
| 106 |
#[arg(long)] |
| 107 |
pub pytest: bool, |
| 108 |
/// Use zig to do cross compilation |
| 109 |
#[arg(long)] |
| 110 |
pub zig: bool, |
| 111 |
/// Skip artifact attestation |
| 112 |
#[arg(long)] |
| 113 |
pub skip_attestation: bool, |
| 114 |
} |
| 115 |
|
| 116 |
impl Default for GenerateCI { |
| 117 |
fn default() -> Self { |
| 118 |
Self { |
| 119 |
ci: Provider::GitHub, |
| 120 |
manifest_path: None, |
| 121 |
output: PathBuf::from("-"), |
| 122 |
platforms: vec![ |
| 123 |
Platform::ManyLinux, |
| 124 |
Platform::Musllinux, |
| 125 |
Platform::Windows, |
| 126 |
Platform::Macos, |
| 127 |
], |
| 128 |
pytest: false, |
| 129 |
zig: false, |
| 130 |
skip_attestation: false, |
| 131 |
} |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
impl GenerateCI { |
| 136 |
/// Execute this command |
| 137 |
pub fn execute(&self) -> Result<()> { |
| 138 |
let conf = self.generate()?; |
| 139 |
self.print(&conf) |
| 140 |
} |
| 141 |
|
| 142 |
/// Generate CI configuration |
| 143 |
pub fn generate(&self) -> Result<String> { |
| 144 |
let cargo_options = CargoOptions { |
| 145 |
manifest_path: self.manifest_path.clone(), |
| 146 |
..Default::default() |
| 147 |
}; |
| 148 |
let ProjectResolver { |
| 149 |
cargo_metadata, |
| 150 |
pyproject_toml, |
| 151 |
project_layout, |
| 152 |
.. |
| 153 |
} = ProjectResolver::resolve(self.manifest_path.clone(), cargo_options)?; |
| 154 |
let pyproject = pyproject_toml.as_ref(); |
| 155 |
let bridge = find_bridge(&cargo_metadata, pyproject.and_then(|x| x.bindings()))?; |
| 156 |
let project_name = pyproject |
| 157 |
.and_then(|project| project.project_name()) |
| 158 |
.unwrap_or(&project_layout.extension_name); |
| 159 |
let sdist = pyproject_toml.is_some(); |
| 160 |
|
| 161 |
match self.ci { |
| 162 |
Provider::GitHub => self.generate_github(project_name, &bridge, sdist), |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
pub(crate) fn generate_github( |
| 167 |
&self, |
| 168 |
project_name: &str, |
| 169 |
bridge_model: &BridgeModel, |
| 170 |
sdist: bool, |
| 171 |
) -> Result<String> { |
| 172 |
let is_abi3 = bridge_model.is_abi3(); |
| 173 |
let is_bin = bridge_model.is_bin(); |
| 174 |
let setup_python = self.pytest |
| 175 |
|| matches!( |
| 176 |
bridge_model, |
| 177 |
BridgeModel::Bin(Some(_)) |
| 178 |
| BridgeModel::PyO3 { .. } |
| 179 |
| BridgeModel::Cffi |
| 180 |
| BridgeModel::UniFfi |
| 181 |
); |
| 182 |
let mut gen_cmd = std::env::args() |
| 183 |
.enumerate() |
| 184 |
.map(|(i, arg)| { |
| 185 |
if i == 0 { |
| 186 |
env!("CARGO_PKG_NAME").to_string() |
| 187 |
} else { |
| 188 |
arg |
| 189 |
} |
| 190 |
}) |
| 191 |
.collect::<Vec<String>>() |
| 192 |
.join(" "); |
| 193 |
if gen_cmd.starts_with("maturin new") || gen_cmd.starts_with("maturin init") { |
| 194 |
gen_cmd = format!("{} generate-ci github", env!("CARGO_PKG_NAME")); |
| 195 |
} |
| 196 |
let mut conf = format!( |
| 197 |
"# This file is autogenerated by maturin v{version} |
| 198 |
# To update, run |
| 199 |
# |
| 200 |
# {gen_cmd} |
| 201 |
# |
| 202 |
name: CI |
| 203 |
|
| 204 |
on: |
| 205 |
push: |
| 206 |
branches: |
| 207 |
- main |
| 208 |
- master |
| 209 |
tags: |
| 210 |
- '*' |
| 211 |
pull_request: |
| 212 |
workflow_dispatch: |
| 213 |
|
| 214 |
permissions: |
| 215 |
contents: read |
| 216 |
|
| 217 |
jobs:\n", |
| 218 |
version = env!("CARGO_PKG_VERSION"), |
| 219 |
); |
| 220 |
|
| 221 |
let mut needs = Vec::new(); |
| 222 |
let platforms: BTreeSet<_> = self |
| 223 |
.platforms |
| 224 |
.iter() |
| 225 |
.flat_map(|p| { |
| 226 |
if matches!(p, Platform::All) { |
| 227 |
if !bridge_model.is_bin() { |
| 228 |
Platform::all() |
| 229 |
} else { |
| 230 |
Platform::defaults() |
| 231 |
} |
| 232 |
} else { |
| 233 |
vec![*p] |
| 234 |
} |
| 235 |
}) |
| 236 |
.collect(); |
| 237 |
for platform in &platforms { |
| 238 |
if bridge_model.is_bin() && matches!(platform, Platform::Emscripten) { |
| 239 |
continue; |
| 240 |
} |
| 241 |
let plat_name = platform.to_string(); |
| 242 |
needs.push(plat_name.clone()); |
| 243 |
conf.push_str(&format!( |
| 244 |
" {plat_name}: |
| 245 |
runs-on: ${{{{ matrix.platform.runner }}}}\n" |
| 246 |
)); |
| 247 |
// target matrix |
| 248 |
let targets: Vec<_> = match platform { |
| 249 |
Platform::ManyLinux => ["x86_64", "x86", "aarch64", "armv7", "s390x", "ppc64le"] |
| 250 |
.into_iter() |
| 251 |
.map(|target| MatrixPlatform { |
| 252 |
runner: "ubuntu-22.04", |
| 253 |
target, |
| 254 |
}) |
| 255 |
.collect(), |
| 256 |
Platform::Musllinux => ["x86_64", "x86", "aarch64", "armv7"] |
| 257 |
.into_iter() |
| 258 |
.map(|target| MatrixPlatform { |
| 259 |
runner: "ubuntu-22.04", |
| 260 |
target, |
| 261 |
}) |
| 262 |
.collect(), |
| 263 |
Platform::Windows => ["x64", "x86"] |
| 264 |
.into_iter() |
| 265 |
.map(|target| MatrixPlatform { |
| 266 |
runner: "windows-latest", |
| 267 |
target, |
| 268 |
}) |
| 269 |
.collect(), |
| 270 |
Platform::Macos => { |
| 271 |
vec![ |
| 272 |
MatrixPlatform { |
| 273 |
runner: "macos-13", |
| 274 |
target: "x86_64", |
| 275 |
}, |
| 276 |
MatrixPlatform { |
| 277 |
runner: "macos-14", |
| 278 |
target: "aarch64", |
| 279 |
}, |
| 280 |
] |
| 281 |
} |
| 282 |
Platform::Emscripten => vec![MatrixPlatform { |
| 283 |
runner: "ubuntu-22.04", |
| 284 |
target: "wasm32-unknown-emscripten", |
| 285 |
}], |
| 286 |
_ => Vec::new(), |
| 287 |
}; |
| 288 |
if !targets.is_empty() { |
| 289 |
conf.push_str( |
| 290 |
" strategy: |
| 291 |
matrix: |
| 292 |
platform:\n", |
| 293 |
); |
| 294 |
} |
| 295 |
for target in targets { |
| 296 |
conf.push_str(&format!( |
| 297 |
" - runner: {}\n target: {}\n", |
| 298 |
target.runner, target.target, |
| 299 |
)); |
| 300 |
} |
| 301 |
// job steps |
| 302 |
conf.push_str( |
| 303 |
" steps: |
| 304 |
- uses: actions/checkout@v4\n", |
| 305 |
); |
| 306 |
|
| 307 |
// install pyodide-build for emscripten |
| 308 |
if matches!(platform, Platform::Emscripten) { |
| 309 |
// install stable pyodide-build |
| 310 |
conf.push_str(" - run: pip install pyodide-build\n"); |
| 311 |
// get the current python version for the installed pyodide-build |
| 312 |
conf.push_str( |
| 313 |
" - name: Get Emscripten and Python version info |
| 314 |
shell: bash |
| 315 |
run: | |
| 316 |
echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV |
| 317 |
echo PYTHON_VERSION=$(pyodide config get python_version | cut -d '.' -f 1-2) >> $GITHUB_ENV |
| 318 |
pip uninstall -y pyodide-build\n", |
| 319 |
); |
| 320 |
conf.push_str( |
| 321 |
" - uses: mymindstorm/setup-emsdk@v12 |
| 322 |
with: |
| 323 |
version: ${{ env.EMSCRIPTEN_VERSION }} |
| 324 |
actions-cache-folder: emsdk-cache\n", |
| 325 |
); |
| 326 |
conf.push_str( |
| 327 |
" - uses: actions/setup-python@v5 |
| 328 |
with: |
| 329 |
python-version: ${{ env.PYTHON_VERSION }}\n", |
| 330 |
); |
| 331 |
// install pyodide-build again in the right Python version |
| 332 |
conf.push_str(" - run: pip install pyodide-build\n"); |
| 333 |
} else { |
| 334 |
// setup python on demand |
| 335 |
if setup_python { |
| 336 |
conf.push_str( |
| 337 |
" - uses: actions/setup-python@v5 |
| 338 |
with: |
| 339 |
python-version: 3.x\n", |
| 340 |
); |
| 341 |
if matches!(platform, Platform::Windows) { |
| 342 |
conf.push_str(" architecture: ${{ matrix.platform.target }}\n"); |
| 343 |
} |
| 344 |
} |
| 345 |
} |
| 346 |
|
| 347 |
// build wheels |
| 348 |
let mut maturin_args = if is_abi3 || (is_bin && !setup_python) { |
| 349 |
Vec::new() |
| 350 |
} else if matches!(platform, Platform::Emscripten) { |
| 351 |
vec!["-i".to_string(), "${{ env.PYTHON_VERSION }}".to_string()] |
| 352 |
} else { |
| 353 |
vec!["--find-interpreter".to_string()] |
| 354 |
}; |
| 355 |
if let Some(manifest_path) = self.manifest_path.as_ref() { |
| 356 |
if manifest_path != Path::new("Cargo.toml") { |
| 357 |
maturin_args.push("--manifest-path".to_string()); |
| 358 |
maturin_args.push(manifest_path.display().to_string()) |
| 359 |
} |
| 360 |
} |
| 361 |
if self.zig && matches!(platform, Platform::ManyLinux) { |
| 362 |
maturin_args.push("--zig".to_string()); |
| 363 |
} |
| 364 |
let maturin_args = if maturin_args.is_empty() { |
| 365 |
String::new() |
| 366 |
} else { |
| 367 |
format!(" {}", maturin_args.join(" ")) |
| 368 |
}; |
| 369 |
conf.push_str(&format!( |
| 370 |
" - name: Build wheels |
| 371 |
uses: PyO3/maturin-action@v1 |
| 372 |
with: |
| 373 |
target: ${{{{ matrix.platform.target }}}} |
| 374 |
args: --release --out dist{maturin_args} |
| 375 |
sccache: ${{{{ !startsWith(github.ref, 'refs/tags/') }}}} |
| 376 |
" |
| 377 |
)); |
| 378 |
let maturin_action_args = match platform { |
| 379 |
Platform::ManyLinux => "manylinux: auto", |
| 380 |
Platform::Musllinux => "manylinux: musllinux_1_2", |
| 381 |
Platform::Emscripten => "rust-toolchain: nightly", |
| 382 |
_ => "", |
| 383 |
}; |
| 384 |
if !maturin_action_args.is_empty() { |
| 385 |
conf.push_str(&format!(" {maturin_action_args}\n")); |
| 386 |
} |
| 387 |
if is_abi3 { |
| 388 |
// build free-threaded wheel for python3.13t |
| 389 |
if matches!(platform, Platform::Windows) { |
| 390 |
conf.push_str( |
| 391 |
" - uses: actions/setup-python@v5 |
| 392 |
with: |
| 393 |
python-version: 3.13t\n", |
| 394 |
); |
| 395 |
conf.push_str(" architecture: ${{ matrix.platform.target }}\n"); |
| 396 |
} |
| 397 |
conf.push_str(&format!( |
| 398 |
" - name: Build free-threaded wheels |
| 399 |
uses: PyO3/maturin-action@v1 |
| 400 |
with: |
| 401 |
target: ${{{{ matrix.platform.target }}}} |
| 402 |
args: --release --out dist{maturin_args} -i python3.13t |
| 403 |
sccache: ${{{{ !startsWith(github.ref, 'refs/tags/') }}}} |
| 404 |
" |
| 405 |
)); |
| 406 |
if !maturin_action_args.is_empty() { |
| 407 |
conf.push_str(&format!(" {maturin_action_args}\n")); |
| 408 |
} |
| 409 |
} |
| 410 |
// upload wheels |
| 411 |
let artifact_name = match platform { |
| 412 |
Platform::Emscripten => "wasm-wheels".to_string(), |
| 413 |
_ => format!("wheels-{platform}-${{{{ matrix.platform.target }}}}"), |
| 414 |
}; |
| 415 |
conf.push_str(&format!( |
| 416 |
" - name: Upload wheels |
| 417 |
uses: actions/upload-artifact@v4 |
| 418 |
with: |
| 419 |
name: {artifact_name} |
| 420 |
path: dist |
| 421 |
" |
| 422 |
)); |
| 423 |
// pytest |
| 424 |
let mut chdir = String::new(); |
| 425 |
if let Some(manifest_path) = self.manifest_path.as_ref() { |
| 426 |
if manifest_path != Path::new("Cargo.toml") { |
| 427 |
let parent = manifest_path.parent().unwrap(); |
| 428 |
chdir = format!("cd {} && ", parent.display()); |
| 429 |
} |
| 430 |
} |
| 431 |
if self.pytest { |
| 432 |
match platform { |
| 433 |
Platform::All => {} |
| 434 |
Platform::ManyLinux => { |
| 435 |
// Test on host for x86_64 GNU targets |
| 436 |
conf.push_str(&format!( |
| 437 |
" - name: pytest |
| 438 |
if: ${{{{ startsWith(matrix.platform.target, 'x86_64') }}}} |
| 439 |
shell: bash |
| 440 |
run: | |
| 441 |
set -e |
| 442 |
python3 -m venv .venv |
| 443 |
source .venv/bin/activate |
| 444 |
pip install {project_name} --find-links dist --force-reinstall |
| 445 |
pip install pytest |
| 446 |
{chdir}pytest |
| 447 |
" |
| 448 |
)); |
| 449 |
// Test on QEMU for other GNU architectures |
| 450 |
conf.push_str(&format!( |
| 451 |
" - name: pytest |
| 452 |
if: ${{{{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}}} |
| 453 |
uses: uraimo/run-on-arch-action@v2 |
| 454 |
with: |
| 455 |
arch: ${{{{ matrix.platform.target }}}} |
| 456 |
distro: ubuntu22.04 |
| 457 |
githubToken: ${{{{ github.token }}}} |
| 458 |
install: | |
| 459 |
apt-get update |
| 460 |
apt-get install -y --no-install-recommends python3 python3-pip |
| 461 |
pip3 install -U pip pytest |
| 462 |
run: | |
| 463 |
set -e |
| 464 |
pip3 install {project_name} --find-links dist --force-reinstall |
| 465 |
{chdir}pytest |
| 466 |
" |
| 467 |
)); |
| 468 |
} |
| 469 |
Platform::Musllinux => { |
| 470 |
conf.push_str(&format!( |
| 471 |
" - name: pytest |
| 472 |
if: ${{{{ startsWith(matrix.platform.target, 'x86_64') }}}} |
| 473 |
uses: addnab/docker-run-action@v3 |
| 474 |
with: |
| 475 |
image: alpine:latest |
| 476 |
options: -v ${{{{ github.workspace }}}}:/io -w /io |
| 477 |
run: | |
| 478 |
set -e |
| 479 |
apk add py3-pip py3-virtualenv |
| 480 |
python3 -m virtualenv .venv |
| 481 |
source .venv/bin/activate |
| 482 |
pip install {project_name} --no-index --find-links dist --force-reinstall |
| 483 |
pip install pytest |
| 484 |
{chdir}pytest |
| 485 |
" |
| 486 |
)); |
| 487 |
conf.push_str(&format!( |
| 488 |
" - name: pytest |
| 489 |
if: ${{{{ !startsWith(matrix.platform.target, 'x86') }}}} |
| 490 |
uses: uraimo/run-on-arch-action@v2 |
| 491 |
with: |
| 492 |
arch: ${{{{ matrix.platform.target }}}} |
| 493 |
distro: alpine_latest |
| 494 |
githubToken: ${{{{ github.token }}}} |
| 495 |
install: | |
| 496 |
apk add py3-virtualenv |
| 497 |
run: | |
| 498 |
set -e |
| 499 |
python3 -m virtualenv .venv |
| 500 |
source .venv/bin/activate |
| 501 |
pip install pytest |
| 502 |
pip install {project_name} --find-links dist --force-reinstall |
| 503 |
{chdir}pytest |
| 504 |
" |
| 505 |
)); |
| 506 |
} |
| 507 |
Platform::Windows => { |
| 508 |
conf.push_str(&format!( |
| 509 |
" - name: pytest |
| 510 |
if: ${{{{ !startsWith(matrix.platform.target, 'aarch64') }}}} |
| 511 |
shell: bash |
| 512 |
run: | |
| 513 |
set -e |
| 514 |
python3 -m venv .venv |
| 515 |
source .venv/Scripts/activate |
| 516 |
pip install {project_name} --find-links dist --force-reinstall |
| 517 |
pip install pytest |
| 518 |
{chdir}pytest |
| 519 |
" |
| 520 |
)); |
| 521 |
} |
| 522 |
Platform::Macos => { |
| 523 |
conf.push_str(&format!( |
| 524 |
" - name: pytest |
| 525 |
run: | |
| 526 |
set -e |
| 527 |
python3 -m venv .venv |
| 528 |
source .venv/bin/activate |
| 529 |
pip install {project_name} --find-links dist --force-reinstall |
| 530 |
pip install pytest |
| 531 |
{chdir}pytest |
| 532 |
" |
| 533 |
)); |
| 534 |
} |
| 535 |
Platform::Emscripten => { |
| 536 |
conf.push_str( |
| 537 |
" - uses: actions/setup-node@v3 |
| 538 |
with: |
| 539 |
node-version: '18' |
| 540 |
", |
| 541 |
); |
| 542 |
conf.push_str(&format!( |
| 543 |
" - name: pytest |
| 544 |
run: | |
| 545 |
set -e |
| 546 |
pyodide venv .venv |
| 547 |
source .venv/bin/activate |
| 548 |
pip install {project_name} --find-links dist --force-reinstall |
| 549 |
pip install pytest |
| 550 |
{chdir}python -m pytest |
| 551 |
" |
| 552 |
)); |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
conf.push('\n'); |
| 558 |
} |
| 559 |
|
| 560 |
// build sdist |
| 561 |
if sdist { |
| 562 |
needs.push("sdist".to_string()); |
| 563 |
|
| 564 |
let maturin_args = self |
| 565 |
.manifest_path |
| 566 |
.as_ref() |
| 567 |
.map(|manifest_path| { |
| 568 |
if manifest_path != Path::new("Cargo.toml") { |
| 569 |
format!(" --manifest-path {}", manifest_path.display()) |
| 570 |
} else { |
| 571 |
String::new() |
| 572 |
} |
| 573 |
}) |
| 574 |
.unwrap_or_default(); |
| 575 |
conf.push_str(&format!( |
| 576 |
r#" sdist: |
| 577 |
runs-on: ubuntu-latest |
| 578 |
steps: |
| 579 |
- uses: actions/checkout@v4 |
| 580 |
- name: Build sdist |
| 581 |
uses: PyO3/maturin-action@v1 |
| 582 |
with: |
| 583 |
command: sdist |
| 584 |
args: --out dist{maturin_args} |
| 585 |
"# |
| 586 |
)); |
| 587 |
conf.push_str( |
| 588 |
" - name: Upload sdist |
| 589 |
uses: actions/upload-artifact@v4 |
| 590 |
with: |
| 591 |
name: wheels-sdist |
| 592 |
path: dist |
| 593 |
", |
| 594 |
); |
| 595 |
conf.push('\n'); |
| 596 |
} |
| 597 |
|
| 598 |
conf.push_str(&format!( |
| 599 |
r#" release: |
| 600 |
name: Release |
| 601 |
runs-on: ubuntu-latest |
| 602 |
if: ${{{{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}}} |
| 603 |
needs: [{needs}] |
| 604 |
"#, |
| 605 |
needs = needs.join(", ") |
| 606 |
)); |
| 607 |
|
| 608 |
conf.push_str( |
| 609 |
r#" permissions: |
| 610 |
# Use to sign the release artifacts |
| 611 |
id-token: write |
| 612 |
# Used to upload release artifacts |
| 613 |
contents: write |
| 614 |
"#, |
| 615 |
); |
| 616 |
if !self.skip_attestation { |
| 617 |
conf.push_str( |
| 618 |
r#" # Used to generate artifact attestation |
| 619 |
attestations: write |
| 620 |
"#, |
| 621 |
); |
| 622 |
} |
| 623 |
conf.push_str( |
| 624 |
r#" steps: |
| 625 |
- uses: actions/download-artifact@v4 |
| 626 |
"#, |
| 627 |
); |
| 628 |
if !self.skip_attestation { |
| 629 |
conf.push_str( |
| 630 |
r#" - name: Generate artifact attestation |
| 631 |
uses: actions/attest-build-provenance@v2 |
| 632 |
with: |
| 633 |
subject-path: 'wheels-*/*' |
| 634 |
"#, |
| 635 |
); |
| 636 |
} |
| 637 |
conf.push_str( |
| 638 |
r#" - name: Publish to PyPI |
| 639 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 640 |
uses: PyO3/maturin-action@v1 |
| 641 |
env: |
| 642 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 643 |
with: |
| 644 |
command: upload |
| 645 |
args: --non-interactive --skip-existing wheels-*/* |
| 646 |
"#, |
| 647 |
); |
| 648 |
if platforms.contains(&Platform::Emscripten) { |
| 649 |
conf.push_str( |
| 650 |
" - name: Upload to GitHub Release |
| 651 |
uses: softprops/action-gh-release@v1 |
| 652 |
with: |
| 653 |
files: | |
| 654 |
wasm-wheels/*.whl |
| 655 |
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} |
| 656 |
", |
| 657 |
); |
| 658 |
} |
| 659 |
Ok(conf) |
| 660 |
} |
| 661 |
|
| 662 |
fn print(&self, conf: &str) -> Result<()> { |
| 663 |
if self.output == Path::new("-") { |
| 664 |
print!("{conf}"); |
| 665 |
} else { |
| 666 |
fs::write(&self.output, conf)?; |
| 667 |
} |
| 668 |
Ok(()) |
| 669 |
} |
| 670 |
} |
| 671 |
|
| 672 |
#[cfg(test)] |
| 673 |
mod tests { |
| 674 |
use super::GenerateCI; |
| 675 |
use crate::{bridge::PyO3Crate, Abi3Version, BridgeModel, PyO3}; |
| 676 |
use expect_test::expect; |
| 677 |
use semver::Version; |
| 678 |
|
| 679 |
#[test] |
| 680 |
fn test_generate_github() { |
| 681 |
let conf = GenerateCI::default() |
| 682 |
.generate_github( |
| 683 |
"example", |
| 684 |
&BridgeModel::PyO3(PyO3 { |
| 685 |
crate_name: PyO3Crate::PyO3, |
| 686 |
version: Version::new(0, 23, 0), |
| 687 |
abi3: None, |
| 688 |
metadata: None, |
| 689 |
}), |
| 690 |
true, |
| 691 |
) |
| 692 |
.unwrap() |
| 693 |
.lines() |
| 694 |
.skip(5) |
| 695 |
.collect::<Vec<_>>() |
| 696 |
.join("\n"); |
| 697 |
let expected = expect![[r#" |
| 698 |
name: CI |
| 699 |
|
| 700 |
on: |
| 701 |
push: |
| 702 |
branches: |
| 703 |
- main |
| 704 |
- master |
| 705 |
tags: |
| 706 |
- '*' |
| 707 |
pull_request: |
| 708 |
workflow_dispatch: |
| 709 |
|
| 710 |
permissions: |
| 711 |
contents: read |
| 712 |
|
| 713 |
jobs: |
| 714 |
linux: |
| 715 |
runs-on: ${{ matrix.platform.runner }} |
| 716 |
strategy: |
| 717 |
matrix: |
| 718 |
platform: |
| 719 |
- runner: ubuntu-22.04 |
| 720 |
target: x86_64 |
| 721 |
- runner: ubuntu-22.04 |
| 722 |
target: x86 |
| 723 |
- runner: ubuntu-22.04 |
| 724 |
target: aarch64 |
| 725 |
- runner: ubuntu-22.04 |
| 726 |
target: armv7 |
| 727 |
- runner: ubuntu-22.04 |
| 728 |
target: s390x |
| 729 |
- runner: ubuntu-22.04 |
| 730 |
target: ppc64le |
| 731 |
steps: |
| 732 |
- uses: actions/checkout@v4 |
| 733 |
- uses: actions/setup-python@v5 |
| 734 |
with: |
| 735 |
python-version: 3.x |
| 736 |
- name: Build wheels |
| 737 |
uses: PyO3/maturin-action@v1 |
| 738 |
with: |
| 739 |
target: ${{ matrix.platform.target }} |
| 740 |
args: --release --out dist --find-interpreter |
| 741 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 742 |
manylinux: auto |
| 743 |
- name: Upload wheels |
| 744 |
uses: actions/upload-artifact@v4 |
| 745 |
with: |
| 746 |
name: wheels-linux-${{ matrix.platform.target }} |
| 747 |
path: dist |
| 748 |
|
| 749 |
musllinux: |
| 750 |
runs-on: ${{ matrix.platform.runner }} |
| 751 |
strategy: |
| 752 |
matrix: |
| 753 |
platform: |
| 754 |
- runner: ubuntu-22.04 |
| 755 |
target: x86_64 |
| 756 |
- runner: ubuntu-22.04 |
| 757 |
target: x86 |
| 758 |
- runner: ubuntu-22.04 |
| 759 |
target: aarch64 |
| 760 |
- runner: ubuntu-22.04 |
| 761 |
target: armv7 |
| 762 |
steps: |
| 763 |
- uses: actions/checkout@v4 |
| 764 |
- uses: actions/setup-python@v5 |
| 765 |
with: |
| 766 |
python-version: 3.x |
| 767 |
- name: Build wheels |
| 768 |
uses: PyO3/maturin-action@v1 |
| 769 |
with: |
| 770 |
target: ${{ matrix.platform.target }} |
| 771 |
args: --release --out dist --find-interpreter |
| 772 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 773 |
manylinux: musllinux_1_2 |
| 774 |
- name: Upload wheels |
| 775 |
uses: actions/upload-artifact@v4 |
| 776 |
with: |
| 777 |
name: wheels-musllinux-${{ matrix.platform.target }} |
| 778 |
path: dist |
| 779 |
|
| 780 |
windows: |
| 781 |
runs-on: ${{ matrix.platform.runner }} |
| 782 |
strategy: |
| 783 |
matrix: |
| 784 |
platform: |
| 785 |
- runner: windows-latest |
| 786 |
target: x64 |
| 787 |
- runner: windows-latest |
| 788 |
target: x86 |
| 789 |
steps: |
| 790 |
- uses: actions/checkout@v4 |
| 791 |
- uses: actions/setup-python@v5 |
| 792 |
with: |
| 793 |
python-version: 3.x |
| 794 |
architecture: ${{ matrix.platform.target }} |
| 795 |
- name: Build wheels |
| 796 |
uses: PyO3/maturin-action@v1 |
| 797 |
with: |
| 798 |
target: ${{ matrix.platform.target }} |
| 799 |
args: --release --out dist --find-interpreter |
| 800 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 801 |
- name: Upload wheels |
| 802 |
uses: actions/upload-artifact@v4 |
| 803 |
with: |
| 804 |
name: wheels-windows-${{ matrix.platform.target }} |
| 805 |
path: dist |
| 806 |
|
| 807 |
macos: |
| 808 |
runs-on: ${{ matrix.platform.runner }} |
| 809 |
strategy: |
| 810 |
matrix: |
| 811 |
platform: |
| 812 |
- runner: macos-13 |
| 813 |
target: x86_64 |
| 814 |
- runner: macos-14 |
| 815 |
target: aarch64 |
| 816 |
steps: |
| 817 |
- uses: actions/checkout@v4 |
| 818 |
- uses: actions/setup-python@v5 |
| 819 |
with: |
| 820 |
python-version: 3.x |
| 821 |
- name: Build wheels |
| 822 |
uses: PyO3/maturin-action@v1 |
| 823 |
with: |
| 824 |
target: ${{ matrix.platform.target }} |
| 825 |
args: --release --out dist --find-interpreter |
| 826 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 827 |
- name: Upload wheels |
| 828 |
uses: actions/upload-artifact@v4 |
| 829 |
with: |
| 830 |
name: wheels-macos-${{ matrix.platform.target }} |
| 831 |
path: dist |
| 832 |
|
| 833 |
sdist: |
| 834 |
runs-on: ubuntu-latest |
| 835 |
steps: |
| 836 |
- uses: actions/checkout@v4 |
| 837 |
- name: Build sdist |
| 838 |
uses: PyO3/maturin-action@v1 |
| 839 |
with: |
| 840 |
command: sdist |
| 841 |
args: --out dist |
| 842 |
- name: Upload sdist |
| 843 |
uses: actions/upload-artifact@v4 |
| 844 |
with: |
| 845 |
name: wheels-sdist |
| 846 |
path: dist |
| 847 |
|
| 848 |
release: |
| 849 |
name: Release |
| 850 |
runs-on: ubuntu-latest |
| 851 |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 852 |
needs: [linux, musllinux, windows, macos, sdist] |
| 853 |
permissions: |
| 854 |
# Use to sign the release artifacts |
| 855 |
id-token: write |
| 856 |
# Used to upload release artifacts |
| 857 |
contents: write |
| 858 |
# Used to generate artifact attestation |
| 859 |
attestations: write |
| 860 |
steps: |
| 861 |
- uses: actions/download-artifact@v4 |
| 862 |
- name: Generate artifact attestation |
| 863 |
uses: actions/attest-build-provenance@v2 |
| 864 |
with: |
| 865 |
subject-path: 'wheels-*/*' |
| 866 |
- name: Publish to PyPI |
| 867 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 868 |
uses: PyO3/maturin-action@v1 |
| 869 |
env: |
| 870 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 871 |
with: |
| 872 |
command: upload |
| 873 |
args: --non-interactive --skip-existing wheels-*/*"#]]; |
| 874 |
expected.assert_eq(&conf); |
| 875 |
} |
| 876 |
|
| 877 |
#[test] |
| 878 |
fn test_generate_github_abi3() { |
| 879 |
let conf = GenerateCI::default() |
| 880 |
.generate_github( |
| 881 |
"example", |
| 882 |
&BridgeModel::PyO3(PyO3 { |
| 883 |
crate_name: PyO3Crate::PyO3, |
| 884 |
version: Version::new(0, 23, 0), |
| 885 |
abi3: Some(Abi3Version::Version(3, 7)), |
| 886 |
metadata: None, |
| 887 |
}), |
| 888 |
false, |
| 889 |
) |
| 890 |
.unwrap() |
| 891 |
.lines() |
| 892 |
.skip(5) |
| 893 |
.collect::<Vec<_>>() |
| 894 |
.join("\n"); |
| 895 |
let expected = expect![[r#" |
| 896 |
name: CI |
| 897 |
|
| 898 |
on: |
| 899 |
push: |
| 900 |
branches: |
| 901 |
- main |
| 902 |
- master |
| 903 |
tags: |
| 904 |
- '*' |
| 905 |
pull_request: |
| 906 |
workflow_dispatch: |
| 907 |
|
| 908 |
permissions: |
| 909 |
contents: read |
| 910 |
|
| 911 |
jobs: |
| 912 |
linux: |
| 913 |
runs-on: ${{ matrix.platform.runner }} |
| 914 |
strategy: |
| 915 |
matrix: |
| 916 |
platform: |
| 917 |
- runner: ubuntu-22.04 |
| 918 |
target: x86_64 |
| 919 |
- runner: ubuntu-22.04 |
| 920 |
target: x86 |
| 921 |
- runner: ubuntu-22.04 |
| 922 |
target: aarch64 |
| 923 |
- runner: ubuntu-22.04 |
| 924 |
target: armv7 |
| 925 |
- runner: ubuntu-22.04 |
| 926 |
target: s390x |
| 927 |
- runner: ubuntu-22.04 |
| 928 |
target: ppc64le |
| 929 |
steps: |
| 930 |
- uses: actions/checkout@v4 |
| 931 |
- uses: actions/setup-python@v5 |
| 932 |
with: |
| 933 |
python-version: 3.x |
| 934 |
- name: Build wheels |
| 935 |
uses: PyO3/maturin-action@v1 |
| 936 |
with: |
| 937 |
target: ${{ matrix.platform.target }} |
| 938 |
args: --release --out dist |
| 939 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 940 |
manylinux: auto |
| 941 |
- name: Build free-threaded wheels |
| 942 |
uses: PyO3/maturin-action@v1 |
| 943 |
with: |
| 944 |
target: ${{ matrix.platform.target }} |
| 945 |
args: --release --out dist -i python3.13t |
| 946 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 947 |
manylinux: auto |
| 948 |
- name: Upload wheels |
| 949 |
uses: actions/upload-artifact@v4 |
| 950 |
with: |
| 951 |
name: wheels-linux-${{ matrix.platform.target }} |
| 952 |
path: dist |
| 953 |
|
| 954 |
musllinux: |
| 955 |
runs-on: ${{ matrix.platform.runner }} |
| 956 |
strategy: |
| 957 |
matrix: |
| 958 |
platform: |
| 959 |
- runner: ubuntu-22.04 |
| 960 |
target: x86_64 |
| 961 |
- runner: ubuntu-22.04 |
| 962 |
target: x86 |
| 963 |
- runner: ubuntu-22.04 |
| 964 |
target: aarch64 |
| 965 |
- runner: ubuntu-22.04 |
| 966 |
target: armv7 |
| 967 |
steps: |
| 968 |
- uses: actions/checkout@v4 |
| 969 |
- uses: actions/setup-python@v5 |
| 970 |
with: |
| 971 |
python-version: 3.x |
| 972 |
- name: Build wheels |
| 973 |
uses: PyO3/maturin-action@v1 |
| 974 |
with: |
| 975 |
target: ${{ matrix.platform.target }} |
| 976 |
args: --release --out dist |
| 977 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 978 |
manylinux: musllinux_1_2 |
| 979 |
- name: Build free-threaded wheels |
| 980 |
uses: PyO3/maturin-action@v1 |
| 981 |
with: |
| 982 |
target: ${{ matrix.platform.target }} |
| 983 |
args: --release --out dist -i python3.13t |
| 984 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 985 |
manylinux: musllinux_1_2 |
| 986 |
- name: Upload wheels |
| 987 |
uses: actions/upload-artifact@v4 |
| 988 |
with: |
| 989 |
name: wheels-musllinux-${{ matrix.platform.target }} |
| 990 |
path: dist |
| 991 |
|
| 992 |
windows: |
| 993 |
runs-on: ${{ matrix.platform.runner }} |
| 994 |
strategy: |
| 995 |
matrix: |
| 996 |
platform: |
| 997 |
- runner: windows-latest |
| 998 |
target: x64 |
| 999 |
- runner: windows-latest |
| 1000 |
target: x86 |
| 1001 |
steps: |
| 1002 |
- uses: actions/checkout@v4 |
| 1003 |
- uses: actions/setup-python@v5 |
| 1004 |
with: |
| 1005 |
python-version: 3.x |
| 1006 |
architecture: ${{ matrix.platform.target }} |
| 1007 |
- name: Build wheels |
| 1008 |
uses: PyO3/maturin-action@v1 |
| 1009 |
with: |
| 1010 |
target: ${{ matrix.platform.target }} |
| 1011 |
args: --release --out dist |
| 1012 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1013 |
- uses: actions/setup-python@v5 |
| 1014 |
with: |
| 1015 |
python-version: 3.13t |
| 1016 |
architecture: ${{ matrix.platform.target }} |
| 1017 |
- name: Build free-threaded wheels |
| 1018 |
uses: PyO3/maturin-action@v1 |
| 1019 |
with: |
| 1020 |
target: ${{ matrix.platform.target }} |
| 1021 |
args: --release --out dist -i python3.13t |
| 1022 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1023 |
- name: Upload wheels |
| 1024 |
uses: actions/upload-artifact@v4 |
| 1025 |
with: |
| 1026 |
name: wheels-windows-${{ matrix.platform.target }} |
| 1027 |
path: dist |
| 1028 |
|
| 1029 |
macos: |
| 1030 |
runs-on: ${{ matrix.platform.runner }} |
| 1031 |
strategy: |
| 1032 |
matrix: |
| 1033 |
platform: |
| 1034 |
- runner: macos-13 |
| 1035 |
target: x86_64 |
| 1036 |
- runner: macos-14 |
| 1037 |
target: aarch64 |
| 1038 |
steps: |
| 1039 |
- uses: actions/checkout@v4 |
| 1040 |
- uses: actions/setup-python@v5 |
| 1041 |
with: |
| 1042 |
python-version: 3.x |
| 1043 |
- name: Build wheels |
| 1044 |
uses: PyO3/maturin-action@v1 |
| 1045 |
with: |
| 1046 |
target: ${{ matrix.platform.target }} |
| 1047 |
args: --release --out dist |
| 1048 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1049 |
- name: Build free-threaded wheels |
| 1050 |
uses: PyO3/maturin-action@v1 |
| 1051 |
with: |
| 1052 |
target: ${{ matrix.platform.target }} |
| 1053 |
args: --release --out dist -i python3.13t |
| 1054 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1055 |
- name: Upload wheels |
| 1056 |
uses: actions/upload-artifact@v4 |
| 1057 |
with: |
| 1058 |
name: wheels-macos-${{ matrix.platform.target }} |
| 1059 |
path: dist |
| 1060 |
|
| 1061 |
release: |
| 1062 |
name: Release |
| 1063 |
runs-on: ubuntu-latest |
| 1064 |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 1065 |
needs: [linux, musllinux, windows, macos] |
| 1066 |
permissions: |
| 1067 |
# Use to sign the release artifacts |
| 1068 |
id-token: write |
| 1069 |
# Used to upload release artifacts |
| 1070 |
contents: write |
| 1071 |
# Used to generate artifact attestation |
| 1072 |
attestations: write |
| 1073 |
steps: |
| 1074 |
- uses: actions/download-artifact@v4 |
| 1075 |
- name: Generate artifact attestation |
| 1076 |
uses: actions/attest-build-provenance@v2 |
| 1077 |
with: |
| 1078 |
subject-path: 'wheels-*/*' |
| 1079 |
- name: Publish to PyPI |
| 1080 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 1081 |
uses: PyO3/maturin-action@v1 |
| 1082 |
env: |
| 1083 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 1084 |
with: |
| 1085 |
command: upload |
| 1086 |
args: --non-interactive --skip-existing wheels-*/*"#]]; |
| 1087 |
expected.assert_eq(&conf); |
| 1088 |
} |
| 1089 |
|
| 1090 |
#[test] |
| 1091 |
fn test_generate_github_no_attestations() { |
| 1092 |
let conf = GenerateCI { |
| 1093 |
skip_attestation: true, |
| 1094 |
..Default::default() |
| 1095 |
} |
| 1096 |
.generate_github( |
| 1097 |
"example", |
| 1098 |
&BridgeModel::PyO3(PyO3 { |
| 1099 |
crate_name: PyO3Crate::PyO3, |
| 1100 |
version: Version::new(0, 23, 0), |
| 1101 |
abi3: Some(Abi3Version::Version(3, 7)), |
| 1102 |
metadata: None, |
| 1103 |
}), |
| 1104 |
false, |
| 1105 |
) |
| 1106 |
.unwrap() |
| 1107 |
.lines() |
| 1108 |
.skip(5) |
| 1109 |
.collect::<Vec<_>>() |
| 1110 |
.join("\n"); |
| 1111 |
let expected = expect![[r#" |
| 1112 |
name: CI |
| 1113 |
|
| 1114 |
on: |
| 1115 |
push: |
| 1116 |
branches: |
| 1117 |
- main |
| 1118 |
- master |
| 1119 |
tags: |
| 1120 |
- '*' |
| 1121 |
pull_request: |
| 1122 |
workflow_dispatch: |
| 1123 |
|
| 1124 |
permissions: |
| 1125 |
contents: read |
| 1126 |
|
| 1127 |
jobs: |
| 1128 |
linux: |
| 1129 |
runs-on: ${{ matrix.platform.runner }} |
| 1130 |
strategy: |
| 1131 |
matrix: |
| 1132 |
platform: |
| 1133 |
- runner: ubuntu-22.04 |
| 1134 |
target: x86_64 |
| 1135 |
- runner: ubuntu-22.04 |
| 1136 |
target: x86 |
| 1137 |
- runner: ubuntu-22.04 |
| 1138 |
target: aarch64 |
| 1139 |
- runner: ubuntu-22.04 |
| 1140 |
target: armv7 |
| 1141 |
- runner: ubuntu-22.04 |
| 1142 |
target: s390x |
| 1143 |
- runner: ubuntu-22.04 |
| 1144 |
target: ppc64le |
| 1145 |
steps: |
| 1146 |
- uses: actions/checkout@v4 |
| 1147 |
- uses: actions/setup-python@v5 |
| 1148 |
with: |
| 1149 |
python-version: 3.x |
| 1150 |
- name: Build wheels |
| 1151 |
uses: PyO3/maturin-action@v1 |
| 1152 |
with: |
| 1153 |
target: ${{ matrix.platform.target }} |
| 1154 |
args: --release --out dist |
| 1155 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1156 |
manylinux: auto |
| 1157 |
- name: Build free-threaded wheels |
| 1158 |
uses: PyO3/maturin-action@v1 |
| 1159 |
with: |
| 1160 |
target: ${{ matrix.platform.target }} |
| 1161 |
args: --release --out dist -i python3.13t |
| 1162 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1163 |
manylinux: auto |
| 1164 |
- name: Upload wheels |
| 1165 |
uses: actions/upload-artifact@v4 |
| 1166 |
with: |
| 1167 |
name: wheels-linux-${{ matrix.platform.target }} |
| 1168 |
path: dist |
| 1169 |
|
| 1170 |
musllinux: |
| 1171 |
runs-on: ${{ matrix.platform.runner }} |
| 1172 |
strategy: |
| 1173 |
matrix: |
| 1174 |
platform: |
| 1175 |
- runner: ubuntu-22.04 |
| 1176 |
target: x86_64 |
| 1177 |
- runner: ubuntu-22.04 |
| 1178 |
target: x86 |
| 1179 |
- runner: ubuntu-22.04 |
| 1180 |
target: aarch64 |
| 1181 |
- runner: ubuntu-22.04 |
| 1182 |
target: armv7 |
| 1183 |
steps: |
| 1184 |
- uses: actions/checkout@v4 |
| 1185 |
- uses: actions/setup-python@v5 |
| 1186 |
with: |
| 1187 |
python-version: 3.x |
| 1188 |
- name: Build wheels |
| 1189 |
uses: PyO3/maturin-action@v1 |
| 1190 |
with: |
| 1191 |
target: ${{ matrix.platform.target }} |
| 1192 |
args: --release --out dist |
| 1193 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1194 |
manylinux: musllinux_1_2 |
| 1195 |
- name: Build free-threaded wheels |
| 1196 |
uses: PyO3/maturin-action@v1 |
| 1197 |
with: |
| 1198 |
target: ${{ matrix.platform.target }} |
| 1199 |
args: --release --out dist -i python3.13t |
| 1200 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1201 |
manylinux: musllinux_1_2 |
| 1202 |
- name: Upload wheels |
| 1203 |
uses: actions/upload-artifact@v4 |
| 1204 |
with: |
| 1205 |
name: wheels-musllinux-${{ matrix.platform.target }} |
| 1206 |
path: dist |
| 1207 |
|
| 1208 |
windows: |
| 1209 |
runs-on: ${{ matrix.platform.runner }} |
| 1210 |
strategy: |
| 1211 |
matrix: |
| 1212 |
platform: |
| 1213 |
- runner: windows-latest |
| 1214 |
target: x64 |
| 1215 |
- runner: windows-latest |
| 1216 |
target: x86 |
| 1217 |
steps: |
| 1218 |
- uses: actions/checkout@v4 |
| 1219 |
- uses: actions/setup-python@v5 |
| 1220 |
with: |
| 1221 |
python-version: 3.x |
| 1222 |
architecture: ${{ matrix.platform.target }} |
| 1223 |
- name: Build wheels |
| 1224 |
uses: PyO3/maturin-action@v1 |
| 1225 |
with: |
| 1226 |
target: ${{ matrix.platform.target }} |
| 1227 |
args: --release --out dist |
| 1228 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1229 |
- uses: actions/setup-python@v5 |
| 1230 |
with: |
| 1231 |
python-version: 3.13t |
| 1232 |
architecture: ${{ matrix.platform.target }} |
| 1233 |
- name: Build free-threaded wheels |
| 1234 |
uses: PyO3/maturin-action@v1 |
| 1235 |
with: |
| 1236 |
target: ${{ matrix.platform.target }} |
| 1237 |
args: --release --out dist -i python3.13t |
| 1238 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1239 |
- name: Upload wheels |
| 1240 |
uses: actions/upload-artifact@v4 |
| 1241 |
with: |
| 1242 |
name: wheels-windows-${{ matrix.platform.target }} |
| 1243 |
path: dist |
| 1244 |
|
| 1245 |
macos: |
| 1246 |
runs-on: ${{ matrix.platform.runner }} |
| 1247 |
strategy: |
| 1248 |
matrix: |
| 1249 |
platform: |
| 1250 |
- runner: macos-13 |
| 1251 |
target: x86_64 |
| 1252 |
- runner: macos-14 |
| 1253 |
target: aarch64 |
| 1254 |
steps: |
| 1255 |
- uses: actions/checkout@v4 |
| 1256 |
- uses: actions/setup-python@v5 |
| 1257 |
with: |
| 1258 |
python-version: 3.x |
| 1259 |
- name: Build wheels |
| 1260 |
uses: PyO3/maturin-action@v1 |
| 1261 |
with: |
| 1262 |
target: ${{ matrix.platform.target }} |
| 1263 |
args: --release --out dist |
| 1264 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1265 |
- name: Build free-threaded wheels |
| 1266 |
uses: PyO3/maturin-action@v1 |
| 1267 |
with: |
| 1268 |
target: ${{ matrix.platform.target }} |
| 1269 |
args: --release --out dist -i python3.13t |
| 1270 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1271 |
- name: Upload wheels |
| 1272 |
uses: actions/upload-artifact@v4 |
| 1273 |
with: |
| 1274 |
name: wheels-macos-${{ matrix.platform.target }} |
| 1275 |
path: dist |
| 1276 |
|
| 1277 |
release: |
| 1278 |
name: Release |
| 1279 |
runs-on: ubuntu-latest |
| 1280 |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 1281 |
needs: [linux, musllinux, windows, macos] |
| 1282 |
permissions: |
| 1283 |
# Use to sign the release artifacts |
| 1284 |
id-token: write |
| 1285 |
# Used to upload release artifacts |
| 1286 |
contents: write |
| 1287 |
steps: |
| 1288 |
- uses: actions/download-artifact@v4 |
| 1289 |
- name: Publish to PyPI |
| 1290 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 1291 |
uses: PyO3/maturin-action@v1 |
| 1292 |
env: |
| 1293 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 1294 |
with: |
| 1295 |
command: upload |
| 1296 |
args: --non-interactive --skip-existing wheels-*/*"#]]; |
| 1297 |
expected.assert_eq(&conf); |
| 1298 |
} |
| 1299 |
|
| 1300 |
#[test] |
| 1301 |
fn test_generate_github_zig_pytest() { |
| 1302 |
let gen = GenerateCI { |
| 1303 |
zig: true, |
| 1304 |
pytest: true, |
| 1305 |
..Default::default() |
| 1306 |
}; |
| 1307 |
let conf = gen |
| 1308 |
.generate_github( |
| 1309 |
"example", |
| 1310 |
&BridgeModel::PyO3(PyO3 { |
| 1311 |
crate_name: PyO3Crate::PyO3, |
| 1312 |
version: Version::new(0, 23, 0), |
| 1313 |
abi3: None, |
| 1314 |
metadata: None, |
| 1315 |
}), |
| 1316 |
true, |
| 1317 |
) |
| 1318 |
.unwrap() |
| 1319 |
.lines() |
| 1320 |
.skip(5) |
| 1321 |
.collect::<Vec<_>>() |
| 1322 |
.join("\n"); |
| 1323 |
let expected = expect![[r#" |
| 1324 |
name: CI |
| 1325 |
|
| 1326 |
on: |
| 1327 |
push: |
| 1328 |
branches: |
| 1329 |
- main |
| 1330 |
- master |
| 1331 |
tags: |
| 1332 |
- '*' |
| 1333 |
pull_request: |
| 1334 |
workflow_dispatch: |
| 1335 |
|
| 1336 |
permissions: |
| 1337 |
contents: read |
| 1338 |
|
| 1339 |
jobs: |
| 1340 |
linux: |
| 1341 |
runs-on: ${{ matrix.platform.runner }} |
| 1342 |
strategy: |
| 1343 |
matrix: |
| 1344 |
platform: |
| 1345 |
- runner: ubuntu-22.04 |
| 1346 |
target: x86_64 |
| 1347 |
- runner: ubuntu-22.04 |
| 1348 |
target: x86 |
| 1349 |
- runner: ubuntu-22.04 |
| 1350 |
target: aarch64 |
| 1351 |
- runner: ubuntu-22.04 |
| 1352 |
target: armv7 |
| 1353 |
- runner: ubuntu-22.04 |
| 1354 |
target: s390x |
| 1355 |
- runner: ubuntu-22.04 |
| 1356 |
target: ppc64le |
| 1357 |
steps: |
| 1358 |
- uses: actions/checkout@v4 |
| 1359 |
- uses: actions/setup-python@v5 |
| 1360 |
with: |
| 1361 |
python-version: 3.x |
| 1362 |
- name: Build wheels |
| 1363 |
uses: PyO3/maturin-action@v1 |
| 1364 |
with: |
| 1365 |
target: ${{ matrix.platform.target }} |
| 1366 |
args: --release --out dist --find-interpreter --zig |
| 1367 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1368 |
manylinux: auto |
| 1369 |
- name: Upload wheels |
| 1370 |
uses: actions/upload-artifact@v4 |
| 1371 |
with: |
| 1372 |
name: wheels-linux-${{ matrix.platform.target }} |
| 1373 |
path: dist |
| 1374 |
- name: pytest |
| 1375 |
if: ${{ startsWith(matrix.platform.target, 'x86_64') }} |
| 1376 |
shell: bash |
| 1377 |
run: | |
| 1378 |
set -e |
| 1379 |
python3 -m venv .venv |
| 1380 |
source .venv/bin/activate |
| 1381 |
pip install example --find-links dist --force-reinstall |
| 1382 |
pip install pytest |
| 1383 |
pytest |
| 1384 |
- name: pytest |
| 1385 |
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }} |
| 1386 |
uses: uraimo/run-on-arch-action@v2 |
| 1387 |
with: |
| 1388 |
arch: ${{ matrix.platform.target }} |
| 1389 |
distro: ubuntu22.04 |
| 1390 |
githubToken: ${{ github.token }} |
| 1391 |
install: | |
| 1392 |
apt-get update |
| 1393 |
apt-get install -y --no-install-recommends python3 python3-pip |
| 1394 |
pip3 install -U pip pytest |
| 1395 |
run: | |
| 1396 |
set -e |
| 1397 |
pip3 install example --find-links dist --force-reinstall |
| 1398 |
pytest |
| 1399 |
|
| 1400 |
musllinux: |
| 1401 |
runs-on: ${{ matrix.platform.runner }} |
| 1402 |
strategy: |
| 1403 |
matrix: |
| 1404 |
platform: |
| 1405 |
- runner: ubuntu-22.04 |
| 1406 |
target: x86_64 |
| 1407 |
- runner: ubuntu-22.04 |
| 1408 |
target: x86 |
| 1409 |
- runner: ubuntu-22.04 |
| 1410 |
target: aarch64 |
| 1411 |
- runner: ubuntu-22.04 |
| 1412 |
target: armv7 |
| 1413 |
steps: |
| 1414 |
- uses: actions/checkout@v4 |
| 1415 |
- uses: actions/setup-python@v5 |
| 1416 |
with: |
| 1417 |
python-version: 3.x |
| 1418 |
- name: Build wheels |
| 1419 |
uses: PyO3/maturin-action@v1 |
| 1420 |
with: |
| 1421 |
target: ${{ matrix.platform.target }} |
| 1422 |
args: --release --out dist --find-interpreter |
| 1423 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1424 |
manylinux: musllinux_1_2 |
| 1425 |
- name: Upload wheels |
| 1426 |
uses: actions/upload-artifact@v4 |
| 1427 |
with: |
| 1428 |
name: wheels-musllinux-${{ matrix.platform.target }} |
| 1429 |
path: dist |
| 1430 |
- name: pytest |
| 1431 |
if: ${{ startsWith(matrix.platform.target, 'x86_64') }} |
| 1432 |
uses: addnab/docker-run-action@v3 |
| 1433 |
with: |
| 1434 |
image: alpine:latest |
| 1435 |
options: -v ${{ github.workspace }}:/io -w /io |
| 1436 |
run: | |
| 1437 |
set -e |
| 1438 |
apk add py3-pip py3-virtualenv |
| 1439 |
python3 -m virtualenv .venv |
| 1440 |
source .venv/bin/activate |
| 1441 |
pip install example --no-index --find-links dist --force-reinstall |
| 1442 |
pip install pytest |
| 1443 |
pytest |
| 1444 |
- name: pytest |
| 1445 |
if: ${{ !startsWith(matrix.platform.target, 'x86') }} |
| 1446 |
uses: uraimo/run-on-arch-action@v2 |
| 1447 |
with: |
| 1448 |
arch: ${{ matrix.platform.target }} |
| 1449 |
distro: alpine_latest |
| 1450 |
githubToken: ${{ github.token }} |
| 1451 |
install: | |
| 1452 |
apk add py3-virtualenv |
| 1453 |
run: | |
| 1454 |
set -e |
| 1455 |
python3 -m virtualenv .venv |
| 1456 |
source .venv/bin/activate |
| 1457 |
pip install pytest |
| 1458 |
pip install example --find-links dist --force-reinstall |
| 1459 |
pytest |
| 1460 |
|
| 1461 |
windows: |
| 1462 |
runs-on: ${{ matrix.platform.runner }} |
| 1463 |
strategy: |
| 1464 |
matrix: |
| 1465 |
platform: |
| 1466 |
- runner: windows-latest |
| 1467 |
target: x64 |
| 1468 |
- runner: windows-latest |
| 1469 |
target: x86 |
| 1470 |
steps: |
| 1471 |
- uses: actions/checkout@v4 |
| 1472 |
- uses: actions/setup-python@v5 |
| 1473 |
with: |
| 1474 |
python-version: 3.x |
| 1475 |
architecture: ${{ matrix.platform.target }} |
| 1476 |
- name: Build wheels |
| 1477 |
uses: PyO3/maturin-action@v1 |
| 1478 |
with: |
| 1479 |
target: ${{ matrix.platform.target }} |
| 1480 |
args: --release --out dist --find-interpreter |
| 1481 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1482 |
- name: Upload wheels |
| 1483 |
uses: actions/upload-artifact@v4 |
| 1484 |
with: |
| 1485 |
name: wheels-windows-${{ matrix.platform.target }} |
| 1486 |
path: dist |
| 1487 |
- name: pytest |
| 1488 |
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }} |
| 1489 |
shell: bash |
| 1490 |
run: | |
| 1491 |
set -e |
| 1492 |
python3 -m venv .venv |
| 1493 |
source .venv/Scripts/activate |
| 1494 |
pip install example --find-links dist --force-reinstall |
| 1495 |
pip install pytest |
| 1496 |
pytest |
| 1497 |
|
| 1498 |
macos: |
| 1499 |
runs-on: ${{ matrix.platform.runner }} |
| 1500 |
strategy: |
| 1501 |
matrix: |
| 1502 |
platform: |
| 1503 |
- runner: macos-13 |
| 1504 |
target: x86_64 |
| 1505 |
- runner: macos-14 |
| 1506 |
target: aarch64 |
| 1507 |
steps: |
| 1508 |
- uses: actions/checkout@v4 |
| 1509 |
- uses: actions/setup-python@v5 |
| 1510 |
with: |
| 1511 |
python-version: 3.x |
| 1512 |
- name: Build wheels |
| 1513 |
uses: PyO3/maturin-action@v1 |
| 1514 |
with: |
| 1515 |
target: ${{ matrix.platform.target }} |
| 1516 |
args: --release --out dist --find-interpreter |
| 1517 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1518 |
- name: Upload wheels |
| 1519 |
uses: actions/upload-artifact@v4 |
| 1520 |
with: |
| 1521 |
name: wheels-macos-${{ matrix.platform.target }} |
| 1522 |
path: dist |
| 1523 |
- name: pytest |
| 1524 |
run: | |
| 1525 |
set -e |
| 1526 |
python3 -m venv .venv |
| 1527 |
source .venv/bin/activate |
| 1528 |
pip install example --find-links dist --force-reinstall |
| 1529 |
pip install pytest |
| 1530 |
pytest |
| 1531 |
|
| 1532 |
sdist: |
| 1533 |
runs-on: ubuntu-latest |
| 1534 |
steps: |
| 1535 |
- uses: actions/checkout@v4 |
| 1536 |
- name: Build sdist |
| 1537 |
uses: PyO3/maturin-action@v1 |
| 1538 |
with: |
| 1539 |
command: sdist |
| 1540 |
args: --out dist |
| 1541 |
- name: Upload sdist |
| 1542 |
uses: actions/upload-artifact@v4 |
| 1543 |
with: |
| 1544 |
name: wheels-sdist |
| 1545 |
path: dist |
| 1546 |
|
| 1547 |
release: |
| 1548 |
name: Release |
| 1549 |
runs-on: ubuntu-latest |
| 1550 |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 1551 |
needs: [linux, musllinux, windows, macos, sdist] |
| 1552 |
permissions: |
| 1553 |
# Use to sign the release artifacts |
| 1554 |
id-token: write |
| 1555 |
# Used to upload release artifacts |
| 1556 |
contents: write |
| 1557 |
# Used to generate artifact attestation |
| 1558 |
attestations: write |
| 1559 |
steps: |
| 1560 |
- uses: actions/download-artifact@v4 |
| 1561 |
- name: Generate artifact attestation |
| 1562 |
uses: actions/attest-build-provenance@v2 |
| 1563 |
with: |
| 1564 |
subject-path: 'wheels-*/*' |
| 1565 |
- name: Publish to PyPI |
| 1566 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 1567 |
uses: PyO3/maturin-action@v1 |
| 1568 |
env: |
| 1569 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 1570 |
with: |
| 1571 |
command: upload |
| 1572 |
args: --non-interactive --skip-existing wheels-*/*"#]]; |
| 1573 |
expected.assert_eq(&conf); |
| 1574 |
} |
| 1575 |
|
| 1576 |
#[test] |
| 1577 |
fn test_generate_github_bin_no_binding() { |
| 1578 |
let conf = GenerateCI::default() |
| 1579 |
.generate_github("example", &BridgeModel::Bin(None), true) |
| 1580 |
.unwrap() |
| 1581 |
.lines() |
| 1582 |
.skip(5) |
| 1583 |
.collect::<Vec<_>>() |
| 1584 |
.join("\n"); |
| 1585 |
let expected = expect![[r#" |
| 1586 |
name: CI |
| 1587 |
|
| 1588 |
on: |
| 1589 |
push: |
| 1590 |
branches: |
| 1591 |
- main |
| 1592 |
- master |
| 1593 |
tags: |
| 1594 |
- '*' |
| 1595 |
pull_request: |
| 1596 |
workflow_dispatch: |
| 1597 |
|
| 1598 |
permissions: |
| 1599 |
contents: read |
| 1600 |
|
| 1601 |
jobs: |
| 1602 |
linux: |
| 1603 |
runs-on: ${{ matrix.platform.runner }} |
| 1604 |
strategy: |
| 1605 |
matrix: |
| 1606 |
platform: |
| 1607 |
- runner: ubuntu-22.04 |
| 1608 |
target: x86_64 |
| 1609 |
- runner: ubuntu-22.04 |
| 1610 |
target: x86 |
| 1611 |
- runner: ubuntu-22.04 |
| 1612 |
target: aarch64 |
| 1613 |
- runner: ubuntu-22.04 |
| 1614 |
target: armv7 |
| 1615 |
- runner: ubuntu-22.04 |
| 1616 |
target: s390x |
| 1617 |
- runner: ubuntu-22.04 |
| 1618 |
target: ppc64le |
| 1619 |
steps: |
| 1620 |
- uses: actions/checkout@v4 |
| 1621 |
- name: Build wheels |
| 1622 |
uses: PyO3/maturin-action@v1 |
| 1623 |
with: |
| 1624 |
target: ${{ matrix.platform.target }} |
| 1625 |
args: --release --out dist |
| 1626 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1627 |
manylinux: auto |
| 1628 |
- name: Upload wheels |
| 1629 |
uses: actions/upload-artifact@v4 |
| 1630 |
with: |
| 1631 |
name: wheels-linux-${{ matrix.platform.target }} |
| 1632 |
path: dist |
| 1633 |
|
| 1634 |
musllinux: |
| 1635 |
runs-on: ${{ matrix.platform.runner }} |
| 1636 |
strategy: |
| 1637 |
matrix: |
| 1638 |
platform: |
| 1639 |
- runner: ubuntu-22.04 |
| 1640 |
target: x86_64 |
| 1641 |
- runner: ubuntu-22.04 |
| 1642 |
target: x86 |
| 1643 |
- runner: ubuntu-22.04 |
| 1644 |
target: aarch64 |
| 1645 |
- runner: ubuntu-22.04 |
| 1646 |
target: armv7 |
| 1647 |
steps: |
| 1648 |
- uses: actions/checkout@v4 |
| 1649 |
- name: Build wheels |
| 1650 |
uses: PyO3/maturin-action@v1 |
| 1651 |
with: |
| 1652 |
target: ${{ matrix.platform.target }} |
| 1653 |
args: --release --out dist |
| 1654 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1655 |
manylinux: musllinux_1_2 |
| 1656 |
- name: Upload wheels |
| 1657 |
uses: actions/upload-artifact@v4 |
| 1658 |
with: |
| 1659 |
name: wheels-musllinux-${{ matrix.platform.target }} |
| 1660 |
path: dist |
| 1661 |
|
| 1662 |
windows: |
| 1663 |
runs-on: ${{ matrix.platform.runner }} |
| 1664 |
strategy: |
| 1665 |
matrix: |
| 1666 |
platform: |
| 1667 |
- runner: windows-latest |
| 1668 |
target: x64 |
| 1669 |
- runner: windows-latest |
| 1670 |
target: x86 |
| 1671 |
steps: |
| 1672 |
- uses: actions/checkout@v4 |
| 1673 |
- name: Build wheels |
| 1674 |
uses: PyO3/maturin-action@v1 |
| 1675 |
with: |
| 1676 |
target: ${{ matrix.platform.target }} |
| 1677 |
args: --release --out dist |
| 1678 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1679 |
- name: Upload wheels |
| 1680 |
uses: actions/upload-artifact@v4 |
| 1681 |
with: |
| 1682 |
name: wheels-windows-${{ matrix.platform.target }} |
| 1683 |
path: dist |
| 1684 |
|
| 1685 |
macos: |
| 1686 |
runs-on: ${{ matrix.platform.runner }} |
| 1687 |
strategy: |
| 1688 |
matrix: |
| 1689 |
platform: |
| 1690 |
- runner: macos-13 |
| 1691 |
target: x86_64 |
| 1692 |
- runner: macos-14 |
| 1693 |
target: aarch64 |
| 1694 |
steps: |
| 1695 |
- uses: actions/checkout@v4 |
| 1696 |
- name: Build wheels |
| 1697 |
uses: PyO3/maturin-action@v1 |
| 1698 |
with: |
| 1699 |
target: ${{ matrix.platform.target }} |
| 1700 |
args: --release --out dist |
| 1701 |
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 1702 |
- name: Upload wheels |
| 1703 |
uses: actions/upload-artifact@v4 |
| 1704 |
with: |
| 1705 |
name: wheels-macos-${{ matrix.platform.target }} |
| 1706 |
path: dist |
| 1707 |
|
| 1708 |
sdist: |
| 1709 |
runs-on: ubuntu-latest |
| 1710 |
steps: |
| 1711 |
- uses: actions/checkout@v4 |
| 1712 |
- name: Build sdist |
| 1713 |
uses: PyO3/maturin-action@v1 |
| 1714 |
with: |
| 1715 |
command: sdist |
| 1716 |
args: --out dist |
| 1717 |
- name: Upload sdist |
| 1718 |
uses: actions/upload-artifact@v4 |
| 1719 |
with: |
| 1720 |
name: wheels-sdist |
| 1721 |
path: dist |
| 1722 |
|
| 1723 |
release: |
| 1724 |
name: Release |
| 1725 |
runs-on: ubuntu-latest |
| 1726 |
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }} |
| 1727 |
needs: [linux, musllinux, windows, macos, sdist] |
| 1728 |
permissions: |
| 1729 |
# Use to sign the release artifacts |
| 1730 |
id-token: write |
| 1731 |
# Used to upload release artifacts |
| 1732 |
contents: write |
| 1733 |
# Used to generate artifact attestation |
| 1734 |
attestations: write |
| 1735 |
steps: |
| 1736 |
- uses: actions/download-artifact@v4 |
| 1737 |
- name: Generate artifact attestation |
| 1738 |
uses: actions/attest-build-provenance@v2 |
| 1739 |
with: |
| 1740 |
subject-path: 'wheels-*/*' |
| 1741 |
- name: Publish to PyPI |
| 1742 |
if: ${{ startsWith(github.ref, 'refs/tags/') }} |
| 1743 |
uses: PyO3/maturin-action@v1 |
| 1744 |
env: |
| 1745 |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 1746 |
with: |
| 1747 |
command: upload |
| 1748 |
args: --non-interactive --skip-existing wheels-*/*"#]]; |
| 1749 |
expected.assert_eq(&conf); |
| 1750 |
} |
| 1751 |
} |