Skip to content

Commit b9e6f78

Browse files
committed
feat: implement GitHub Actions workflow for automatic changelog generation
1 parent 2eeaabe commit b9e6f78

File tree

4 files changed

+79
-13
lines changed

4 files changed

+79
-13
lines changed

.github/workflows/changelog.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Generate Changelog
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch: # Allow manual triggering
7+
8+
jobs:
9+
changelog:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Fetch full history for changelog generation
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- name: Install git-cliff
22+
uses: taiki-e/install-action@v2
23+
with:
24+
tool: git-cliff
25+
26+
- name: Check for changes since last changelog update
27+
id: check_changes
28+
run: |
29+
# Get the last commit that modified CHANGELOG.md
30+
LAST_CHANGELOG_COMMIT=$(git log -1 --format="%H" -- CHANGELOG.md 2>/dev/null || echo "")
31+
32+
if [ -z "$LAST_CHANGELOG_COMMIT" ]; then
33+
echo "No previous changelog found, generating full changelog"
34+
echo "has_changes=true" >> $GITHUB_OUTPUT
35+
else
36+
# Check if there are commits since the last changelog update
37+
COMMITS_SINCE=$(git rev-list --count ${LAST_CHANGELOG_COMMIT}..HEAD)
38+
if [ "$COMMITS_SINCE" -gt 1 ]; then
39+
echo "Found $COMMITS_SINCE commits since last changelog update"
40+
echo "has_changes=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "No new commits to add to changelog"
43+
echo "has_changes=false" >> $GITHUB_OUTPUT
44+
fi
45+
fi
46+
47+
- name: Generate changelog
48+
if: steps.check_changes.outputs.has_changes == 'true'
49+
run: |
50+
echo "Generating changelog..."
51+
git-cliff --output CHANGELOG.md
52+
53+
- name: Check if changelog was updated
54+
if: steps.check_changes.outputs.has_changes == 'true'
55+
id: check_diff
56+
run: |
57+
if git diff --quiet CHANGELOG.md; then
58+
echo "No changes to changelog"
59+
echo "changelog_updated=false" >> $GITHUB_OUTPUT
60+
else
61+
echo "Changelog was updated"
62+
echo "changelog_updated=true" >> $GITHUB_OUTPUT
63+
fi
64+
65+
- name: Commit and push changelog
66+
if: steps.check_changes.outputs.has_changes == 'true' && steps.check_diff.outputs.changelog_updated == 'true'
67+
run: |
68+
git config --local user.email "action@github.com"
69+
git config --local user.name "GitHub Action"
70+
git add CHANGELOG.md
71+
git commit -m "docs: update changelog [skip ci]"
72+
git push

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
### 🐛 Bug Fixes
3434

35+
- Update timestamp format in changelog generation for consistency _(2025-10-16 12:10:15)_
3536
- Reorder links in README for better clarity and navigation _(2025-10-16 11:44:58)_
3637
- Clarify instructions for supporting codebase principles in documentation _(2025-10-15 20:44:41)_
3738
- Update upload-pages-artifact action to v3 in deploy-docs.yml _(2025-10-15 17:17:21)_

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,10 @@ The codebase interface is a set of principles that aim to promote the ease of us
3333
To set up the development environment and enable automatic changelog generation:
3434

3535
```bash
36-
# Install dependencies and configure hooks
36+
# Install dependencies
3737
task setup
38-
39-
# Or manually configure hooks
40-
task setup:hooks
4138
```
4239

43-
This will:
44-
45-
- Install required dependencies (MkDocs, plugins)
46-
- Configure Git to use project hooks for automatic changelog generation
47-
- Enable pre-commit hook that updates CHANGELOG.md automatically
40+
This will install required dependencies (MkDocs, plugins) for local development.
4841

49-
**Note**: The pre-commit hook automatically generates changelog entries from your conventional commits, so make sure to follow the [Conventional Commits](https://conventionalcommits.org) specification.
42+
**Note**: The changelog is automatically generated via GitHub Actions when commits are pushed to main. Make sure to follow the [Conventional Commits](https://conventionalcommits.org) specification for proper changelog generation.

Taskfile.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ tasks:
1818
- pip install mkdocs-material
1919
- pip install mkdocs-git-revision-date-localized-plugin
2020
- pip install pymdown-extensions
21-
- task: setup:hooks
21+
- echo "Setup complete! Changelog is automatically generated via GitHub Actions."
2222
silent: true
2323

2424
setup:hooks:
25-
desc: Configure Git to use project hooks directory
25+
desc: Configure Git to use project hooks directory (optional - changelog now generated via GitHub Actions)
2626
cmds:
2727
- git config core.hooksPath .githooks
2828
- chmod +x .githooks/pre-commit
29-
- echo "Git hooks configured! Pre-commit hook is now active for changelog generation."
29+
- echo "Git hooks configured! Note: Changelog is now automatically generated via GitHub Actions on push to main."
3030

3131
build:
3232
desc: Build the MkDocs site

0 commit comments

Comments
 (0)