From 93d810f91dd373428807ccd307e156614c1fdfea Mon Sep 17 00:00:00 2001 From: Zaki Ali Date: Tue, 27 Aug 2024 17:12:03 -0700 Subject: [PATCH] chore: Updated publish workflow to only push if version tag updated --- .github/workflows/pypi_release.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pypi_release.yaml b/.github/workflows/pypi_release.yaml index af775d9..b7af3d5 100644 --- a/.github/workflows/pypi_release.yaml +++ b/.github/workflows/pypi_release.yaml @@ -23,8 +23,19 @@ jobs: - name: Build with UV run: uvx --from build pyproject-build --installer uv + - name: Check version + id: check_version + run: | + NEW_VERSION=$(echo "$GITHUB_REF" | sed -E 's/refs\/tags\/v(.+)/\1/') + CURRENT_VERSION=$(python -c "import toml; from packaging.version import parse as parse_version; print(parse_version(toml.load('pyproject.toml')['project']['version']))") + if python -c "from packaging.version import parse as parse_version; exit(0 if parse_version('$NEW_VERSION') > parse_version('$CURRENT_VERSION') else 1)"; then + echo "::set-output name=new_version::true" + else + echo "::set-output name=new_version::false" + - name: Publish uses: pypa/gh-action-pypi-publish@v1.4.2 + if: startsWith(github.ref, 'refs/tags/v') && steps.check_version.outputs.new_version == 'true' with: user: __token__ password: ${{ secrets.PYPI_TOKEN_TEMP }}