From b3588676552fcbd2bbff0393716023693eae3d8b Mon Sep 17 00:00:00 2001 From: Aaron <7063649+ahcode0919@users.noreply.github.com> Date: Wed, 4 Nov 2026 17:20:30 -0800 Subject: [PATCH 1/2] Add automated release automation --- .github/pull_request_template.md | 17 ++++--- .github/release-drafter.yml | 45 +++++++++++++++++ .github/workflows/release-drafter.yml | 48 ++++++++++++++++++ .github/workflows/release.yml | 71 +++++++++++++++++++++++++++ CHANGELOG.md | 8 +++ README.md | 26 ++++++++++ 6 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index addd7b6..fdb4426 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,15 +8,20 @@ ## Type of Change -- [ ] Bug fix -- [ ] New feature -- [ ] Refactor / cleanup -- [ ] Documentation -- [ ] Build / CI / tooling + ## 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 diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..0c24e18 --- /dev/null +++ b/.github/release-drafter.yml @@ -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 diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..986ac27 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8ab3c0b --- /dev/null +++ b/.github/workflows/release.yml @@ -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/* diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..64b84e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/README.md b/README.md index daf6799..0bdc5b0 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,32 @@ Note: Project uses `uv` and `just` to manage project configuration and commands * `just test` * `gitleaks` secret scan of staged changes +## 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 From 9ce3256623e4a42b6c0fbc22ceef7b6128aadac3 Mon Sep 17 00:00:00 2001 From: Aaron <7063649+ahcode0919@users.noreply.github.com> Date: Wed, 4 Nov 2026 17:27:38 -0800 Subject: [PATCH 2/2] Update content permission --- .github/workflows/release-drafter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 986ac27..d8a1528 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -24,6 +24,8 @@ jobs: if: github.event_name == 'pull_request' && github.event.action != 'labeled' && github.event.action != 'unlabeled' runs-on: ubuntu-latest permissions: + # Release Drafter reads .github/release-drafter.yml through the contents API + contents: read pull-requests: write steps: - uses: release-drafter/release-drafter@v6