# Builds and publishes the package to PyPI from a release branch. # Creates a merge-back PR to sync release changes to main. name: "Release: Publish to PyPi" on: workflow_dispatch: permissions: contents: write pull-requests: write jobs: publish: runs-on: ubuntu-latest steps: - name: Validate branch run: | if [[ ! "${{ github.ref_name }}" =~ ^release/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Error: Must run from a release/v* branch (e.g., release/v0.3.0)" exit 1 fi - name: Extract version id: version run: | VERSION="${{ github.ref_name }}" VERSION="${VERSION#release/v}" echo "version=$VERSION" >> $GITHUB_OUTPUT echo "Publishing version: $VERSION" - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v4 with: version: "latest" - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.11" - name: Build package run: uv build - name: Publish to PyPI env: UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} run: uv publish - name: Create merge-back PR env: GH_TOKEN: ${{ secrets.RELEASE_PAT }} run: | gh pr create \ --base main \ --head "${{ github.ref_name }}" \ --title "chore: merge release v${{ steps.version.outputs.version }} to main" \ --body "Syncs version bump and CHANGELOG from release v${{ steps.version.outputs.version }} to main."