|
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + types: |
| 8 | + - published |
| 9 | + |
| 10 | +jobs: |
| 11 | + build_wheels: |
| 12 | + name: "Build wheels on ${{ matrix.os }}" |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 18 | + steps: |
| 19 | + - uses: "actions/checkout@v3" |
| 20 | + with: |
| 21 | + submodules: true |
| 22 | + - name: "Build wheels" |
| 23 | + uses: "pypa/cibuildwheel@v2.3.1" |
| 24 | + env: |
| 25 | + CIBW_SKIP: "pp38-win_amd64" # FIXME |
| 26 | + CIBW_BEFORE_BUILD: "pip install -U cython && ./update_cpp.sh" |
| 27 | + CIBW_BEFORE_BUILD_WINDOWS: "pip install -U cython && update_cpp.sh" |
| 28 | + CIBW_TEST_COMMAND: "echo Wheel installed successfully" |
| 29 | + - uses: "actions/upload-artifact@v3" |
| 30 | + with: |
| 31 | + path: "./wheelhouse/*.whl" |
| 32 | + |
| 33 | + make_sdist: |
| 34 | + name: "Build source distribution" |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: "actions/checkout@v2" |
| 38 | + with: |
| 39 | + submodules: true |
| 40 | + - name: "Install dependencies" |
| 41 | + run: "python -m pip install --upgrade cython" |
| 42 | + - name: "Rebuild CPP files using Cython" |
| 43 | + run: "./update_cpp.sh" |
| 44 | + - name: "Build source distribution" |
| 45 | + run: "pipx run build --sdist" |
| 46 | + - uses: "actions/upload-artifact@v3" |
| 47 | + with: |
| 48 | + path: "./dist/*.tar.gz" |
| 49 | + |
| 50 | + upload_to_pypi: |
| 51 | + name: "Upload to PyPI" |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: |
| 54 | + - build_wheels |
| 55 | + - make_sdist |
| 56 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 57 | + steps: |
| 58 | + - uses: "actions/download-artifact@v3" |
| 59 | + with: |
| 60 | + name: artifact |
| 61 | + path: dist |
| 62 | + - uses: "pypa/gh-action-pypi-publish@v1.5.0" |
| 63 | + with: |
| 64 | + user: __token__ |
| 65 | + password: ${{ secrets.pypi_password }} |
| 66 | + print_hash: true |
| 67 | + verbose: true |
0 commit comments