|
| 1 | +name: Build sdist and wheel and publish to PyPI and TestPyPI |
| 2 | + |
| 3 | +#on: [push, pull_request] |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - master |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_sdist: |
| 14 | + name: Build sdist |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + |
| 18 | + - uses: actions/checkout@master |
| 19 | + with: |
| 20 | + submodules: true |
| 21 | + |
| 22 | + - name: Install ninja |
| 23 | + run: pipx install ninja |
| 24 | + |
| 25 | + - name: Build sdist |
| 26 | + run: pipx run build --sdist |
| 27 | + |
| 28 | + - name: Check metadata |
| 29 | + run: pipx run twine check --strict dist/* |
| 30 | + |
| 31 | + - uses: actions/upload-artifact@v2 |
| 32 | + with: |
| 33 | + path: dist/*.tar.gz |
| 34 | + |
| 35 | + build_wheels: |
| 36 | + name: Build wheels on ${{ matrix.os }} |
| 37 | + runs-on: ${{ matrix.os }} |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + os: [ubuntu-latest, windows-latest, macOS-10.15] |
| 41 | + steps: |
| 42 | + |
| 43 | + - uses: actions/checkout@master |
| 44 | + with: |
| 45 | + submodules: true |
| 46 | + |
| 47 | + # Used to host cibuildwheel |
| 48 | + - uses: actions/setup-python@v3 |
| 49 | + |
| 50 | + - name: Build wheels |
| 51 | + |
| 52 | + # to supply options, put them in 'env', like: |
| 53 | + # env: |
| 54 | + # CIBW_SOME_OPTION: value |
| 55 | + |
| 56 | + - uses: actions/upload-artifact@v3 |
| 57 | + with: |
| 58 | + path: wheelhouse/*.whl |
| 59 | + |
| 60 | + build_arch_wheels: |
| 61 | + name: Build wheels on Linux ${{ matrix.arch }} |
| 62 | + runs-on: ubuntu-20.04 |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + arch: [aarch64] |
| 66 | + steps: |
| 67 | + |
| 68 | + - uses: actions/checkout@master |
| 69 | + with: |
| 70 | + submodules: true |
| 71 | + |
| 72 | + |
| 73 | + with: |
| 74 | + platforms: all |
| 75 | + |
| 76 | + |
| 77 | + env: |
| 78 | + CIBW_ARCHS: ${{ matrix.arch }} |
| 79 | + |
| 80 | + - name: Verify clean directory |
| 81 | + run: git diff --exit-code |
| 82 | + shell: bash |
| 83 | + |
| 84 | + - name: Upload wheels |
| 85 | + uses: actions/upload-artifact@v3 |
| 86 | + with: |
| 87 | + path: wheelhouse/*.whl |
| 88 | + |
| 89 | + upload_pypi: |
| 90 | + needs: [build_wheels, build_sdist] |
| 91 | + runs-on: ubuntu-latest |
| 92 | + environment: PyPI release |
| 93 | + if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') |
| 94 | + steps: |
| 95 | + |
| 96 | + - uses: actions/download-artifact@v3 |
| 97 | + with: |
| 98 | + # unpacks default artifact into dist/ |
| 99 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 100 | + name: artifact |
| 101 | + path: dist |
| 102 | + |
| 103 | + - name: Publish distribution to Test PyPI |
| 104 | + |
| 105 | + with: |
| 106 | + skip_existing: true |
| 107 | + user: __token__ |
| 108 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 109 | + repository_url: https://test.pypi.org/legacy/ |
| 110 | + |
| 111 | + - name: Publish distribution to PyPI |
| 112 | + if: startsWith(github.ref, 'refs/tags/v') |
| 113 | + |
| 114 | + with: |
| 115 | + user: __token__ |
| 116 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments