|
| 1 | +name: Build and upload to PyPI |
| 2 | + |
| 3 | +# Build on every branch push, tag push, and pull request change: |
| 4 | +#on: [push, pull_request] |
| 5 | +# Alternatively, to publish when a (published) GitHub Release is created, use the following: |
| 6 | +on: |
| 7 | + release: |
| 8 | + types: |
| 9 | + - published |
| 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-latest, windows-latest, macos-latest] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Setup C/C++ Compiler |
| 21 | + id: install_cc |
| 22 | + |
| 23 | + with: |
| 24 | + compiler: gcc #clang |
| 25 | + |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Build wheels |
| 30 | + env: |
| 31 | + CC: '${{ steps.install_cc.outputs.cc }}' |
| 32 | + CXX: '${{ steps.install_cc.outputs.cxx }}' |
| 33 | + |
| 34 | + |
| 35 | + - uses: actions/upload-artifact@v3 |
| 36 | + with: |
| 37 | + path: ./wheelhouse/*.whl |
| 38 | + |
| 39 | + build_sdist: |
| 40 | + name: Build source distribution |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v3 |
| 44 | + |
| 45 | + - name: Build sdist |
| 46 | + run: pipx run build --sdist |
| 47 | + |
| 48 | + - uses: actions/upload-artifact@v3 |
| 49 | + with: |
| 50 | + path: dist/*.tar.gz |
| 51 | + |
| 52 | + upload_pypi: |
| 53 | + needs: [build_wheels, build_sdist] |
| 54 | + runs-on: ubuntu-latest |
| 55 | + # upload to PyPI on every tag starting with 'v' |
| 56 | + #if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 57 | + # alternatively, to publish when a GitHub Release is created, use the following rule: |
| 58 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 59 | + steps: |
| 60 | + - uses: actions/download-artifact@v3 |
| 61 | + with: |
| 62 | + # unpacks default artifact into dist/ |
| 63 | + # if `name: artifact` is omitted, the action will create extra parent dir |
| 64 | + name: artifact |
| 65 | + path: dist |
| 66 | + |
| 67 | + |
| 68 | + with: |
| 69 | + user: __token__ |
| 70 | + password: ${{ secrets.pypi_password }} |
| 71 | + # To test: repository_url: https://test.pypi.org/legacy/ |
0 commit comments