-
Notifications
You must be signed in to change notification settings - Fork 1
163 lines (142 loc) · 4.46 KB
/
Copy pathpublish-dev.yml
File metadata and controls
163 lines (142 loc) · 4.46 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Publish Dev Build
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches: [ main ]
workflow_dispatch: # Allow manual triggering for testing
jobs:
get-version:
name: Get dev version
runs-on: ubuntu-latest
# Only run if CI succeeded (or manual trigger)
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Calculate dev version
id: version
run: |
# Read base version from workspace Cargo.toml
BASE_VERSION=$(grep -m1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
# Create dev version using GitHub run number
# Use hyphen format for Cargo (maturin converts to .dev for Python)
DEV_VERSION="${BASE_VERSION}-dev${{ github.run_number }}"
echo "Base version: $BASE_VERSION"
echo "Dev version: $DEV_VERSION"
echo "version=$DEV_VERSION" >> $GITHUB_OUTPUT
build-wheels:
name: Build wheels on ${{ matrix.platform.os }}
needs: get-version
runs-on: ${{ matrix.platform.runner }}
permissions:
contents: read
id-token: write
strategy:
matrix:
platform:
- runner: ubuntu-latest
os: linux
target: x86_64
- runner: ubuntu-latest
os: linux
target: aarch64
- runner: macos-latest # ARM64, cross-compiles x86_64
os: macos
target: x86_64
- runner: macos-latest # ARM64
os: macos-arm
target: aarch64
- runner: windows-latest
os: windows
target: x64
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Set dev version
run: |
DEV_VERSION="${{ needs.get-version.outputs.version }}"
echo "Building dev version: $DEV_VERSION"
# Update Cargo.toml with dev version (temporary, not committed)
sed -i.bak "s/^version = \".*\"/version = \"$DEV_VERSION\"/" Cargo.toml
shell: bash
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
working-directory: bindings-python
target: ${{ matrix.platform.target }}
command: build
args: --release --out dist --interpreter 3.11 3.12 3.13
manylinux: ${{ matrix.platform.os == 'linux' && 'auto' || '' }}
- name: Upload wheels to GitHub artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
path: bindings-python/dist
build-sdist:
name: Build source distribution
needs: get-version
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Set dev version
run: |
DEV_VERSION="${{ needs.get-version.outputs.version }}"
echo "Building dev version: $DEV_VERSION"
sed -i.bak "s/^version = \".*\"/version = \"$DEV_VERSION\"/" Cargo.toml
shell: bash
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
working-directory: bindings-python
command: sdist
args: --out dist
- name: Upload sdist to GitHub artifacts
uses: actions/upload-artifact@v4
with:
name: sdist
path: bindings-python/dist
publish-to-pypi:
name: Publish dev build to PyPI
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@v4
with:
name: sdist
path: dist
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --skip-existing dist/*
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}