From e84fb2c77bd2bd97daf8ea3b410d6e1e83aedcad Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 14 May 2025 15:21:57 +0300 Subject: Improve workflow --- .github/workflows/build-test-publish.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to '.github') diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 9c7bf41..b70f1f1 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -33,6 +33,26 @@ jobs: - name: Publish to PyPI if: github.ref == 'refs/heads/main' - run: uv publish + run: | + set +e + + # Run uv publish and capture output + OUTPUT=$(uv publish 2>&1) + STATUS=$? + + set -eo pipefail + + echo "$OUTPUT" + + if [ $STATUS -eq 0 ]; then + echo "✅ Publish succeeded." + exit 0 + elif echo "$OUTPUT" | grep -q "400 File already exists"; then + echo "⚠️ Package version already exists on PyPI. Skipping publish." + exit 0 + else + echo "❌ Publish failed unexpectedly." + exit $STATUS + fi env: UV_PUBLISH_TOKEN: ${{ secrets.UV_PYPI_TOKEN }} -- cgit v1.3