Repository navigation
137 lines (119 loc) · 4.28 KB
/
Copy pathrelease.yml
File metadata and controls
137 lines (119 loc) · 4.28 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Release
# Builds abi3 wheels (one per platform, any Python >= 3.9) and an sdist, tests each
# wheel, and publishes to PyPI when a version tag is pushed.
#
# - pull requests touching packaging: build + test only, nothing is published
# - workflow_dispatch: same, on demand
# - tag vX.Y.Z (must match the version in Cargo.toml): build, test, publish
on:
push:
tags: ["v*"]
pull_request:
paths:
- .github/workflows/release.yml
- pyproject.toml
- Cargo.toml
- Cargo.lock
workflow_dispatch:
permissions:
contents: read
jobs:
wheels:
name: wheel ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.runner }}
strategy:
fail-fast: false
matrix:
platform:
- { name: linux-x86_64, runner: ubuntu-latest, target: x86_64, manylinux: "2_28", test: true }
- { name: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64, manylinux: "2_28", test: true }
- { name: macos-arm64, runner: macos-14, target: aarch64-apple-darwin, test: true }
# cross-compiled on the arm64 runner, so it can't be run here
- { name: macos-x86_64, runner: macos-14, target: x86_64-apple-darwin, test: false }
- { name: windows-x86_64, runner: windows-latest, target: x64, test: true }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Build wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: ${{ matrix.platform.manylinux || 'auto' }}
args: --release --locked --out dist
# the abi3 wheel is tested on the oldest and newest supported Pythons
- uses: actions/setup-python@v5
id: py-oldest
if: matrix.platform.test
with:
python-version: "3.9"
- uses: actions/setup-python@v5
id: py-newest
if: matrix.platform.test
with:
python-version: "3.13"
# runs from outside the repo so the installed wheel is imported, not the source tree
- name: Test wheel
if: matrix.platform.test
shell: bash
env:
PYTHONS: ${{ steps.py-oldest.outputs.python-path }};${{ steps.py-newest.outputs.python-path }}
run: |
IFS=';' read -ra pythons <<< "$PYTHONS"
for py in "${pythons[@]}"; do
echo "::group::$py"
venv="$RUNNER_TEMP/venv-$("$py" -c 'import sys; print("%d%d" % sys.version_info[:2])')"
"$py" -m venv "$venv"
bin="$venv/bin"; [ "$RUNNER_OS" = "Windows" ] && bin="$venv/Scripts"
"$bin/python" -m pip install -q dist/*.whl onnx onnxruntime
cd "$RUNNER_TEMP"
"$bin/python" -c "import sys, burn_python as b; print(sys.version, b.__version__, b.available_backends())"
"$bin/python" "$GITHUB_WORKSPACE/tests/test_ops.py"
cd "$GITHUB_WORKSPACE"
echo "::endgroup::"
done
- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.platform.name }}
path: dist/*.whl
sdist:
name: sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
publish:
name: publish to PyPI
if: startsWith(github.ref, 'refs/tags/v')
needs: [wheels, sdist]
runs-on: ubuntu-latest
# PyPI trusted publishing: no API token, PyPI trusts this workflow + environment
environment:
name: pypi
url: https://pypi.org/p/burn-python
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Check tag matches Cargo.toml version
run: |
version=$(grep -m1 '^version' Cargo.toml | cut -d'"' -f2)
if [ "v$version" != "$GITHUB_REF_NAME" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match Cargo.toml version $version"
exit 1
fi
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- run: ls -la dist
- uses: pypa/gh-action-pypi-publish@release/v1