-
Notifications
You must be signed in to change notification settings - Fork 9
215 lines (178 loc) · 5.99 KB
/
release-python.yml
File metadata and controls
215 lines (178 loc) · 5.99 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Release Python
run-name: "Release Python SDK ${{ github.ref_name }}"
on:
push:
tags:
- 'python/v*'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build-linux:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Copy root LICENSE for maturin
run: cp LICENSE python/LICENSE
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install maturin
run: pip install maturin
- name: Build wheels (x86_64)
if: matrix.target == 'x86_64'
run: maturin build --release --manifest-path python/rust/Cargo.toml --out dist
- name: Install Zig (for aarch64)
if: matrix.target == 'aarch64'
run: |
wget -q https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz
tar -xf zig-linux-x86_64-0.13.0.tar.xz
echo "$(pwd)/zig-linux-x86_64-0.13.0" >> $GITHUB_PATH
- name: Build wheels (aarch64)
if: matrix.target == 'aarch64'
run: |
source "$HOME/.cargo/env"
rustup target add aarch64-unknown-linux-gnu
cargo install cargo-zigbuild
maturin build --release --target aarch64-unknown-linux-gnu --zig --manifest-path python/rust/Cargo.toml --out dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: dist
if-no-files-found: error
build-windows:
runs-on:
group: databricks-protected-runner-group
labels: windows-server-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Copy root LICENSE for maturin
run: cp LICENSE python/LICENSE
shell: bash
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
shell: pwsh
- name: Install maturin
run: pip install maturin
- name: Build wheels
run: maturin build --release --manifest-path python/rust/Cargo.toml --out dist
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: dist
if-no-files-found: error
build-macos:
runs-on: [self-hosted, macOS, ARM64, zerobus-sdk]
strategy:
fail-fast: false
matrix:
target: [aarch64-apple-darwin, x86_64-apple-darwin]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Copy root LICENSE for maturin
run: cp LICENSE python/LICENSE
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install maturin
run: pip install maturin
- name: Build wheels
run: maturin build --release --target ${{ matrix.target }} --manifest-path python/rust/Cargo.toml --out dist
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist
if-no-files-found: error
sdist:
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Copy root LICENSE for maturin
run: cp LICENSE python/LICENSE
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install maturin
run: pip install maturin
- name: Build source distribution
run: maturin sdist --manifest-path python/rust/Cargo.toml --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
if-no-files-found: error
publish:
name: Publish to PyPI
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
if: startsWith(github.ref, 'refs/tags/python/')
needs: [build-linux, build-windows, build-macos, sdist]
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: List artifacts for verification
run: ls -lh dist/
- name: Publish to PyPI (Trusted Publishing)
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
release:
name: Create GitHub Release
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
needs: publish
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF#refs/tags/python/v}" >> "$GITHUB_OUTPUT"
- name: Extract release notes from changelog
run: |
version="v${{ steps.version.outputs.version }}"
awk "/^## Release ${version}/{found=1; next} /^## /{if(found) exit} found{print}" python/CHANGELOG.md > /tmp/release-notes.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Python SDK v${{ steps.version.outputs.version }}
body_path: /tmp/release-notes.md