1*dd8ab4d9SJed Brownname: Python Wheels 2*dd8ab4d9SJed Brown 3*dd8ab4d9SJed Brown# Build on every branch push, tag push, and pull request change: 4*dd8ab4d9SJed Brownon: [push, pull_request] 5*dd8ab4d9SJed Brown# Alternatively, to publish when a (published) GitHub Release is created, use the following: 6*dd8ab4d9SJed Brown# on: 7*dd8ab4d9SJed Brown# push: 8*dd8ab4d9SJed Brown# pull_request: 9*dd8ab4d9SJed Brown# release: 10*dd8ab4d9SJed Brown# types: 11*dd8ab4d9SJed Brown# - published 12*dd8ab4d9SJed Brown 13*dd8ab4d9SJed Brownjobs: 14*dd8ab4d9SJed Brown build_wheels: 15*dd8ab4d9SJed Brown name: Build wheels on ${{ matrix.os }} 16*dd8ab4d9SJed Brown if: >- 17*dd8ab4d9SJed Brown (github.event_name == 'pull_request' && 18*dd8ab4d9SJed Brown contains(github.event.pull_request.labels.*.name, 'release preparation')) || 19*dd8ab4d9SJed Brown github.event_name == 'workflow_dispatch' || 20*dd8ab4d9SJed Brown (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) 21*dd8ab4d9SJed Brown runs-on: ${{ matrix.os }} 22*dd8ab4d9SJed Brown strategy: 23*dd8ab4d9SJed Brown matrix: 24*dd8ab4d9SJed Brown # windows-2019, macos-11 25*dd8ab4d9SJed Brown os: [ubuntu-20.04] 26*dd8ab4d9SJed Brown 27*dd8ab4d9SJed Brown steps: 28*dd8ab4d9SJed Brown - uses: actions/checkout@v3 29*dd8ab4d9SJed Brown 30*dd8ab4d9SJed Brown - name: Build wheels 31*dd8ab4d9SJed Brown uses: pypa/cibuildwheel@v2.11.3 32*dd8ab4d9SJed Brown 33*dd8ab4d9SJed Brown - uses: actions/upload-artifact@v3 34*dd8ab4d9SJed Brown with: 35*dd8ab4d9SJed Brown path: ./wheelhouse/*.whl 36*dd8ab4d9SJed Brown 37*dd8ab4d9SJed Brown build_sdist: 38*dd8ab4d9SJed Brown name: Build source distribution 39*dd8ab4d9SJed Brown if: >- 40*dd8ab4d9SJed Brown (github.event_name == 'pull_request' && 41*dd8ab4d9SJed Brown contains(github.event.pull_request.labels.*.name, 'release preparation')) || 42*dd8ab4d9SJed Brown github.event_name == 'workflow_dispatch' || 43*dd8ab4d9SJed Brown (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) 44*dd8ab4d9SJed Brown runs-on: ubuntu-latest 45*dd8ab4d9SJed Brown steps: 46*dd8ab4d9SJed Brown - uses: actions/checkout@v3 47*dd8ab4d9SJed Brown 48*dd8ab4d9SJed Brown - name: Build sdist 49*dd8ab4d9SJed Brown run: pipx run build --sdist 50*dd8ab4d9SJed Brown 51*dd8ab4d9SJed Brown - uses: actions/upload-artifact@v3 52*dd8ab4d9SJed Brown with: 53*dd8ab4d9SJed Brown path: dist/*.tar.gz 54*dd8ab4d9SJed Brown 55*dd8ab4d9SJed Brown upload_pypi: 56*dd8ab4d9SJed Brown needs: [build_wheels, build_sdist] 57*dd8ab4d9SJed Brown runs-on: ubuntu-latest 58*dd8ab4d9SJed Brown # upload to PyPI on every tag starting with 'v' 59*dd8ab4d9SJed Brown if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') 60*dd8ab4d9SJed Brown # alternatively, to publish when a GitHub Release is created, use the following rule: 61*dd8ab4d9SJed Brown # if: github.event_name == 'release' && github.event.action == 'published' 62*dd8ab4d9SJed Brown steps: 63*dd8ab4d9SJed Brown - uses: actions/download-artifact@v3 64*dd8ab4d9SJed Brown with: 65*dd8ab4d9SJed Brown # unpacks default artifact into dist/ 66*dd8ab4d9SJed Brown # if `name: artifact` is omitted, the action will create extra parent dir 67*dd8ab4d9SJed Brown name: artifact 68*dd8ab4d9SJed Brown path: dist 69*dd8ab4d9SJed Brown 70*dd8ab4d9SJed Brown - uses: pypa/gh-action-pypi-publish@v1.5.0 71*dd8ab4d9SJed Brown with: 72*dd8ab4d9SJed Brown user: __token__ 73*dd8ab4d9SJed Brown password: ${{ secrets.PYPI_TOKEN }} 74*dd8ab4d9SJed Brown # To test: repository_url: https://test.pypi.org/legacy/ 75