diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 853bb15..6aef2a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -48,31 +48,56 @@ jobs: pytest rm -rf build/ +jobs: build_wheels: - needs: build - if: ${{github.event_name == 'push'}} + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: - fail-fast: false matrix: - os: [ ubuntu-latest ] - python-version: [ 3.9, "3.10", "3.11", "3.12" ] + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: + - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Build wheels + uses: pypa/cibuildwheel@v2.20.0 + + - uses: actions/upload-artifact@v4 with: - python-version: ${{ matrix.python-version }} + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - name: build - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - run: | - pip install wheel - python setup.py sdist bdist_wheel - - name: publish - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + + - uses: pypa/gh-action-pypi-publish@release/v1 with: verbose: true password: ${{ secrets.PYPI_API_TOKEN }}