From 461a355300cca4dcfcbb2af912a1b1611ab2413e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Borgna?= <121866228+aborgna-q@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:15:03 +0200 Subject: [PATCH] ci: build wheels and publish to pypi (#191) Builds the wheels on every push to main, and publishes the to pypi when pushing a new version tag --- .github/workflows/python-wheels.yml | 50 +++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/python-wheels.yml diff --git a/.github/workflows/python-wheels.yml b/.github/workflows/python-wheels.yml new file mode 100644 index 00000000..678a1517 --- /dev/null +++ b/.github/workflows/python-wheels.yml @@ -0,0 +1,50 @@ +name: Build and publish python wheels + +on: + workflow_dispatch: + push: + branches: + - main + tags: + - 'v**' + +jobs: + build-publish: + name: Build and publish wheels + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.4 + - name: Install poetry + run: pipx install poetry + - name: Set up Python '3.10' + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: "poetry" + + - name: Build sdist and wheels + run: poetry build + + - name: Upload the built packages as artifacts + uses: actions/upload-artifact@v4 + with: + name: build-guppylang-sdist + path: | + dist/*.tar.gz + dist/*.whl + + - name: Publish to test instance of PyPI (dry-run) + if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_type == 'branch' ) }} + run: | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ + poetry config pypi-token.test-pypi ${{ secrets.PYPI_TEST_PUBLISH }} + poetry publish -r test-pypi --skip-existing --dry-run + + - name: Publish to PyPI + if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }} + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_PUBLISH }} + poetry publish --skip-existing