From 1bfdd4aeab041bfb34609df61029aecb922787d2 Mon Sep 17 00:00:00 2001 From: Martin Proks Date: Thu, 12 Sep 2024 16:35:40 +0200 Subject: [PATCH] feat: added automatic release for pypi --- .github/workflows/release.yml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7739a81 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: release + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - name: Checkout the repository + uses: actions/checkout@main + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v2 + with: + version: "latest" + enable-cache: true + + - name: Install Python + run: uv python install + + - name: Install pypa/build + run: uv build + + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish 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/scanvi-explainer + 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 package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1