|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + build_wheels: |
| 7 | + name: Build wheels on ${{ matrix.os }} |
| 8 | + runs-on: ${{ matrix.os }} |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: [ubuntu-20.04, macOS-10.15] |
| 12 | + # Exclude windows-2019 |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + |
| 17 | + |
| 18 | + - name: Build wheels |
| 19 | + uses: pypa/cibuildwheel@v2.7.0 |
| 20 | + # to supply options, put them in 'env', like: |
| 21 | + env: |
| 22 | + CIBW_ARCHS_MACOS: x86_64 universal2 |
| 23 | + CIBW_SKIP: pp* |
| 24 | + |
| 25 | + - uses: actions/upload-artifact@v3 |
| 26 | + with: |
| 27 | + path: ./wheelhouse/*.whl |
| 28 | + |
| 29 | + build_sdist: |
| 30 | + name: Build source distribution |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v3 |
| 34 | + |
| 35 | + - name: Build sdist |
| 36 | + run: pipx run build --sdist |
| 37 | + |
| 38 | + - uses: actions/upload-artifact@v3 |
| 39 | + with: |
| 40 | + path: dist/*.tar.gz |
| 41 | + |
| 42 | + upload_pypi: |
| 43 | + needs: [build_wheels, build_sdist] |
| 44 | + runs-on: ubuntu-latest |
| 45 | + # upload to PyPI on every tag starting with 'v' |
| 46 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 47 | + # alternatively, to publish when a GitHub Release is created, use the following rule: |
| 48 | + # if: github.event_name == 'release' && github.event.action == 'published' |
| 49 | + steps: |
| 50 | + - uses: actions/download-artifact@v3 |
| 51 | + with: |
| 52 | + # unpacks default artifact into dist/ |
| 53 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 54 | + name: artifact |
| 55 | + path: dist |
| 56 | + |
| 57 | + - uses: pypa/gh-action-pypi-publish@v1.5.0 |
| 58 | + with: |
| 59 | + user: __token__ |
| 60 | + password: ${{ secrets.PYPI_API_TOKEN }} |
| 61 | + # To test: repository_url: https://test.pypi.org/legacy/ |
0 commit comments