-
Notifications
You must be signed in to change notification settings - Fork 2
313 lines (265 loc) · 11 KB
/
release.yml
File metadata and controls
313 lines (265 loc) · 11 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
# =============================================================================
# ToonDB Python SDK Release Pipeline
# =============================================================================
#
# Downloads pre-built binaries from main ToonDB repo releases and packages
# them into platform-specific Python wheels for PyPI.
#
# Platforms supported:
# - Linux x86_64 (manylinux_2_17)
# - macOS ARM64 (Apple Silicon)
# - Windows x64
#
# =============================================================================
# REQUIRED SETUP:
# =============================================================================
#
# PyPI - NO TOKEN NEEDED!
# Uses OIDC Trusted Publisher (configure at PyPI project settings)
# https://pypi.org/manage/project/toondb-client/settings/publishing/
#
# =============================================================================
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 0.3.1) - must match a toondb/toondb release'
required: true
type: string
dry_run:
description: 'Dry run (validate without publishing)'
required: false
default: false
type: boolean
env:
TOONDB_REPO: toondb/toondb
jobs:
# ===========================================================================
# Build Python Wheels (All Platforms)
# ===========================================================================
build-wheel:
name: Build Wheel (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
wheel_platform: manylinux_2_17_x86_64
archive_ext: tar.gz
- os: macos-latest
target: aarch64-apple-darwin
wheel_platform: macosx_11_0_arm64
archive_ext: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
wheel_platform: win_amd64
archive_ext: zip
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Create directory structure
shell: bash
run: |
mkdir -p src/toondb/_bin/${{ matrix.target }}
mkdir -p src/toondb/lib/${{ matrix.target }}
- name: Download binaries from main ToonDB release
shell: bash
run: |
VERSION="${{ inputs.version }}"
TAG="v${VERSION}"
TARGET="${{ matrix.target }}"
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
ASSET_NAME="toondb-${VERSION}-${TARGET}.zip"
else
ASSET_NAME="toondb-${VERSION}-${TARGET}.tar.gz"
fi
DOWNLOAD_URL="https://github.com/${{ env.TOONDB_REPO }}/releases/download/${TAG}/${ASSET_NAME}"
echo "Downloading from: $DOWNLOAD_URL"
curl -L -f -o release-archive.${{ matrix.archive_ext }} "$DOWNLOAD_URL"
# Extract the archive
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
unzip -o release-archive.zip
else
tar -xzf release-archive.tar.gz
fi
ls -la
ls -la ${TARGET}/ || true
- name: Copy binaries and libraries to SDK (Unix)
if: matrix.os != 'windows-latest'
shell: bash
run: |
TARGET="${{ matrix.target }}"
# Copy binaries to _bin/
cp ${TARGET}/toondb-bulk src/toondb/_bin/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb-bulk" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
cp ${TARGET}/toondb-server src/toondb/_bin/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb-server" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
cp ${TARGET}/toondb-grpc-server src/toondb/_bin/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb-grpc-server" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
# Copy shared libraries to lib/
cp ${TARGET}/libtoondb_storage* src/toondb/lib/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "libtoondb_storage*" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
cp ${TARGET}/libtoondb_index* src/toondb/lib/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "libtoondb_index*" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
# Make executables
chmod +x src/toondb/_bin/${TARGET}/* 2>/dev/null || true
chmod +x src/toondb/lib/${TARGET}/* 2>/dev/null || true
echo "=== Binaries ==="
ls -la src/toondb/_bin/${TARGET}/
echo "=== Libraries ==="
ls -la src/toondb/lib/${TARGET}/
- name: Copy binaries and libraries to SDK (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
TARGET="${{ matrix.target }}"
# Copy binaries to _bin/ (no toondb-server on Windows)
cp ${TARGET}/toondb-bulk.exe src/toondb/_bin/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb-bulk.exe" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
cp ${TARGET}/toondb-grpc-server.exe src/toondb/_bin/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb-grpc-server.exe" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
# Copy shared libraries (DLLs) to lib/
cp ${TARGET}/toondb_storage.dll src/toondb/lib/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb_storage.dll" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
cp ${TARGET}/toondb_index.dll src/toondb/lib/${TARGET}/ 2>/dev/null || \
find . -maxdepth 2 -name "toondb_index.dll" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
echo "=== Binaries ==="
ls -la src/toondb/_bin/${TARGET}/
echo "=== Libraries ==="
ls -la src/toondb/lib/${TARGET}/
- name: Update package version
shell: bash
run: |
sed -i.bak 's/version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml
rm -f pyproject.toml.bak
grep "version" pyproject.toml | head -1
- name: Build wheel
run: |
pip install build wheel
python -m build --wheel
- name: Rename wheel with correct platform tag
shell: bash
run: |
cd dist
for f in *-py3-none-any.whl; do
if [ -f "$f" ]; then
newname=$(echo $f | sed 's/-py3-none-any/-py3-none-${{ matrix.wheel_platform }}/')
mv "$f" "$newname"
fi
done
ls -la
- name: Upload wheel artifact
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.target }}
path: dist/*.whl
retention-days: 5
# ===========================================================================
# Build Source Distribution
# ===========================================================================
build-sdist:
name: Build Source Distribution
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Update package version
run: |
sed -i 's/version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml
- name: Build sdist
run: |
pip install build
python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
retention-days: 5
# ===========================================================================
# Publish to PyPI (DISABLED FOR TESTING)
# ===========================================================================
# publish:
# name: Publish to PyPI
# runs-on: ubuntu-latest
# needs: [build-wheel, build-sdist]
# # Required for PyPI Trusted Publisher (OIDC) - no token needed!
# permissions:
# id-token: write
# contents: read
# steps:
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.12'
# - name: Download all artifacts
# uses: actions/download-artifact@v4
# with:
# path: dist/
# merge-multiple: true
# - name: List packages
# run: |
# echo "=== Packages to upload ==="
# ls -la dist/
# if [ -z "$(ls -A dist/)" ]; then
# echo "ERROR: No Python packages found!"
# exit 1
# fi
# - name: Validate packages
# run: |
# pip install twine
# twine check dist/*
# - name: Publish to PyPI (Trusted Publisher)
# if: ${{ inputs.dry_run != true }}
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages-dir: dist/
# skip-existing: true
# verbose: true
# - name: Dry run validation
# if: ${{ inputs.dry_run == true }}
# run: |
# echo "🔍 Dry run - packages validated but not uploaded"
# echo "Packages:"
# ls -la dist/
# ===========================================================================
# Release Summary
# ===========================================================================
summary:
name: Release Summary
runs-on: ubuntu-latest
needs: [build-wheel, build-sdist]
if: always()
steps:
- name: Summary
run: |
echo "## 🐍 ToonDB Python SDK v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Mode:** TEST BUILD (Publishing Disabled)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "pip install toondb-client==${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Platforms Bundled" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Linux x86_64 (manylinux_2_17)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ macOS ARM64 (Apple Silicon)" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Windows x64" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Status" >> $GITHUB_STEP_SUMMARY
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Build Wheels | ${{ needs.build-wheel.result || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Build sdist | ${{ needs.build-sdist.result || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY