From 1057b0efffde0512f303bbe3bd9e4ef31a3de90f Mon Sep 17 00:00:00 2001 From: Luqman Date: Thu, 2 Feb 2023 21:46:23 +0100 Subject: [PATCH] Automate Publishing to Pypi (#4115) Automate Upload to Pypi --------- Co-authored-by: James Maslek --- .github/workflows/pypi.yml | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000000..59b61111ace --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,79 @@ +name: Deploy to PyPI + +on: + push: + branches: + - release/* + - main + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy-test-pypi: + name: Build and publish distributions 📦 to PyPI and TestPyPI + if: startsWith(github.ref, 'refs/heads/release/') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + deploy-pypi: + name: Build and publish distributions 📦 to PyPI and TestPyPI + if: startsWith(github.ref, 'refs/heads/main') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }}