Skip to content
Merged
Show file tree
Hide file tree
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
111 changes: 0 additions & 111 deletions .github/workflows/release-pr.yml

This file was deleted.

85 changes: 18 additions & 67 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,86 +1,37 @@
name: Release

# Triggered when a release PR (label "release", opened by release-pr.yml) is
# merged into main. Tags the merge commit and publishes a GitHub Release.
# No PyPI publish step.

on:
pull_request:
types: [closed]
push:
branches: [main]

permissions: {}
permissions:
contents: read

concurrency:
group: release
group: ${{ github.workflow }}-release-${{ github.ref_name }}
cancel-in-progress: false

jobs:
release:
name: Tag and publish GitHub Release
runs-on: ubuntu-latest
if: >-
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'release')
permissions:
contents: write

steps:
- name: Checkout main
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- name: Extract version from pyproject.toml
id: version
run: |
version=$(grep -m1 '^version = ' pyproject.toml | sed -E 's/version = "(.*)"/\1/')
if [ -z "$version" ]; then
echo "Could not extract version from pyproject.toml" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=v$version" >> "$GITHUB_OUTPUT"
ref: ${{ github.ref_name }}

- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- run: git reset --hard ${{ github.sha }}

- name: Create and push tag
env:
TAG: ${{ steps.version.outputs.tag }}
run: |
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists; nothing to do."
exit 0
fi
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"

- name: Extract release notes from CHANGELOG
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
# CHANGELOG.md sections look like "## v0.2.0 (YYYY-MM-DD)" or similar.
# Capture lines after the matching header up to the next "## " header.
awk -v ver="$VERSION" '
/^## / {
if (in_section) { exit }
if (index($0, ver) > 0) { in_section = 1; next }
}
in_section { print }
' CHANGELOG.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "(no CHANGELOG entry matched v${VERSION}; release notes generated by GitHub)" > release_notes.md
fi
- id: release
uses: python-semantic-release/python-semantic-release@v10.5.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"

- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ steps.version.outputs.tag }}
run: |
gh release create "$TAG" \
--title "$TAG" \
--notes-file release_notes.md
- uses: python-semantic-release/publish-action@v10.5.3
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ branch = "main"
# Strict semver: breaking changes bump major even pre-1.0.
major_on_zero = true
allow_zero_version = true
build_command = "uv build"

[tool.semantic_release.changelog.default_templates]
changelog_file = "CHANGELOG.md"
Expand Down
Loading