|
5 | 5 | workflow_dispatch: # Allow manual triggering |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - pypi: |
9 | | - name: Publish to PyPI |
| 8 | + # Build the Rust native extension wheels for each platform/arch |
| 9 | + build-rust-wheels: |
| 10 | + name: Build Rust wheels (${{ matrix.os }}, ${{ matrix.target }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + # Linux x86_64 |
| 17 | + - os: ubuntu-latest |
| 18 | + target: x86_64 |
| 19 | + # Linux aarch64 |
| 20 | + - os: ubuntu-latest |
| 21 | + target: aarch64 |
| 22 | + # macOS x86_64 |
| 23 | + - os: macos-13 |
| 24 | + target: x86_64 |
| 25 | + # macOS aarch64 (Apple Silicon) |
| 26 | + - os: macos-14 |
| 27 | + target: aarch64 |
| 28 | + # Windows x86_64 |
| 29 | + - os: windows-latest |
| 30 | + target: x64 |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + |
| 34 | + - name: Set up Python |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.10' |
| 38 | + |
| 39 | + - name: Build wheels |
| 40 | + uses: PyO3/maturin-action@v1 |
| 41 | + with: |
| 42 | + target: ${{ matrix.target }} |
| 43 | + args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 |
| 44 | + manylinux: auto |
| 45 | + working-directory: rust |
| 46 | + |
| 47 | + - name: Upload wheels |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: wheels-${{ matrix.os }}-${{ matrix.target }} |
| 51 | + path: rust/dist/*.whl |
| 52 | + |
| 53 | + # Build the Rust sdist (fallback for platforms without prebuilt wheels) |
| 54 | + build-rust-sdist: |
| 55 | + name: Build Rust sdist |
| 56 | + runs-on: ubuntu-latest |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v4 |
| 59 | + |
| 60 | + - name: Build sdist |
| 61 | + uses: PyO3/maturin-action@v1 |
| 62 | + with: |
| 63 | + command: sdist |
| 64 | + args: --out dist |
| 65 | + working-directory: rust |
| 66 | + |
| 67 | + - name: Upload sdist |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: rust-sdist |
| 71 | + path: rust/dist/*.tar.gz |
| 72 | + |
| 73 | + # Build the main Python package |
| 74 | + build-python: |
| 75 | + name: Build Python package |
10 | 76 | runs-on: ubuntu-latest |
11 | | - environment: |
12 | | - name: pypi |
13 | | - url: https://pypi.org/p/vector-benchmark |
14 | | - permissions: |
15 | | - contents: read |
16 | | - id-token: write |
17 | 77 | steps: |
18 | 78 | - uses: actions/checkout@v4 |
19 | 79 |
|
|
37 | 97 | pip install twine |
38 | 98 | twine check dist/* |
39 | 99 |
|
40 | | - - name: Publish to PyPI |
| 100 | + - name: Upload Python dist |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: python-dist |
| 104 | + path: dist/* |
| 105 | + |
| 106 | + # Publish everything to PyPI |
| 107 | + publish: |
| 108 | + name: Publish to PyPI |
| 109 | + runs-on: ubuntu-latest |
| 110 | + needs: [build-rust-wheels, build-rust-sdist, build-python] |
| 111 | + environment: |
| 112 | + name: pypi |
| 113 | + url: https://pypi.org/p/vector-benchmark |
| 114 | + permissions: |
| 115 | + contents: read |
| 116 | + id-token: write |
| 117 | + steps: |
| 118 | + - name: Download all artifacts |
| 119 | + uses: actions/download-artifact@v4 |
| 120 | + with: |
| 121 | + path: all-dist |
| 122 | + |
| 123 | + - name: Collect dist files |
| 124 | + run: | |
| 125 | + mkdir -p dist |
| 126 | + # Rust wheels and sdist |
| 127 | + find all-dist/wheels-* -name '*.whl' -exec cp {} dist/ \; 2>/dev/null || true |
| 128 | + find all-dist/rust-sdist -name '*.tar.gz' -exec cp {} dist/ \; 2>/dev/null || true |
| 129 | + # Python package |
| 130 | + cp all-dist/python-dist/* dist/ |
| 131 | + echo "Packages to publish:" |
| 132 | + ls -la dist/ |
| 133 | +
|
| 134 | + - name: Publish Rust extension to PyPI |
| 135 | + uses: PyO3/maturin-action@v1 |
| 136 | + with: |
| 137 | + command: upload |
| 138 | + args: --non-interactive --skip-existing dist/vector_db_benchmark_rs* |
| 139 | + |
| 140 | + - name: Publish Python package to PyPI |
41 | 141 | env: |
42 | 142 | POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} |
43 | | - run: poetry publish |
| 143 | + run: | |
| 144 | + pip install poetry |
| 145 | + # Publish only the Python package (already built) |
| 146 | + pip install twine |
| 147 | + twine upload --skip-existing dist/vector_benchmark* dist/vector-benchmark* |
0 commit comments