From b59449d91188cb639452021eaa6fc063ace58c41 Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Wed, 24 Sep 2025 12:24:48 -0500 Subject: [PATCH] Skip publish workflow if version already exists on PyPI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added early version check that queries PyPI API to see if current version already exists. If so, skips all expensive steps (poetry install, tests, build) and exits early. This prevents unnecessary CI runs and potential publish conflicts when the same version is pushed multiple times to main. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/publish.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a50df7e..5551f08 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,16 +26,36 @@ jobs: with: python-version: "3.10" + - name: Check if version already published + id: version-check + run: | + VERSION=$(cat sdk_reforge/VERSION | tr -d '\n') + echo "Current version: $VERSION" + + # Check if this version exists on PyPI + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/sdk-reforge/$VERSION/json") + + if [ "$HTTP_STATUS" = "200" ]; then + echo "Version $VERSION already exists on PyPI" + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "Version $VERSION not found on PyPI, proceeding with publish" + echo "skip=false" >> $GITHUB_OUTPUT + fi + - name: Install Poetry + if: steps.version-check.outputs.skip == 'false' uses: snok/install-poetry@v1 with: virtualenvs-create: true - name: Install dependencies + if: steps.version-check.outputs.skip == 'false' run: | poetry install --no-interaction - name: Run tests + if: steps.version-check.outputs.skip == 'false' run: poetry run pytest env: REFORGE_INTEGRATION_TEST_SDK_KEY: ${{ secrets.REFORGE_INTEGRATION_TEST_SDK_KEY }} @@ -44,9 +64,11 @@ jobs: IS_A_NUMBER: 1234 - name: Build package + if: steps.version-check.outputs.skip == 'false' run: poetry build - name: Publish to PyPI + if: steps.version-check.outputs.skip == 'false' uses: pypa/gh-action-pypi-publish@release/v1 with: packages-dir: dist/