Skip to content

Commit e249b11

Browse files
committed
fix(ci): skip pub on PyPi if version already present
1 parent eb611d1 commit e249b11

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/maturin.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ jobs:
238238
runs-on: ubuntu-latest
239239
needs: [linux, musllinux, windows, macos, sdist]
240240
outputs:
241-
has_pyfaup_tag: ${{ steps.check-tag.outputs.has_pyfaup_tag }}
241+
publish: ${{ steps.check-pypi.outputs.publish }}
242242
steps:
243243
- uses: actions/checkout@v6
244244
with:
@@ -255,12 +255,25 @@ jobs:
255255
else
256256
echo "has_pyfaup_tag=false" >> $GITHUB_OUTPUT
257257
fi
258+
- name: Check if version exists on PyPI
259+
if: steps.check-tag.outputs.has_pyfaup_tag == 'true'
260+
id: check-pypi
261+
run: |
262+
set -euxo pipefail
263+
VERSION=$(git tag --points-at HEAD | grep 'pyfaup-rs' | head -1 | cut -d'-' -f3)
264+
RESPONSE=$(curl -s "https://pypi.org/pypi/pyfaup-rs/$VERSION/json" | jq '.message')
265+
if echo "$RESPONSE" | grep -qEi "Not Found"; then
266+
echo "publish=true" >> $GITHUB_OUTPUT
267+
else
268+
echo "Version $VERSION already exists on PyPI"
269+
echo "publish=false" >> $GITHUB_OUTPUT
270+
fi
258271
259272
release:
260273
name: Release
261274
runs-on: ubuntu-latest
262275
needs: [check-tag]
263-
if: needs.check-tag.outputs.has_pyfaup_tag == 'true'
276+
if: needs.check-tag.publish == 'true'
264277
permissions:
265278
# Use to sign the release artifacts
266279
id-token: write

0 commit comments

Comments
 (0)