From bed855de94aab55370b650205bd8531d99ad730c Mon Sep 17 00:00:00 2001 From: Emily Price Date: Sun, 17 Nov 2024 11:51:47 +0000 Subject: [PATCH] Add live pypi publish workflow --- .github/workflows/publish-to-pypi.yml | 43 ++++++++++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..cbd3ac5 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,43 @@ +name: Publish Python 🐍 distribution 📦 to PyPI +on: push +jobs: + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install hatch + uses: pypa/hatch@install + - name: Build a binary wheel and a source tarball + run: hatch build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/datapoint + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml index d32b33e..716858e 100644 --- a/.github/workflows/publish-to-test-pypi.yml +++ b/.github/workflows/publish-to-test-pypi.yml @@ -1,4 +1,4 @@ -name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI +name: Publish Python 🐍 distribution 📦 to TestPyPI on: push jobs: build: