-
Notifications
You must be signed in to change notification settings - Fork 7
317 lines (279 loc) · 10.9 KB
/
Copy pathrelease.yml
File metadata and controls
317 lines (279 loc) · 10.9 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release
on:
workflow_dispatch:
inputs:
publish_rust:
description: 'Publish to crates.io'
required: true
type: boolean
default: true
publish_python:
description: 'Publish to PyPI'
required: true
type: boolean
default: true
dry_run:
description: 'Dry run (no actual publishing)'
required: true
type: boolean
default: false
jobs:
validate:
name: Validate Release Branch
runs-on: ubuntu-latest
outputs:
can_release: ${{ steps.check.outputs.can_release }}
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Check branch name
id: check
run: |
BRANCH_NAME="${{ github.ref_name }}"
echo "Current branch: $BRANCH_NAME"
if [[ "$BRANCH_NAME" == release/* ]] || [[ "$BRANCH_NAME" == release-* ]]; then
echo "✅ Valid release branch: $BRANCH_NAME"
echo "can_release=true" >> $GITHUB_OUTPUT
else
echo "❌ Not a release branch. Must start with 'release/' or 'release-'"
echo "can_release=false" >> $GITHUB_OUTPUT
exit 1
fi
- name: Extract version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2)
echo "Version found: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
publish-rust:
name: Publish Rust to crates.io
needs: validate
if: ${{ needs.validate.outputs.can_release == 'true' && github.event.inputs.publish_rust == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Check package
run: |
cargo check --all-features
cargo test --all-features
- name: Dry run publish (validation)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "🔍 Dry run - validating package..."
cargo publish --dry-run --all-features
echo "✅ Package validation successful"
- name: Publish to crates.io
if: ${{ github.event.inputs.dry_run == 'false' }}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
echo "📦 Publishing version ${{ needs.validate.outputs.version }} to crates.io..."
cargo publish --all-features
echo "✅ Successfully published to crates.io"
build-python-wheels:
name: Build Python wheels on ${{ matrix.os }}
needs: validate
if: ${{ needs.validate.outputs.can_release == 'true' && github.event.inputs.publish_python == 'true' }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Linux x86_64. Pinned to manylinux_2_28 (AlmaLinux 8) — manylinux2014
# (CentOS 7) ships libclang 3.4 which is too old for zstd-sys/bindgen.
- os: ubuntu-latest
target: x86_64
manylinux: 2_28
features: python,git,sql,rocksdb_storage,proximity,proximity_text
# Linux aarch64 — cross-compile via rust-cross/manylinux_2_28-cross.
# rocksdb_storage is OFF here: librocksdb-sys's bindgen invokes clang
# targeting aarch64-unknown-linux-gnu and can't resolve the aarch64
# multiarch `bits/libc-header-start.h` from the Debian-based cross
# container. aarch64-Linux users needing RocksDB can build from sdist.
- os: ubuntu-latest
target: aarch64
manylinux: 2_28
features: python,git,sql,proximity,proximity_text
# Windows x86_64
- os: windows-latest
target: x64
manylinux: false
features: python,git,sql,rocksdb_storage,proximity,proximity_text
# macOS ARM64 (Apple Silicon) — arm64 wheel works on Intel Macs via Rosetta
- os: macos-14
target: aarch64
manylinux: false
features: python,git,sql,rocksdb_storage,proximity,proximity_text
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup QEMU
if: ${{ matrix.target == 'aarch64' && runner.os == 'Linux' }}
uses: docker/setup-qemu-action@v3
with:
platforms: linux/arm64
- name: Install LLVM (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
choco install -y llvm
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $env:GITHUB_ENV
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --features ${{ matrix.features }} -i python3.11
manylinux: ${{ matrix.manylinux }}
before-script-linux: |
# Install clang/libclang for bindgen and a C++ toolchain for any
# C++ deps. (rocksdb_storage is disabled on aarch64 — see matrix.)
if command -v yum >/dev/null 2>&1; then
yum install -y clang gcc gcc-c++ glibc-devel
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y --no-install-recommends clang g++ libc6-dev
fi
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.target }}
path: dist
publish-python:
name: Publish Python to PyPI
needs: [validate, build-python-wheels]
if: ${{ needs.validate.outputs.can_release == 'true' && github.event.inputs.publish_python == 'true' }}
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/prollytree/
permissions:
id-token: write # Required for trusted publishing
steps:
- uses: actions/checkout@v4
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Build source distribution
run: |
pip install maturin
maturin sdist
cp target/wheels/*.tar.gz dist/
- name: List distribution files
run: |
echo "📦 Distribution files to publish:"
ls -la dist/
- name: Dry run - validate packages
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "🔍 Dry run - validating packages..."
pip install twine
twine check dist/*
echo "✅ Package validation successful"
- name: Publish to TestPyPI (dry run)
if: ${{ github.event.inputs.dry_run == 'true' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
- name: Publish to PyPI
if: ${{ github.event.inputs.dry_run == 'false' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
verbose: true
create-release:
name: Create GitHub Release
needs: [validate, publish-rust, publish-python]
if: |
always() &&
needs.validate.outputs.can_release == 'true' &&
github.event.inputs.dry_run == 'false' &&
(needs.publish-rust.result == 'success' || needs.publish-rust.result == 'skipped') &&
(needs.publish-python.result == 'success' || needs.publish-python.result == 'skipped')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download Python wheels
if: ${{ github.event.inputs.publish_python == 'true' }}
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true
- name: Generate release notes
id: notes
run: |
VERSION="${{ needs.validate.outputs.version }}"
echo "# ProllyTree v$VERSION" > release-notes.md
echo "" >> release-notes.md
# Add package info
echo "## 📦 Packages Published" >> release-notes.md
if [[ "${{ github.event.inputs.publish_rust }}" == "true" ]]; then
echo "- ✅ Rust package published to [crates.io](https://crates.io/crates/prollytree/$VERSION)" >> release-notes.md
fi
if [[ "${{ github.event.inputs.publish_python }}" == "true" ]]; then
echo "- ✅ Python package published to [PyPI](https://pypi.org/project/prollytree/$VERSION/)" >> release-notes.md
fi
echo "" >> release-notes.md
echo "## 📝 Installation" >> release-notes.md
echo "" >> release-notes.md
echo "### Rust" >> release-notes.md
echo '```toml' >> release-notes.md
echo "prollytree = \"$VERSION\"" >> release-notes.md
echo '```' >> release-notes.md
echo "" >> release-notes.md
echo "### Python" >> release-notes.md
echo '```bash' >> release-notes.md
echo "pip install prollytree==$VERSION" >> release-notes.md
echo '```' >> release-notes.md
echo "" >> release-notes.md
# Try to extract changelog if exists
if [ -f CHANGELOG.md ]; then
echo "## 📋 Changes" >> release-notes.md
# Extract section for this version
awk "/^## \[$VERSION\]/,/^## \[/" CHANGELOG.md | head -n -1 >> release-notes.md || true
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.validate.outputs.version }}
name: Release v${{ needs.validate.outputs.version }}
body_path: release-notes.md
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, 'beta') || contains(needs.validate.outputs.version, 'alpha') || contains(needs.validate.outputs.version, 'rc') }}
files: |
dist/*.whl
dist/*.tar.gz
fail_on_unmatched_files: false