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
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- [ ] `just lint` passes
- [ ] `just test-template` passes
- [ ] Docs updated if needed (`README.md`, `template/README.md.jinja`, `template/CLAUDE.md`)
- [ ] 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'
branch: ['/^dependabot\/.+/']
template: |
$CHANGES
50 changes: 50 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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-slim
permissions:
contents: write
steps:
- uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

autolabel:
if: github.event_name == 'pull_request' && github.event.action != 'labeled' && github.event.action != 'unlabeled'
runs-on: ubuntu-slim
permissions:
pull-requests: write
steps:
- uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0
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@23e10fde7e062233401931a0eece796cd9bf3177 # v5.6.0
with:
mode: minimum
count: 1
labels: >-
breaking, feature, enhancement, bug, fix, chore, ci, dependencies, documentation, refactor,
skip-changelog
use_api: true
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Release

# Publishes a template release. Copier reads the resulting vX.Y.Z tags as template versions.

on:
workflow_dispatch:

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

permissions:
contents: read

jobs:
release:
runs-on: ubuntu-slim
permissions:
contents: write
steps:
- name: Refresh draft release
id: drafter
uses: release-drafter/release-drafter@978bb0b30c5ee8cdd332ced253758157150d43f0 # v7.10.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Publishing the draft creates the vX.Y.Z tag at the commit this workflow ran on
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_ID: ${{ steps.drafter.outputs.id }}
run: |
gh api -X PATCH "repos/${{ github.repository }}/releases/$RELEASE_ID" \
-F draft=false -f target_commitish="$GITHUB_SHA"
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Rust project template for [Copier](https://copier.readthedocs.io/).

- Create a new project - `copier copy gh:ahcodedev/rust-template path/to/new-project`
- Pull in template updates from inside a generated project - `just update-template` (runs `copier update`)
- New projects and updates use the latest template release (`vX.Y.Z` tag); changes merged to `main` reach projects only after a release

## Development

Expand All @@ -37,6 +38,26 @@ CI runs `just lint` and `just test-template`, scans the Git history for secrets
- zizmor-action reports findings as code scanning alerts in the repository's Security tab rather than failing CI
- Code scanning needs a public repo, or GitHub Advanced Security on a private one

## Releases

Releases are managed with [Release Drafter](https://github.com/release-drafter/release-drafter), which reads the
**release labels** on merged pull requests. Commit messages and PR titles aren't parsed.

| 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 needs at least one release label, or the `Release Drafter / require-label` check fails
- Labels are added automatically from the branch name prefix (`feat/`, `fix/`, `chore/`, `ci/`, `docs/`,
`refactor/`, `dependabot/`) and from the files a PR changes
- 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 publishes the draft and tags the commit `vX.Y.Z`,
which Copier uses as the template version

## Dependency Updates

- Dependabot (`.github/dependabot.yml`) opens weekly PRs for GitHub Actions in this repo's workflows and in `template/`
Expand All @@ -52,3 +73,4 @@ CI runs `just lint` and `just test-template`, scans the Git history for secrets
- `template/` - files rendered into new projects; files ending in `.jinja` are templated
- `prek.toml` - Git hooks for this repo
- `.github/pull_request_template.md` - checklist filled into new PR descriptions
- `.github/release-drafter.yml` - release label to version bump and release notes section mapping
Loading