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/