|
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + build_wheels: |
| 13 | + name: Build wheels on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + os: [ubuntu-20.04, windows-2019, macos-10.15] |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + with: |
| 22 | + submodules: recursive |
| 23 | + - uses: actions/setup-python@v2 |
| 24 | + name: Install Python |
| 25 | + with: |
| 26 | + python-version: 3.8 |
| 27 | + - name: Set up QEMU |
| 28 | + if: runner.os == 'Linux' |
| 29 | + uses: docker/setup-qemu-action@v1 |
| 30 | + with: |
| 31 | + platforms: all |
| 32 | + - name: Build wheels |
| 33 | + uses: pypa/cibuildwheel@v2.0.0 |
| 34 | + env: |
| 35 | + CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 |
| 36 | + CIBW_BUILD: cp3?-* |
| 37 | + CIBW_SKIP: cp27-* cp36-* *-win32 *-manylinux_i686 |
| 38 | + CIBW_ARCHS_LINUX: x86_64 aarch64 |
| 39 | + CIBW_ARCHS_MACOS: x86_64 arm64 universal2 |
| 40 | + CIBW_BEFORE_BUILD: pip install pybind11 |
| 41 | + CIBW_TEST_COMMAND: pytest {project}/tests |
| 42 | + CIBW_TEST_REQUIRES: pytest numpy |
| 43 | + - uses: actions/upload-artifact@v2 |
| 44 | + with: |
| 45 | + path: ./wheelhouse/*.whl |
| 46 | + |
| 47 | + build_sdist: |
| 48 | + name: Build source distribution |
| 49 | + runs-on: ubuntu-latest |
| 50 | + steps: |
| 51 | + - uses: actions/checkout@v2 |
| 52 | + with: |
| 53 | + submodules: recursive |
| 54 | + - uses: actions/setup-python@v2 |
| 55 | + name: Install Python |
| 56 | + with: |
| 57 | + python-version: 3.8 |
| 58 | + - name: Build sdist |
| 59 | + run: python setup.py sdist |
| 60 | + - uses: actions/upload-artifact@v2 |
| 61 | + with: |
| 62 | + path: dist/*.tar.gz |
| 63 | + |
| 64 | + upload_pypi: |
| 65 | + needs: [build_wheels, build_sdist] |
| 66 | + runs-on: ubuntu-latest |
| 67 | + # upload to PyPI on every tag starting with 'v' |
| 68 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 69 | + steps: |
| 70 | + - uses: actions/download-artifact@v2 |
| 71 | + with: |
| 72 | + name: artifact |
| 73 | + path: dist |
| 74 | + - uses: pypa/gh-action-pypi-publish@v1.4.2 |
| 75 | + with: |
| 76 | + user: __token__ |
| 77 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments