Skip to content

Commit 7716a08

Browse files
jkebingerclaude
andauthored
Skip publish workflow if version already exists on PyPI (#11)
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 <noreply@anthropic.com>
1 parent ab19abf commit 7716a08

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/publish.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,36 @@ jobs:
2626
with:
2727
python-version: "3.10"
2828

29+
- name: Check if version already published
30+
id: version-check
31+
run: |
32+
VERSION=$(cat sdk_reforge/VERSION | tr -d '\n')
33+
echo "Current version: $VERSION"
34+
35+
# Check if this version exists on PyPI
36+
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/sdk-reforge/$VERSION/json")
37+
38+
if [ "$HTTP_STATUS" = "200" ]; then
39+
echo "Version $VERSION already exists on PyPI"
40+
echo "skip=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "Version $VERSION not found on PyPI, proceeding with publish"
43+
echo "skip=false" >> $GITHUB_OUTPUT
44+
fi
45+
2946
- name: Install Poetry
47+
if: steps.version-check.outputs.skip == 'false'
3048
uses: snok/install-poetry@v1
3149
with:
3250
virtualenvs-create: true
3351

3452
- name: Install dependencies
53+
if: steps.version-check.outputs.skip == 'false'
3554
run: |
3655
poetry install --no-interaction
3756
3857
- name: Run tests
58+
if: steps.version-check.outputs.skip == 'false'
3959
run: poetry run pytest
4060
env:
4161
REFORGE_INTEGRATION_TEST_SDK_KEY: ${{ secrets.REFORGE_INTEGRATION_TEST_SDK_KEY }}
@@ -44,9 +64,11 @@ jobs:
4464
IS_A_NUMBER: 1234
4565

4666
- name: Build package
67+
if: steps.version-check.outputs.skip == 'false'
4768
run: poetry build
4869

4970
- name: Publish to PyPI
71+
if: steps.version-check.outputs.skip == 'false'
5072
uses: pypa/gh-action-pypi-publish@release/v1
5173
with:
5274
packages-dir: dist/

0 commit comments

Comments
 (0)