name: Test, Build, and Publish on: push: branches: - main pull_request: branches: - "**" jobs: test-build-publish: runs-on: ubuntu-latest name: Test, Build and Publish steps: - name: Checkout repo uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.11" - name: Install uv run: pip install uv - name: Run tests run: python test.py - name: Build package run: uv build - name: Publish to PyPI if: github.ref == 'refs/heads/main' 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 }}