-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (103 loc) · 3.13 KB
/
Copy pathpython-release.yaml
File metadata and controls
117 lines (103 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Publish Python Package
on:
push:
tags:
- "v*"
permissions:
contents: read
id-token: write
jobs:
build-wheels:
name: Build wheel (${{ matrix.name }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
- name: macos-arm64
os: macos-14
target: aarch64-apple-darwin
env:
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_REF: ${{ github.ref }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ env.RELEASE_REF }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Sync versions to release tag
shell: bash
run: |
python - <<'PY'
import os
import re
from pathlib import Path
tag = os.environ.get("RELEASE_TAG", "")
if not tag:
raise SystemExit("RELEASE_TAG is empty; expected a v* tag push.")
version = tag[1:] if tag.startswith("v") else tag
for path in ("rust/Cargo.toml", "pyproject.toml"):
file_path = Path(path)
text = file_path.read_text(encoding="utf-8")
updated, count = re.subn(
r'^version = ".*"$',
f'version = "{version}"',
text,
count=1,
flags=re.MULTILINE,
)
if count != 1:
raise SystemExit(f"Could not update version in {path}")
file_path.write_text(updated, encoding="utf-8")
PY
- name: Build wheel (Linux)
if: runner.os == 'Linux'
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ matrix.target }}
manylinux: "2_28"
args: --release --manifest-path rust/Cargo.toml --features python --out dist
- name: Build wheel (non-Linux)
if: runner.os != 'Linux'
uses: PyO3/maturin-action@v1
with:
command: build
target: ${{ matrix.target }}
args: --release --manifest-path rust/Cargo.toml --features python --out dist
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.name }}
path: dist/*.whl
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: build-wheels
environment: pypi
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: Verify dist locally (act)
if: ${{ env.ACT }}
run: ls -la dist
- name: Publish to PyPI
if: ${{ !env.ACT }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist