|
| 1 | +name: Build Python wheels |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + tags: 'v*' |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-python-wheels: |
| 11 | + name: Build wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: [ |
| 17 | + ubuntu-latest, |
| 18 | + windows-latest, |
| 19 | + macos-13, # latest non-beta version |
| 20 | + ] # see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners |
| 21 | + python-version: [ |
| 22 | + '3.10', |
| 23 | + '3.11', |
| 24 | + '3.12', |
| 25 | + ] # see https://devguide.python.org/versions/ |
| 26 | + |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up rust |
| 31 | + uses: dtolnay/rust-toolchain@stable |
| 32 | + with: |
| 33 | + toolchain: stable |
| 34 | + |
| 35 | + - name: Set up Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: ${{ matrix.python-version }} |
| 39 | + architecture: x64 |
| 40 | + |
| 41 | + - name: Install maturin |
| 42 | + run: python -m pip install maturin |
| 43 | + |
| 44 | + - name: Build source distribution # do this only once |
| 45 | + run: | |
| 46 | + cd lakers-python |
| 47 | + maturin build --sdist --out wheelhouse |
| 48 | + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' |
| 49 | + |
| 50 | + - name: Build wheels |
| 51 | + run: | |
| 52 | + cd lakers-python |
| 53 | + maturin build --release --out wheelhouse |
| 54 | +
|
| 55 | + - uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: wheel-${{ matrix.os }}-python-${{ matrix.python-version }} |
| 58 | + path: ./lakers-python/wheelhouse/lakers_python* |
| 59 | + |
| 60 | + release: |
| 61 | + runs-on: ubuntu-latest |
| 62 | + needs: [build-python-wheels] |
| 63 | + if: >- |
| 64 | + github.event_name == 'push' && |
| 65 | + startsWith(github.event.ref, 'refs/tags') |
| 66 | +
|
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: set up python |
| 71 | + uses: actions/setup-python@v5 |
| 72 | + with: |
| 73 | + python-version: '3.10' |
| 74 | + |
| 75 | + - run: pip install -U twine |
| 76 | + |
| 77 | + - name: get wheelhouse artifacts |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + path: wheelhouse |
| 81 | + |
| 82 | + - run: ls -lah ./wheelhouse/*/lakers_python* |
| 83 | + - run: twine check ./wheelhouse/*/lakers_python* |
| 84 | + |
| 85 | + - name: upload to pypi |
| 86 | + run: twine upload ./wheelhouse/*/lakers_python* |
| 87 | + env: |
| 88 | + TWINE_USERNAME: __token__ |
| 89 | + TWINE_PASSWORD: ${{ secrets.PYPI_UPLOAD_TOKEN }} |
0 commit comments