-
-
Notifications
You must be signed in to change notification settings - Fork 8
105 lines (82 loc) · 2.75 KB
/
python_publish.yaml
File metadata and controls
105 lines (82 loc) · 2.75 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
name: Publish Python distributions
permissions:
contents: read
# This workflow builds wheels for all platforms (Windows, Linux, macOS) and Python versions (3.10-3.13)
# and publishes to PyPI when a release is created or when manually triggered
on:
workflow_dispatch:
release:
types: [created, published]
jobs:
build-wheels:
name: Build wheels for ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install uv
run: |
python -m pip install --upgrade pip
pip install uv
- name: Install dependencies with uv
run: |
uv pip install --system maturin
- name: Build wheels
run: |
maturin build --release --strip
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
path: target/wheels/*.whl
build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python 3.12
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install maturin
- name: Build source distribution
run: maturin sdist
- name: Upload source distribution
uses: actions/upload-artifact@v4
with:
name: sdist
path: target/wheels/*.tar.gz
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build-wheels, build-sdist]
if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch'
permissions:
id-token: write # Required for trusted publishing to PyPI
contents: read
steps:
- uses: actions/download-artifact@v4
with:
path: dist/
- name: Flatten artifacts
run: |
find dist/ -type f \( -name "*.whl" -o -name "*.tar.gz" \) -exec mv {} dist/ \;
find dist/ -mindepth 1 -type d -exec rm -rf {} +
- name: List dist contents
run: ls -la dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1