name: Release on: workflow_dispatch: inputs: version: description: 'Version to release (e.g., 0.1.2)' required: true type: string use_cibuildwheel: description: 'Use cibuildwheel for better compatibility (recommended for Colab)' required: false type: boolean default: false jobs: update-version: name: Update Version runs-on: ubuntu-latest permissions: contents: write outputs: commit-sha: ${{ steps.push.outputs.commit-sha }} steps: - uses: actions/checkout@v4 - name: Validate version run: | if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "❌ Invalid version format" exit 1 fi echo "✅ Version format valid" - name: Update versions and push id: push run: | ./scripts/bump_version.sh ${{ inputs.version }} git config user.name "GitHub Actions" git config user.email "actions@github.com" git add packages/*/pyproject.toml git commit -m "chore: release v${{ inputs.version }}" git push origin main COMMIT_SHA=$(git rev-parse HEAD) echo "commit-sha=$COMMIT_SHA" >> $GITHUB_OUTPUT echo "✅ Pushed version update: $COMMIT_SHA" build-packages-reusable: name: Build packages (Standard) needs: update-version if: ${{ !inputs.use_cibuildwheel }} uses: ./.github/workflows/build-reusable.yml with: ref: ${{ needs.update-version.outputs.commit-sha }} build-packages-cibuildwheel: name: Build packages (cibuildwheel) needs: update-version if: ${{ inputs.use_cibuildwheel }} uses: ./.github/workflows/build-cibuildwheel.yml with: ref: ${{ needs.update-version.outputs.commit-sha }} publish: name: Publish and Release needs: [update-version, build-packages-reusable, build-packages-cibuildwheel] if: always() && needs.update-version.result == 'success' && (needs.build-packages-reusable.result == 'success' || needs.build-packages-cibuildwheel.result == 'success') runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v4 with: ref: ${{ needs.update-version.outputs.commit-sha }} - name: Download all artifacts uses: actions/download-artifact@v4 with: path: dist-artifacts - name: Collect packages run: | mkdir -p dist find dist-artifacts -name "*.whl" -exec cp {} dist/ \; find dist-artifacts -name "*.tar.gz" -exec cp {} dist/ \; echo "📦 Packages to publish:" ls -la dist/ - name: Publish to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: | if [ -z "$TWINE_PASSWORD" ]; then echo "❌ PYPI_API_TOKEN not configured!" exit 1 fi pip install twine twine upload dist/* --skip-existing --verbose echo "✅ Published to PyPI!" - name: Create release run: | git tag "v${{ inputs.version }}" git push origin "v${{ inputs.version }}" gh release create "v${{ inputs.version }}" \ --title "Release v${{ inputs.version }}" \ --notes "🚀 Released to PyPI: https://pypi.org/project/leann/${{ inputs.version }}/" \ --latest env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}