forked from ArcadeData/arcadedb
-
Notifications
You must be signed in to change notification settings - Fork 0
401 lines (339 loc) ยท 15.8 KB
/
Copy pathrelease-python-packages.yml
File metadata and controls
401 lines (339 loc) ยท 15.8 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
name: Build and Release Python Packages to PyPI
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*' # Matches: 25.10.1, 25.10.1.dev0, 25.10.1.post1, etc.
jobs:
# Validate version compatibility between tag and pom.xml
validate-version:
name: Validate Version Compatibility
runs-on: ubuntu-24.04
outputs:
python-version: ${{ steps.validate.outputs.python-version }}
base-version: ${{ steps.validate.outputs.base-version }}
steps:
- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.12'
- name: Validate version compatibility
id: validate
run: |
cd bindings/python
# Get version from git tag
TAG_VERSION="${{ github.ref_name }}"
echo "๐ Git tag version: $TAG_VERSION"
# Extract base version from tag (remove .dev0, .post1, etc.)
TAG_BASE=$(echo "$TAG_VERSION" | sed -E 's/\.(dev|post|rc|a|b)[0-9]+$//')
echo "๐ Tag base version: $TAG_BASE"
# Get version from pom.xml
POM_VERSION=$(python3 extract_version.py --format=docker)
echo "๐ pom.xml version: $POM_VERSION"
# Extract base version from pom.xml (remove -SNAPSHOT, etc.)
POM_BASE=$(echo "$POM_VERSION" | sed 's/-SNAPSHOT$//' | sed 's/-RC.*//')
echo "๐ pom.xml base version: $POM_BASE"
# Compare base versions
if [ "$TAG_BASE" != "$POM_BASE" ]; then
echo "โ Version mismatch!"
echo " Tag base version: $TAG_BASE"
echo " pom.xml base version: $POM_BASE"
echo ""
echo "This prevents accidentally releasing the wrong version."
echo "For example, tagging 25.9.1.dev0 when pom.xml says 25.10.1-SNAPSHOT"
exit 1
fi
echo "โ
Version compatibility check passed!"
echo " Base version: $TAG_BASE"
echo " Full tag version: $TAG_VERSION"
# Output for later jobs
echo "python-version=$TAG_VERSION" >> $GITHUB_OUTPUT
echo "base-version=$TAG_BASE" >> $GITHUB_OUTPUT
# Run example tests before building (workflow_call)
test-examples:
name: Run Example Tests
needs: validate-version
uses: ./.github/workflows/test-python-examples.yml
secrets: inherit
# Run unit tests before building
test:
name: Run Unit Tests
needs: validate-version
uses: ./.github/workflows/test-python-bindings.yml
secrets: inherit
# Reuse wheels from test job (no need to rebuild!)
prepare-wheels:
needs: [validate-version, test, test-examples]
name: Prepare Wheels for Release (${{ matrix.platform }})
runs-on: ubuntu-latest
strategy:
matrix:
# Temporarily limit to three platforms (skip macOS x86_64 and all Windows)
# platform:
# - linux-amd64
# - linux-arm64
# - darwin-amd64
# - darwin-arm64
# - windows-amd64
# - windows-arm64
platform:
- linux-amd64
- linux-arm64
- darwin-arm64
steps:
- name: Download wheel from test job
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: wheel-${{ matrix.platform }}-test
path: dist/
- name: Verify wheel was downloaded
shell: bash
run: |
echo "๐ฆ Checking for wheel-${{ matrix.platform }}-test..."
ls -lh dist/
if [ ! -f dist/*.whl ]; then
echo "โ No wheel found for ${{ matrix.platform }}!"
exit 1
fi
echo "โ
Wheel found for ${{ matrix.platform }}"
- name: Re-upload wheel for release
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: wheel-${{ matrix.platform }}
path: dist/*.whl
retention-days: 5
publish:
name: Publish arcadedb-embedded to PyPI (3 platforms)
needs: [validate-version, prepare-wheels]
runs-on: ubuntu-latest
continue-on-error: true # Don't block GitHub Release if PyPI upload fails (size limit)
environment: pypi
permissions:
id-token: write
steps:
- name: Download wheels for main platforms only
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
pattern: wheel-*
path: wheels-temp/
merge-multiple: false # Keep in separate directories
- name: Collect wheels for PyPI (3 main platforms)
shell: bash
run: |
mkdir -p dist
# Only copy wheels for the 3 platforms we currently ship on PyPI
# Previous set (commented for future reference): linux-amd64 darwin-arm64 windows-amd64 linux-arm64 darwin-amd64 windows-arm64
echo "๐ฆ Collecting wheels for PyPI (current platforms)..."
# Copy main platform wheels
for platform in linux-amd64 darwin-arm64 linux-arm64; do
if [ -d "wheels-temp/wheel-$platform" ]; then
cp wheels-temp/wheel-$platform/*.whl dist/ 2>/dev/null || true
echo " โ
$platform"
else
echo " โ ๏ธ $platform not found"
fi
done
echo ""
echo "๐ฆ Wheels for PyPI:"
ls -lh dist/
- name: Verify wheels
run: |
ls -lh dist/
echo "๐ฆ Wheels for PyPI (current platforms):"
ls dist/*.whl
# Count wheels (should be 3: linux-amd64, linux-arm64, darwin-arm64)
WHEEL_COUNT=$(ls dist/*.whl | wc -l)
echo "๐ Wheel count: $WHEEL_COUNT (expected: 3)"
echo ""
echo "โน๏ธ Platforms not on PyPI (available via GitHub Releases):"
echo " - darwin-amd64 (~3-5%): Intel Macs can use darwin-arm64 via Rosetta 2" # formerly on PyPI
echo " - windows-amd64 (~85-90% of Windows)" # formerly on PyPI
echo " - windows-arm64 (~1-2%): Surface Pro X"
echo ""
echo " Current PyPI coverage: linux x86_64, linux arm64, macOS Apple Silicon"
if [ "$WHEEL_COUNT" -ne 3 ]; then
echo "โ Expected 3 wheels (3 main platforms), got $WHEEL_COUNT"
exit 1
fi
# Show checksums to verify wheels are different
echo ""
echo "๐ Wheel checksums (SHA256):"
sha256sum dist/*.whl
# Report wheel sizes with actual component breakdown
echo "" >> $GITHUB_STEP_SUMMARY
echo "## ๐ฆ Built Wheels" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Platform | Wheel Size | JRE Size | JARs Size | Installed Size | SHA256 (first 8 chars) |" >> $GITHUB_STEP_SUMMARY
echo "|----------|------------|----------|-----------|----------------|------------------------|" >> $GITHUB_STEP_SUMMARY
for WHEEL_FILE in dist/*.whl; do
WHEEL_NAME=$(basename "$WHEEL_FILE")
WHEEL_SIZE_BYTES=$(stat -c%s "$WHEEL_FILE")
WHEEL_SIZE_MB=$(echo "scale=1; $WHEEL_SIZE_BYTES / 1024 / 1024" | bc)
# Extract platform from filename
if [[ "$WHEEL_NAME" == *"manylinux"*"x86_64"* ]]; then
PLATFORM="linux/amd64"
elif [[ "$WHEEL_NAME" == *"manylinux"*"aarch64"* ]]; then
PLATFORM="linux/arm64"
elif [[ "$WHEEL_NAME" == *"macosx"*"arm64"* ]]; then
PLATFORM="darwin/arm64"
# elif [[ "$WHEEL_NAME" == *"macosx"*"x86_64"* ]]; then
# PLATFORM="darwin/amd64"
# elif [[ "$WHEEL_NAME" == *"win_amd64"* ]]; then
# PLATFORM="windows/amd64"
else
PLATFORM="unknown"
fi
# Analyze wheel contents
TEMP_DIR=$(mktemp -d)
unzip -q "$WHEEL_FILE" -d "$TEMP_DIR"
# Calculate component sizes (find jre directory anywhere)
JRE_DIR=$(find "$TEMP_DIR" -type d -name "jre" | head -n1)
if [ -n "$JRE_DIR" ] && [ -d "$JRE_DIR" ]; then
JRE_SIZE_BYTES=$(du -sb "$JRE_DIR" | cut -f1)
JRE_SIZE_MB=$(echo "scale=1; $JRE_SIZE_BYTES / 1024 / 1024" | bc)
else
JRE_SIZE_MB="N/A"
fi
JAR_SIZE_BYTES=$(find "$TEMP_DIR" -name "*.jar" -exec du -cb {} + 2>/dev/null | tail -1 | cut -f1)
if [ -n "$JAR_SIZE_BYTES" ] && [ "$JAR_SIZE_BYTES" != "0" ]; then
JAR_SIZE_MB=$(echo "scale=1; $JAR_SIZE_BYTES / 1024 / 1024" | bc)
else
JAR_SIZE_MB="N/A"
fi
INSTALLED_SIZE_BYTES=$(du -sb "$TEMP_DIR" | cut -f1)
INSTALLED_SIZE_MB=$(echo "scale=0; $INSTALLED_SIZE_BYTES / 1024 / 1024" | bc)
# Calculate SHA256 checksum
CHECKSUM=$(sha256sum "$WHEEL_FILE" | cut -d' ' -f1 | cut -c1-8)
rm -rf "$TEMP_DIR"
echo "| $PLATFORM | ${WHEEL_SIZE_MB}M | ${JRE_SIZE_MB}M | ${JAR_SIZE_MB}M | ~${INSTALLED_SIZE_MB}M | \`$CHECKSUM\` |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Note**: Sizes are uncompressed except for Wheel Size (compressed)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: Verify wheel versions
run: |
for WHEEL_FILE in dist/*.whl; do
echo "๐ฆ Checking: $WHEEL_FILE"
# Extract version from wheel filename
WHEEL_VERSION=$(echo "$WHEEL_FILE" | grep -oP '\d+\.\d+\.\d+(\.(dev|post|rc|a|b)\d+)?')
echo " Version: $WHEEL_VERSION"
if [ "$WHEEL_VERSION" != "${{ needs.validate-version.outputs.python-version }}" ]; then
echo "โ Wheel version mismatch in $WHEEL_FILE!"
exit 1
fi
done
echo "โ
All wheel versions match tag version"
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1
github-release:
name: Create GitHub Release (All enabled platforms)
needs: [validate-version, prepare-wheels]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all wheels (all enabled platforms)
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: wheel-*
path: dist/
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
files: dist/*.whl
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, 'dev') || contains(github.ref_name, 'rc') || contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') }}
body: |
## ๐ฎ ArcadeDB Embedded Python Bindings v${{ needs.validate-version.outputs.python-version }}
### ๐ฆ Installation
**Recommended (PyPI - 3 main platforms):**
```bash
pip install arcadedb-embedded==${{ needs.validate-version.outputs.python-version }}
```
**Alternative (GitHub - all 6 platforms):**
```bash
# For platforms not on PyPI (see below)
pip install https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/arcadedb_embedded-${{ needs.validate-version.outputs.python-version }}-py3-none-<platform>.whl
```
### ๐ Supported Platforms
**Available on PyPI** (~90% of developers):
- โ
**Linux x86_64** (servers, CI/CD, Docker, cloud)
- โ
**macOS Apple Silicon** (M1/M2/M3/M4, also works on Intel Macs via Rosetta 2)
- โ
**Windows x64** (most Windows users)
**Available via GitHub Releases only** (~10% of developers):
- โฌ๏ธ **macOS Intel** (2019-2020 Macs) - *Can use Apple Silicon wheel via Rosetta 2*
- โฌ๏ธ **Linux ARM64** (Raspberry Pi, AWS Graviton)
- โฌ๏ธ **Windows ARM64** (Surface Pro X)
### ๐ Links
- [PyPI Package](https://pypi.org/project/arcadedb-embedded/${{ needs.validate-version.outputs.python-version }}/)
- [Documentation](https://github.com/${{ github.repository }})
- [Examples](https://github.com/${{ github.repository }}/tree/main/bindings/python/examples)
### ๐ฝ Direct Downloads
All 6 platform-specific wheels are attached below. Most users should install via pip (auto-selects correct wheel).
---
**Note**: PyPI distribution limited to 3 main platforms to reduce storage (~50% savings). All platforms available here.
**Intel Mac users**: Use the Apple Silicon wheel (works via Rosetta 2) or download the native Intel wheel below for maximum performance.
**Based on ArcadeDB v${{ needs.validate-version.outputs.base-version }}**
update-pypi-index:
name: Update PyPI simple index on GitHub Pages (All 6 platforms)
needs: [validate-version, github-release]
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Generate PyPI simple index
shell: bash
env:
VERSION: ${{ needs.validate-version.outputs.python-version }}
REPO: ${{ github.repository }}
run: |
# Create simple index directory structure
mkdir -p simple/arcadedb-embedded
# Generate index.html header
cat > simple/arcadedb-embedded/index.html <<'EOF'
<!DOCTYPE html>
<html>
<head>
<title>Links for arcadedb-embedded</title>
<meta name="pypi:repository-version" content="1.0">
</head>
<body>
<h1>Links for arcadedb-embedded</h1>
<p><strong>Alternative PyPI index with all 6 platforms</strong> (official PyPI only has 3 main platforms)</p>
<p>Usage: <code>pip install --extra-index-url https://humemai.github.io/arcadedb-embedded-python/simple arcadedb-embedded</code></p>
<p><em>Note: Intel Mac users can use the Apple Silicon wheel via Rosetta 2, or download the native Intel wheel for best performance.</em></p>
<hr/>
EOF
# Get all releases and add wheel links (all 6 platforms from GitHub)
echo "๐ Fetching all releases..."
gh release list --limit 100 --json tagName | jq -r '.[].tagName' | while read -r tag; do
echo " Processing release: $tag"
# Get wheel assets for this release
gh release view "$tag" --json assets --jq '.assets[] | select(.name | endswith(".whl")) | .name' | while read -r wheel; do
echo "<a href=\"https://github.com/${{ github.repository }}/releases/download/$tag/$wheel\">$wheel</a><br/>" >> simple/arcadedb-embedded/index.html
done
done
# Close HTML
cat >> simple/arcadedb-embedded/index.html <<'EOF'
</body>
</html>
EOF
echo "โ
Generated PyPI simple index:"
cat simple/arcadedb-embedded/index.html
- name: Commit and push index
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add simple/
git commit -m "Update PyPI simple index for v${{ needs.validate-version.outputs.python-version }}" || echo "No changes to commit"
git push