# SPDX-FileCopyrightText: 2025 Alexander Kalinovsky # # SPDX-License-Identifier: Apache-2.0 name: Publish to TestPyPI on: release: types: [published] jobs: build-publish: # Only run on pre-releases (alpha, beta, rc, dev) # This workflow handles: v0.1.0rc1, v1.0.0a1, v2.3.4b2, v0.1.0dev1, etc. # IMPORTANT: This should NEVER run for stable releases like v0.1.0 # Use more specific patterns to avoid matching normal version numbers # Pattern: rc (release candidate), a followed by number (alpha), b followed by number (beta), dev if: contains(gitea.ref_name, 'rc') || contains(gitea.ref_name, 'a') || contains(gitea.ref_name, 'b') || contains(gitea.ref_name, 'dev') permissions: id-token: write contents: read runs-on: ubuntu-latest env: UV_INDEX_URL: https://test.pypi.org/simple/ UV_EXTRA_INDEX_URL: https://pypi.org/simple/ steps: - name: Checkout code uses: actions/checkout@v4 - name: Debug release info run: | echo "🔍 Release Debug Information:" echo "Tag/Ref: ${{ gitea.ref }}" echo "Tag name: ${{ gitea.ref_name }}" echo "Repository: ${{ gitea.repository }}" echo "Event type: ${{ gitea.event_name }}" echo "Workflow: TestPyPI" echo "" echo "📋 Condition Check:" echo "Contains 'rc': ${{ contains(gitea.ref_name, 'rc') }}" echo "Contains 'a': ${{ contains(gitea.ref_name, 'a') }}" echo "Contains 'b': ${{ contains(gitea.ref_name, 'b') }}" echo "Contains 'dev': ${{ contains(gitea.ref_name, 'dev') }}" echo "Should run: ${{ contains(gitea.ref_name, 'rc') || contains(gitea.ref_name, 'a') || contains(gitea.ref_name, 'b') || contains(gitea.ref_name, 'dev') }}" - name: Set up uv uses: astral-sh/setup-uv@v5 with: enable-cache: true python-version: "3.13" - name: Build wheel & sdist run: | uv build - name: Publish (TestPyPI) run: | uv publish --publish-url https://test.pypi.org/legacy/ --username __token__ --password ${{ secrets.TESTPYPI_API_TOKEN }}