Skip to content

Commit 8adaf5f

Browse files
committed
build: automate changelog generation during releases
1 parent ede02f1 commit 8adaf5f

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

.github/changelog-config.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## 🚀 Features",
5+
"labels": ["feature", "enhancement"]
6+
},
7+
{
8+
"title": "## 🐛 Bug Fixes",
9+
"labels": ["bug", "fix"]
10+
},
11+
{
12+
"title": "## 📦 Dependencies",
13+
"labels": ["dependencies", "dependabot"]
14+
},
15+
{
16+
"title": "## 🔧 Maintenance",
17+
"labels": ["maintenance", "chore", "refactor"]
18+
},
19+
{
20+
"title": "## 🏗️ Build",
21+
"labels": ["build"]
22+
},
23+
{
24+
"title": "## 📚 Documentation",
25+
"labels": ["documentation", "docs"]
26+
}
27+
],
28+
"ignore_labels": [
29+
"ignore"
30+
],
31+
"sort": "ASC",
32+
"template": "- ${{TITLE}} ${{CATEGORIES}} ${{AUTHORS}}",
33+
"pr_template": "- ${{TITLE}} (#${{NUMBER}}) ${{AUTHORS}}",
34+
"empty_template": "- No changes",
35+
"label_extractor": [
36+
{
37+
"pattern": "^(feat|feature)(\\(.+\\))?:",
38+
"target": "feature"
39+
},
40+
{
41+
"pattern": "^(fix|bug)(\\(.+\\))?:",
42+
"target": "bug"
43+
},
44+
{
45+
"pattern": "^(chore|maintenance)(\\(.+\\))?:",
46+
"target": "maintenance"
47+
},
48+
{
49+
"pattern": "^(build)(\\(.+\\))?:",
50+
"target": "build"
51+
},
52+
{
53+
"pattern": "^(docs|documentation)(\\(.+\\))?:",
54+
"target": "documentation"
55+
},
56+
{
57+
"pattern": "^(deps|dependencies)(\\(.+\\))?:",
58+
"target": "dependencies"
59+
},
60+
{
61+
"pattern": "Bump version to",
62+
"target": "ignore"
63+
},
64+
{
65+
"pattern": "Bump .+ from .+ to .+",
66+
"target": "dependencies"
67+
}
68+
]
69+
}

.github/workflows/release.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest]
18+
permissions:
19+
contents: write # Required for creating releases
1820
# Steps represent a sequence of tasks that will be executed as part of the job
1921
steps:
2022
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
2123
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Fetch full history for changelog generation
2226

2327
# Set up Node
2428
- name: Use Node 20
@@ -37,6 +41,41 @@ jobs:
3741
- name: Test
3842
run: npm test
3943

44+
- name: Get previous tag
45+
id: get_previous_tag
46+
run: |
47+
# Get the previous tag (excluding the current one)
48+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
49+
echo "tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT
50+
echo "Previous tag: $PREVIOUS_TAG"
51+
52+
# Generate changelog for the release
53+
- name: Build Changelog
54+
id: build_changelog
55+
uses: mikepenz/release-changelog-builder-action@v5
56+
with:
57+
token: ${{ secrets.GITHUB_TOKEN }}
58+
configuration: ".github/changelog-config.json"
59+
fromTag: ${{ steps.get_previous_tag.outputs.tag }}
60+
toTag: ${{ github.ref_name }}
61+
ignorePreReleases: true
62+
63+
# Create GitHub Release
64+
- name: Create GitHub Release
65+
uses: actions/create-release@v1
66+
with:
67+
tag_name: ${{ github.ref_name }}
68+
release_name: Release ${{ github.ref_name }}
69+
body: |
70+
## What's Changed
71+
${{ steps.build_changelog.outputs.changelog }}
72+
73+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.get_previous_tag.outputs.tag }}...${{ github.ref_name }}
74+
draft: false
75+
prerelease: false
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
4079
# Publish to npm
4180
- name: Publish to npm
4281
run: npm publish --access public

0 commit comments

Comments
 (0)