Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 53 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Release

permissions:
contents: write
pull-requests: write

on:
workflow_dispatch:
Expand All @@ -10,14 +11,18 @@ on:
description: Release version (e.g., 1.2.3)
required: true
type: string
pull_request:
types: [closed]
branches:
- main

jobs:
release:
create-release-pr:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -35,18 +40,60 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Create release branch
run: |
git checkout -b release/${{ inputs.version }}
- name: Build Changelog
run: uv run towncrier build --yes --version ${{ inputs.version }}
- name: Commit Changelog
run: |
git add CHANGELOG.md
git add news/ || true
git commit -m "Release ${{ inputs.version }}"
- name: Push release branch
run: git push origin release/${{ inputs.version }}
- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head release/${{ inputs.version }} \
--title "Release ${{ inputs.version }}" \
--body "This PR contains the changelog for version ${{ inputs.version }}.

Once merged, a tag \`v${{ inputs.version }}\` will be automatically created and a GitHub release will be published."
create-tag-and-release:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/') && github.event.pull_request.user.login
== 'github-actions[bot]'
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
version-file: pyproject.toml
- name: Extract version from branch name
id: extract_version
run: |
VERSION="${{ github.head_ref }}"
VERSION="${VERSION#release/}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Create and Push Tag
run: |
git tag -a "v${{ inputs.version }}" -m "Version ${{ inputs.version }}"
git push origin HEAD:${{ github.ref_name }}
git push origin "v${{ inputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.extract_version.outputs.version }}"
git push origin "v${{ steps.extract_version.outputs.version }}"
- name: Create wheel
run: uv build -o dist/ .
- name: Publish package distributions to PyPI
Expand Down