Skip to content

Commit 76dad28

Browse files
committed
python sdk pipeline.
1 parent 9de8327 commit 76dad28

File tree

1 file changed

+313
-0
lines changed

1 file changed

+313
-0
lines changed

.github/workflows/release.yml

Lines changed: 313 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
# =============================================================================
2+
# ToonDB Python SDK Release Pipeline
3+
# =============================================================================
4+
#
5+
# Downloads pre-built binaries from main ToonDB repo releases and packages
6+
# them into platform-specific Python wheels for PyPI.
7+
#
8+
# Platforms supported:
9+
# - Linux x86_64 (manylinux_2_17)
10+
# - macOS ARM64 (Apple Silicon)
11+
# - Windows x64
12+
#
13+
# =============================================================================
14+
# REQUIRED SETUP:
15+
# =============================================================================
16+
#
17+
# PyPI - NO TOKEN NEEDED!
18+
# Uses OIDC Trusted Publisher (configure at PyPI project settings)
19+
# https://pypi.org/manage/project/toondb-client/settings/publishing/
20+
#
21+
# =============================================================================
22+
23+
name: Release
24+
25+
on:
26+
workflow_dispatch:
27+
inputs:
28+
version:
29+
description: 'Release version (e.g., 0.3.1) - must match a toondb/toondb release'
30+
required: true
31+
type: string
32+
dry_run:
33+
description: 'Dry run (validate without publishing)'
34+
required: false
35+
default: false
36+
type: boolean
37+
38+
env:
39+
TOONDB_REPO: toondb/toondb
40+
41+
jobs:
42+
# ===========================================================================
43+
# Build Python Wheels (All Platforms)
44+
# ===========================================================================
45+
build-wheel:
46+
name: Build Wheel (${{ matrix.target }})
47+
runs-on: ${{ matrix.os }}
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
include:
52+
- os: ubuntu-latest
53+
target: x86_64-unknown-linux-gnu
54+
wheel_platform: manylinux_2_17_x86_64
55+
archive_ext: tar.gz
56+
57+
- os: macos-latest
58+
target: aarch64-apple-darwin
59+
wheel_platform: macosx_11_0_arm64
60+
archive_ext: tar.gz
61+
62+
- os: windows-latest
63+
target: x86_64-pc-windows-msvc
64+
wheel_platform: win_amd64
65+
archive_ext: zip
66+
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: '3.12'
75+
76+
- name: Create directory structure
77+
shell: bash
78+
run: |
79+
mkdir -p src/toondb/_bin/${{ matrix.target }}
80+
mkdir -p src/toondb/lib/${{ matrix.target }}
81+
82+
- name: Download binaries from main ToonDB release
83+
shell: bash
84+
run: |
85+
VERSION="${{ inputs.version }}"
86+
TAG="v${VERSION}"
87+
TARGET="${{ matrix.target }}"
88+
89+
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
90+
ASSET_NAME="toondb-${VERSION}-${TARGET}.zip"
91+
else
92+
ASSET_NAME="toondb-${VERSION}-${TARGET}.tar.gz"
93+
fi
94+
95+
DOWNLOAD_URL="https://github.com/${{ env.TOONDB_REPO }}/releases/download/${TAG}/${ASSET_NAME}"
96+
echo "Downloading from: $DOWNLOAD_URL"
97+
98+
curl -L -f -o release-archive.${{ matrix.archive_ext }} "$DOWNLOAD_URL"
99+
100+
# Extract the archive
101+
if [ "${{ matrix.archive_ext }}" = "zip" ]; then
102+
unzip -o release-archive.zip
103+
else
104+
tar -xzf release-archive.tar.gz
105+
fi
106+
107+
ls -la
108+
ls -la ${TARGET}/ || true
109+
110+
- name: Copy binaries and libraries to SDK (Unix)
111+
if: matrix.os != 'windows-latest'
112+
shell: bash
113+
run: |
114+
TARGET="${{ matrix.target }}"
115+
116+
# Copy binaries to _bin/
117+
cp ${TARGET}/toondb-bulk src/toondb/_bin/${TARGET}/ 2>/dev/null || \
118+
find . -maxdepth 2 -name "toondb-bulk" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
119+
120+
cp ${TARGET}/toondb-server src/toondb/_bin/${TARGET}/ 2>/dev/null || \
121+
find . -maxdepth 2 -name "toondb-server" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
122+
123+
cp ${TARGET}/toondb-grpc-server src/toondb/_bin/${TARGET}/ 2>/dev/null || \
124+
find . -maxdepth 2 -name "toondb-grpc-server" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
125+
126+
# Copy shared libraries to lib/
127+
cp ${TARGET}/libtoondb_storage* src/toondb/lib/${TARGET}/ 2>/dev/null || \
128+
find . -maxdepth 2 -name "libtoondb_storage*" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
129+
130+
cp ${TARGET}/libtoondb_index* src/toondb/lib/${TARGET}/ 2>/dev/null || \
131+
find . -maxdepth 2 -name "libtoondb_index*" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
132+
133+
# Make executables
134+
chmod +x src/toondb/_bin/${TARGET}/* 2>/dev/null || true
135+
chmod +x src/toondb/lib/${TARGET}/* 2>/dev/null || true
136+
137+
echo "=== Binaries ==="
138+
ls -la src/toondb/_bin/${TARGET}/
139+
echo "=== Libraries ==="
140+
ls -la src/toondb/lib/${TARGET}/
141+
142+
- name: Copy binaries and libraries to SDK (Windows)
143+
if: matrix.os == 'windows-latest'
144+
shell: bash
145+
run: |
146+
TARGET="${{ matrix.target }}"
147+
148+
# Copy binaries to _bin/ (no toondb-server on Windows)
149+
cp ${TARGET}/toondb-bulk.exe src/toondb/_bin/${TARGET}/ 2>/dev/null || \
150+
find . -maxdepth 2 -name "toondb-bulk.exe" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
151+
152+
cp ${TARGET}/toondb-grpc-server.exe src/toondb/_bin/${TARGET}/ 2>/dev/null || \
153+
find . -maxdepth 2 -name "toondb-grpc-server.exe" -type f -exec cp {} src/toondb/_bin/${TARGET}/ \;
154+
155+
# Copy shared libraries (DLLs) to lib/
156+
cp ${TARGET}/toondb_storage.dll src/toondb/lib/${TARGET}/ 2>/dev/null || \
157+
find . -maxdepth 2 -name "toondb_storage.dll" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
158+
159+
cp ${TARGET}/toondb_index.dll src/toondb/lib/${TARGET}/ 2>/dev/null || \
160+
find . -maxdepth 2 -name "toondb_index.dll" -type f -exec cp {} src/toondb/lib/${TARGET}/ \;
161+
162+
echo "=== Binaries ==="
163+
ls -la src/toondb/_bin/${TARGET}/
164+
echo "=== Libraries ==="
165+
ls -la src/toondb/lib/${TARGET}/
166+
167+
- name: Update package version
168+
shell: bash
169+
run: |
170+
sed -i.bak 's/version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml
171+
rm -f pyproject.toml.bak
172+
grep "version" pyproject.toml | head -1
173+
174+
- name: Build wheel
175+
run: |
176+
pip install build wheel
177+
python -m build --wheel
178+
179+
- name: Rename wheel with correct platform tag
180+
shell: bash
181+
run: |
182+
cd dist
183+
for f in *-py3-none-any.whl; do
184+
if [ -f "$f" ]; then
185+
newname=$(echo $f | sed 's/-py3-none-any/-py3-none-${{ matrix.wheel_platform }}/')
186+
mv "$f" "$newname"
187+
fi
188+
done
189+
ls -la
190+
191+
- name: Upload wheel artifact
192+
uses: actions/upload-artifact@v4
193+
with:
194+
name: wheel-${{ matrix.target }}
195+
path: dist/*.whl
196+
retention-days: 5
197+
198+
# ===========================================================================
199+
# Build Source Distribution
200+
# ===========================================================================
201+
build-sdist:
202+
name: Build Source Distribution
203+
runs-on: ubuntu-latest
204+
steps:
205+
- name: Checkout repository
206+
uses: actions/checkout@v4
207+
208+
- name: Set up Python
209+
uses: actions/setup-python@v5
210+
with:
211+
python-version: '3.12'
212+
213+
- name: Update package version
214+
run: |
215+
sed -i 's/version = ".*"/version = "${{ inputs.version }}"/' pyproject.toml
216+
217+
- name: Build sdist
218+
run: |
219+
pip install build
220+
python -m build --sdist
221+
222+
- name: Upload sdist artifact
223+
uses: actions/upload-artifact@v4
224+
with:
225+
name: sdist
226+
path: dist/*.tar.gz
227+
retention-days: 5
228+
229+
# ===========================================================================
230+
# Publish to PyPI (DISABLED FOR TESTING)
231+
# ===========================================================================
232+
# publish:
233+
# name: Publish to PyPI
234+
# runs-on: ubuntu-latest
235+
# needs: [build-wheel, build-sdist]
236+
# # Required for PyPI Trusted Publisher (OIDC) - no token needed!
237+
# permissions:
238+
# id-token: write
239+
# contents: read
240+
# steps:
241+
# - name: Set up Python
242+
# uses: actions/setup-python@v5
243+
# with:
244+
# python-version: '3.12'
245+
246+
# - name: Download all artifacts
247+
# uses: actions/download-artifact@v4
248+
# with:
249+
# path: dist/
250+
# merge-multiple: true
251+
252+
# - name: List packages
253+
# run: |
254+
# echo "=== Packages to upload ==="
255+
# ls -la dist/
256+
# if [ -z "$(ls -A dist/)" ]; then
257+
# echo "ERROR: No Python packages found!"
258+
# exit 1
259+
# fi
260+
261+
# - name: Validate packages
262+
# run: |
263+
# pip install twine
264+
# twine check dist/*
265+
266+
# - name: Publish to PyPI (Trusted Publisher)
267+
# if: ${{ inputs.dry_run != true }}
268+
# uses: pypa/gh-action-pypi-publish@release/v1
269+
# with:
270+
# packages-dir: dist/
271+
# skip-existing: true
272+
# verbose: true
273+
274+
# - name: Dry run validation
275+
# if: ${{ inputs.dry_run == true }}
276+
# run: |
277+
# echo "🔍 Dry run - packages validated but not uploaded"
278+
# echo "Packages:"
279+
# ls -la dist/
280+
281+
# ===========================================================================
282+
# Release Summary
283+
# ===========================================================================
284+
summary:
285+
name: Release Summary
286+
runs-on: ubuntu-latest
287+
needs: [build-wheel, build-sdist]
288+
if: always()
289+
steps:
290+
- name: Summary
291+
run: |
292+
echo "## 🐍 ToonDB Python SDK v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
293+
echo "" >> $GITHUB_STEP_SUMMARY
294+
echo "**Mode:** TEST BUILD (Publishing Disabled)" >> $GITHUB_STEP_SUMMARY
295+
296+
echo "" >> $GITHUB_STEP_SUMMARY
297+
echo "### Installation" >> $GITHUB_STEP_SUMMARY
298+
echo '```bash' >> $GITHUB_STEP_SUMMARY
299+
echo "pip install toondb-client==${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
300+
echo '```' >> $GITHUB_STEP_SUMMARY
301+
302+
echo "" >> $GITHUB_STEP_SUMMARY
303+
echo "### Platforms Bundled" >> $GITHUB_STEP_SUMMARY
304+
echo "- ✅ Linux x86_64 (manylinux_2_17)" >> $GITHUB_STEP_SUMMARY
305+
echo "- ✅ macOS ARM64 (Apple Silicon)" >> $GITHUB_STEP_SUMMARY
306+
echo "- ✅ Windows x64" >> $GITHUB_STEP_SUMMARY
307+
308+
echo "" >> $GITHUB_STEP_SUMMARY
309+
echo "### Status" >> $GITHUB_STEP_SUMMARY
310+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
311+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
312+
echo "| Build Wheels | ${{ needs.build-wheel.result || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY
313+
echo "| Build sdist | ${{ needs.build-sdist.result || 'N/A' }} |" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)