Skip to content

Commit 0b85230

Browse files
authored
ci: add Release Drafter and CHANGELOG tracking (#6)
1 parent 0f81410 commit 0b85230

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

.github/release-drafter.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Release Drafter configuration.
2+
#
3+
# Categories are keyed on this project's type labels (enhancement / bug /
4+
# chore / documentation); the autolabeler classifies Conventional-Commit PR
5+
# titles into them so the draft is categorized without manual labelling.
6+
#
7+
# Scope labels (phase-1/2/3, scaffolding) are deliberately NOT category or
8+
# exclude labels — they are ignored by the changelog. Listing them under
9+
# exclude-labels would drop nearly every PR; they simply don't drive a
10+
# category.
11+
name-template: "v$RESOLVED_VERSION"
12+
tag-template: "v$RESOLVED_VERSION"
13+
template: |
14+
# What Changed 👀
15+
16+
$CHANGES
17+
18+
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
19+
categories:
20+
- title: 🚀 Features
21+
labels:
22+
- enhancement
23+
- title: 🐛 Bug Fixes
24+
labels:
25+
- bug
26+
- title: 📄 Documentation
27+
labels:
28+
- documentation
29+
- title: 🔧 Maintenance
30+
labels:
31+
- chore
32+
- title: 🧩 Dependency Updates
33+
labels:
34+
- dependencies
35+
collapse-after: 5
36+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
37+
change-title-escapes: '\<*_&'
38+
version-resolver:
39+
major:
40+
labels:
41+
- breaking
42+
minor:
43+
labels:
44+
- enhancement
45+
patch:
46+
labels:
47+
- bug
48+
- chore
49+
- documentation
50+
- dependencies
51+
default: patch
52+
exclude-labels:
53+
- skip-changelog
54+
# Classify Conventional-Commit PR titles into the type labels above. The
55+
# breaking rule matches the CC "!" marker (e.g. feat!: / fix(x)!:).
56+
autolabeler:
57+
- label: breaking
58+
title:
59+
- '/^[a-z]+(\(.+\))?!:/i'
60+
- label: enhancement
61+
title:
62+
- '/^feat(\(.+\))?!?:/i'
63+
- label: bug
64+
title:
65+
- '/^fix(\(.+\))?!?:/i'
66+
- label: documentation
67+
title:
68+
- '/^docs(\(.+\))?!?:/i'
69+
- label: chore
70+
title:
71+
- '/^(chore|build|ci|refactor|perf|test|style|revert)(\(.+\))?!?:/i'
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release Drafter
2+
3+
# Drafts the next release on push to main and updates CHANGELOG.md before the
4+
# release is cut; autolabels PRs so the draft is categorized.
5+
#
6+
# DISABLED until the org GitHub App is configured: every job is gated on
7+
# `vars.APP_CLIENT_ID`, so until that variable is set the job is skipped (no
8+
# runs, no failures). Once APP_CLIENT_ID (variable) and APP_PRIVATE_KEY
9+
# (secret) are set for the org/repo, it self-enables — no edit required.
10+
#
11+
# The App token is used to push the CHANGELOG commit back to main. That commit
12+
# touches only CHANGELOG.md (path-ignored by ci-go/ci-image) and carries
13+
# [skip ci], so it never triggers the image build or re-triggers this workflow.
14+
15+
on:
16+
push:
17+
branches: [main]
18+
pull_request:
19+
types: [opened, reopened, synchronize]
20+
workflow_dispatch:
21+
22+
permissions:
23+
contents: read
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: false
28+
29+
jobs:
30+
draft:
31+
name: Draft release and update changelog
32+
# Inert until the GitHub App is configured (see header).
33+
if: ${{ vars.APP_CLIENT_ID != '' }}
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: write # update releases + push the changelog commit
37+
pull-requests: write # autolabeler
38+
steps:
39+
- name: Create GitHub App token
40+
id: app-token
41+
uses: actions/create-github-app-token@v3.1.1
42+
with:
43+
client-id: ${{ vars.APP_CLIENT_ID }}
44+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
45+
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
with:
49+
token: ${{ steps.app-token.outputs.token }}
50+
fetch-depth: 0
51+
52+
- name: Release Drafter
53+
id: drafter
54+
uses: release-drafter/release-drafter@v6
55+
env:
56+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
57+
58+
- name: Update CHANGELOG
59+
if: github.event_name != 'pull_request'
60+
uses: Bugs5382/changelog-updater-action@v0.3.2
61+
env:
62+
LOG_LEVEL: debug
63+
LOG_FORMAT: text
64+
RELEASE_NOTES: >-
65+
${{ steps.drafter.outputs.body }}
66+
RELEASE_VERSION: v${{ steps.drafter.outputs.resolved_version }}
67+
with:
68+
tag: ${{ env.RELEASE_VERSION }}
69+
notes: ${{ env.RELEASE_NOTES }}
70+
diff: "true"
71+
72+
- name: Commit changelog
73+
if: github.event_name != 'pull_request'
74+
uses: stefanzweifel/git-auto-commit-action@v4
75+
with:
76+
commit_message: "chore(pre-release): v${{ steps.drafter.outputs.resolved_version }} [skip ci]"
77+
file_pattern: CHANGELOG.md

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changelog
2+
3+
All notable changes to this project are documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

0 commit comments

Comments
 (0)