refactor: use CI artifacts in release workflow instead of rebuilding

- Download pre-built wheels from successful CI runs
- Avoids duplicate builds and ensures consistency
- CI artifacts are already tested across all platforms
- Faster release process (no build time)
- Updates release documentation to reflect new flow

This ensures the released packages are exactly what was tested in CI.
This commit is contained in:
Andy Lee
2025-07-24 14:19:22 -07:00
parent 1614203786
commit 50686c0819
2 changed files with 60 additions and 6 deletions

View File

@@ -26,8 +26,8 @@ jobs:
- name: Check CI status
run: |
echo " This workflow assumes CI has already passed on the current commit."
echo " If not, please wait for CI to complete before releasing."
echo " This workflow will download build artifacts from the latest CI run."
echo " CI must have completed successfully on the current commit."
echo ""
- name: Validate version format
@@ -64,11 +64,64 @@ jobs:
git add packages/*/pyproject.toml
git commit -m "chore: release v${{ inputs.version }}"
- name: Build packages for TestPyPI
- name: Get CI run ID
id: get-ci-run
run: |
echo "🔨 Building packages for testing..."
./scripts/build_and_test.sh all
echo "✅ Build successful! (Already tested on multiple platforms)"
# Get the latest successful CI run on this commit
COMMIT_SHA=$(git rev-parse HEAD)
RUN_ID=$(gh run list \
--workflow=ci.yml \
--status=success \
--commit=$COMMIT_SHA \
--json databaseId \
--jq '.[0].databaseId')
if [ -z "$RUN_ID" ]; then
echo "❌ No successful CI run found for commit $COMMIT_SHA"
echo "Please wait for CI to complete before releasing."
exit 1
fi
echo "✅ Found CI run: $RUN_ID"
echo "run-id=$RUN_ID" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifacts from CI
run: |
echo "📦 Downloading artifacts from CI run ${{ steps.get-ci-run.outputs.run-id }}..."
# Download all wheel artifacts
gh run download ${{ steps.get-ci-run.outputs.run-id }} \
--pattern "wheels-*" \
--dir ./dist-downloads
# Consolidate all wheels into packages/*/dist/
mkdir -p packages/leann-core/dist
mkdir -p packages/leann-backend-hnsw/dist
mkdir -p packages/leann-backend-diskann/dist
mkdir -p packages/leann/dist
find ./dist-downloads -name "*.whl" -exec cp {} ./packages/ \;
# Move wheels to correct package directories
for wheel in packages/*.whl; do
if [[ $wheel == *"leann_core"* ]]; then
mv "$wheel" packages/leann-core/dist/
elif [[ $wheel == *"leann_backend_hnsw"* ]]; then
mv "$wheel" packages/leann-backend-hnsw/dist/
elif [[ $wheel == *"leann_backend_diskann"* ]]; then
mv "$wheel" packages/leann-backend-diskann/dist/
elif [[ $wheel == *"leann-"* ]] && [[ $wheel != *"backend"* ]] && [[ $wheel != *"core"* ]]; then
mv "$wheel" packages/leann/dist/
fi
done
# List downloaded wheels
echo "✅ Downloaded wheels:"
find packages/*/dist -name "*.whl" -type f | sort
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test on TestPyPI (optional)
if: inputs.test_pypi