Fix release workflow: build pure Python wheel without bundled extensions #7
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build-and-test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| artifact: graphqlite.so | |
| artifact-name: graphqlite-linux-x86_64.so | |
| - os: macos-14 | |
| arch: arm64 | |
| artifact: graphqlite.dylib | |
| artifact-name: graphqlite-macos-arm64.dylib | |
| - os: macos-14 | |
| arch: x86_64 | |
| artifact: graphqlite.dylib | |
| artifact-name: graphqlite-macos-x86_64.dylib | |
| - os: windows-latest | |
| artifact: graphqlite.dll | |
| artifact-name: graphqlite-windows-x86_64.dll | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup MSYS2 (Windows) | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-sqlite3 | |
| mingw-w64-x86_64-libsystre | |
| bison | |
| flex | |
| make | |
| - name: Install dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y bison flex libsqlite3-dev | |
| - name: Install dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install bison flex sqlite | |
| echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH | |
| echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH | |
| echo "HOMEBREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV | |
| echo "SQLITE_PREFIX=$(brew --prefix sqlite)" >> $GITHUB_ENV | |
| - name: Build extension (Linux) | |
| if: runner.os == 'Linux' | |
| run: make extension RELEASE=1 | |
| - name: Build extension (macOS arm64) | |
| if: runner.os == 'macOS' && matrix.arch == 'arm64' | |
| run: make extension RELEASE=1 EXTRA_INCLUDES="-I$HOMEBREW_PREFIX/include" EXTRA_LIBS="-L$HOMEBREW_PREFIX/lib" | |
| - name: Build extension (macOS x86_64 cross-compile) | |
| if: runner.os == 'macOS' && matrix.arch == 'x86_64' | |
| run: make extension RELEASE=1 CC="clang -arch x86_64" EXTRA_INCLUDES="-I$HOMEBREW_PREFIX/include" EXTRA_LIBS="-L$HOMEBREW_PREFIX/lib" | |
| - name: Build extension (Windows) | |
| if: runner.os == 'Windows' | |
| run: make extension RELEASE=1 | |
| # Python binding tests | |
| - name: Set up Python (Linux/Windows) | |
| if: runner.os != 'macOS' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install and test Python bindings (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| pip install -e "./bindings/python[dev]" | |
| cd bindings/python && pytest tests/ -v | |
| - name: Install and test Python bindings (macOS) | |
| if: runner.os == 'macOS' && matrix.arch == 'arm64' | |
| run: | | |
| # Use Homebrew Python which supports extension loading | |
| brew install python@3.11 | |
| $(brew --prefix python@3.11)/libexec/bin/python -m pip install -e "./bindings/python[dev]" | |
| DYLD_LIBRARY_PATH="$SQLITE_PREFIX/lib:$DYLD_LIBRARY_PATH" $(brew --prefix python@3.11)/libexec/bin/python -m pytest bindings/python/tests/ -v | |
| - name: Install and test Python bindings (Windows) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: | | |
| pip install -e "./bindings/python[dev]" | |
| cd bindings/python && pytest tests/ -v | |
| # Rust binding tests (skip for cross-compiled x86_64) | |
| - name: Install Rust toolchain | |
| if: matrix.arch != 'x86_64' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Test Rust bindings | |
| if: matrix.arch != 'x86_64' | |
| working-directory: bindings/rust | |
| shell: bash | |
| run: cargo test -- --test-threads=1 | |
| - name: Rename artifact | |
| run: cp build/${{ matrix.artifact }} build/${{ matrix.artifact-name }} | |
| - name: Upload extension artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: build/${{ matrix.artifact-name }} | |
| # Build platform-specific Python wheels | |
| build-wheels: | |
| needs: build-and-test | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| artifact: graphqlite-linux-x86_64.so | |
| extension: graphqlite.so | |
| wheel_tag: manylinux_2_17_x86_64.manylinux2014_x86_64 | |
| - os: macos-14 | |
| artifact: graphqlite-macos-arm64.dylib | |
| extension: graphqlite.dylib | |
| wheel_tag: macosx_11_0_arm64 | |
| - os: windows-latest | |
| artifact: graphqlite-windows-x86_64.dll | |
| extension: graphqlite.dll | |
| wheel_tag: win_amd64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Download extension artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }} | |
| path: bindings/python/src/graphqlite/ | |
| - name: Rename extension to standard name | |
| working-directory: bindings/python/src/graphqlite | |
| run: mv ${{ matrix.artifact }} ${{ matrix.extension }} | |
| shell: bash | |
| - name: Install build tools | |
| run: pip install build wheel | |
| - name: Build wheel | |
| working-directory: bindings/python | |
| run: python -m build --wheel | |
| - name: Retag wheel with platform | |
| working-directory: bindings/python/dist | |
| run: | | |
| for whl in *.whl; do | |
| python -m wheel tags --platform-tag=${{ matrix.wheel_tag }} "$whl" | |
| rm "$whl" | |
| done | |
| shell: bash | |
| - name: List wheels | |
| run: ls -la bindings/python/dist/ | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.wheel_tag }} | |
| path: bindings/python/dist/*.whl | |
| publish-python: | |
| needs: build-wheels | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Download all wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheel-* | |
| path: dist/ | |
| merge-multiple: true | |
| - name: Install build tools | |
| run: pip install build twine | |
| - name: Build source distribution | |
| working-directory: bindings/python | |
| run: python -m build --sdist | |
| - name: Copy sdist to dist | |
| run: cp bindings/python/dist/*.tar.gz dist/ | |
| - name: List distributions | |
| run: ls -la dist/ | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: twine upload dist/* | |
| publish-rust: | |
| needs: build-and-test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Publish to crates.io | |
| working-directory: bindings/rust | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish --allow-dirty | |
| create-release: | |
| needs: [build-and-test, build-wheels, publish-python, publish-rust] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| artifacts/**/* | |
| generate_release_notes: true |