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
17 changes: 11 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Refactor / cleanup
- [ ] Documentation
- [ ] Build / CI / tooling
<!--
Add a release label to this PR from the Labels section of the PR sidebar
(not a prefix in the PR title or commit message). It sets the release notes section and the version bump:
breaking -> major
feature / enhancement -> minor
bug / fix -> patch
chore / ci / dependencies / documentation / refactor -> patch
skip-changelog -> excluded from release notes
-->

## Checklist

- [ ] `just lint` passes
- [ ] `just test` passes
- [ ] Tests added or updated for the change
- [ ] `README.md` / `CHANGELOG.md` updated if needed
- [ ] `README.md` updated if needed
- [ ] Release label added
45 changes: 45 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Release Drafter configuration.
# See https://github.com/release-drafter/release-drafter for more information.
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
category-template: '### $TITLE'
change-template: '- $TITLE (#$NUMBER) @$AUTHOR'
change-title-escapes: '\<*_&@'
exclude-labels:
- 'skip-changelog'
categories:
- title: 'Breaking Changes'
labels: ['breaking']
- title: 'Features'
labels: ['feature', 'enhancement']
- title: 'Bug Fixes'
labels: ['bug', 'fix']
- title: 'Maintenance'
labels: ['chore', 'ci', 'dependencies', 'documentation', 'refactor']
version-resolver:
major:
labels: ['breaking']
minor:
labels: ['feature', 'enhancement']
patch:
labels: ['bug', 'fix', 'chore', 'ci', 'dependencies', 'documentation', 'refactor']
default: patch
autolabeler:
- label: 'feature'
branch: ['/^feat(ure)?\/.+/']
- label: 'bug'
branch: ['/^(bug)?fix\/.+/']
- label: 'chore'
branch: ['/^chore\/.+/']
- label: 'ci'
branch: ['/^ci\/.+/']
files: ['.github/workflows/*']
- label: 'documentation'
branch: ['/^docs?\/.+/']
files: ['*.md']
- label: 'refactor'
branch: ['/^refactor\/.+/']
- label: 'dependencies'
files: ['uv.lock']
template: |
$CHANGES
48 changes: 48 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Release Drafter

on:
push:
branches: [ main ]
pull_request:
types: [ opened, reopened, synchronize, labeled, unlabeled ]

permissions:
contents: read

jobs:
update-draft:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

autolabel:
if: github.event_name == 'pull_request' && github.event.action != 'labeled' && github.event.action != 'unlabeled'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: release-drafter/release-drafter@v6
with:
disable-releaser: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

require-label:
needs: [ autolabel ]
# Run even when autolabel is skipped (labeled/unlabeled events)
if: ${{ always() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: mheap/github-action-required-labels@v5
with:
mode: minimum
count: 1
labels: "breaking, feature, enhancement, bug, fix, chore, ci, dependencies, documentation, refactor, skip-changelog"
use_api: true
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Release

on:
workflow_dispatch:

concurrency:
group: release
cancel-in-progress: false

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
ref: main
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: ">=0.11,<0.12"

- name: Refresh draft release
id: drafter
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Bump version
env:
VERSION: ${{ steps.drafter.outputs.resolved_version }}
run: uv version "$VERSION"

- name: Update CHANGELOG.md
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ steps.drafter.outputs.tag_name }}
release-notes: ${{ steps.drafter.outputs.body }}

- name: Commit and push
id: commit
env:
TAG: ${{ steps.drafter.outputs.tag_name }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add pyproject.toml uv.lock CHANGELOG.md
git commit -m "Release $TAG"
git push origin main
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_ID: ${{ steps.drafter.outputs.id }}
SHA: ${{ steps.commit.outputs.sha }}
run: |
gh api -X PATCH "repos/${{ github.repository }}/releases/$RELEASE_ID" \
-F draft=false -f target_commitish="$SHA"

- name: Build and upload artifacts
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.drafter.outputs.tag_name }}
run: |
uv build
gh release upload "$TAG" dist/*
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
Release notes are generated from labeled pull requests by Release Drafter.

## [Unreleased]
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ Note: Project uses `uv` and `just` to manage project configuration and commands
* `just git-leaks` - scan staged changes for secrets with gitleaks
* `uv add {package}` - install a dependency

## Releases

Releases are managed with [Release Drafter](https://github.com/release-drafter/release-drafter),
which reads the **release labels** on merged pull requests.

A release label is a GitHub label added to the pull request itself, from the **Labels** section
of the PR sidebar. Release Drafter only reads these labels. Commit messages and PR titles are not
parsed, so prefixes like `feat:` or `fix:` have no effect. Only the labels below count as release
labels; other repository labels (e.g. `good first issue`, `question`) are ignored.

| Release label | Version bump | Release notes section |
| ----------------------------------------------------------------- | ------------ | --------------------- |
| `breaking` | major | Breaking Changes |
| `feature`, `enhancement` | minor | Features |
| `bug`, `fix` | patch | Bug Fixes |
| `chore`, `ci`, `dependencies`, `documentation`, `refactor` | patch | Maintenance |
| `skip-changelog` | none | Excluded |

* Every PR must have at least one release label, or the `Release Drafter / require-label` check fails. If a release
has PRs with different labels, the largest bump wins
* Release labels are added automatically from the PR's branch name prefix (`feat/`, `fix/`, `chore/`,
`ci/`, `docs/`, `refactor/`) and from the files it changes. You can add or change them by hand
* Merging to `main` updates a draft GitHub Release with the next version and notes
* To release, run the **Release** workflow from the Actions tab. It bumps the version in
`pyproject.toml`/`uv.lock`, updates `CHANGELOG.md`, tags the release, and uploads build artifacts

## Usage

* Usage Notes
Loading