From 5a84cde3587703c2a5edba840d25b76c23da9b08 Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Tue, 6 Aug 2024 10:46:47 +0200 Subject: [PATCH] Add GitHub Actions workflow for deploying wheels on PyPI --- .../workflows/{build_wheels.yml => build.yml} | 3 +- .github/workflows/build_deploy.yml | 60 +++++++++++++++++++ .../{python-package.yml => test.yml} | 0 3 files changed, 62 insertions(+), 1 deletion(-) rename .github/workflows/{build_wheels.yml => build.yml} (95%) create mode 100644 .github/workflows/build_deploy.yml rename .github/workflows/{python-package.yml => test.yml} (100%) diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build.yml similarity index 95% rename from .github/workflows/build_wheels.yml rename to .github/workflows/build.yml index 4f238ff..ed18264 100644 --- a/.github/workflows/build_wheels.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,7 @@ name: Build -on: [push, pull_request] +on: + workflow_dispatch: jobs: build_wheels: diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/build_deploy.yml new file mode 100644 index 0000000..7708a63 --- /dev/null +++ b/.github/workflows/build_deploy.yml @@ -0,0 +1,60 @@ +name: Build and upload to PyPI + +on: + workflow_dispatch: + release: + types: + - published + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # 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 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.20.0 + + - uses: actions/upload-artifact@v4 + with: + 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 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 == 'release' && github.event.action == 'published' + 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: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/test.yml similarity index 100% rename from .github/workflows/python-package.yml rename to .github/workflows/test.yml