Skip to content

Commit ac9c1ca

Browse files
committed
Update CHANGELOG and add automation workflow
Manual updates: - Added recent changes to [Unreleased] section - Documented ResourceFileParser fixes and improvements - Added demo GIF and new tests Automation: - Created update-changelog.yml workflow - Auto-updates CHANGELOG from commit messages - Categorizes commits (Fixed/Added/Changed) - Uses [skip ci] to prevent infinite loops - Skips on CHANGELOG-only changes - Won't trigger CI or release workflows
1 parent 2b86bea commit ac9c1ca

2 files changed

Lines changed: 162 additions & 0 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Update CHANGELOG
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- 'CHANGELOG.md' # Don't trigger on CHANGELOG-only changes
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
update-changelog:
15+
name: Update CHANGELOG from commits
16+
runs-on: ubuntu-latest
17+
18+
# Skip if commit message contains [skip ci] or is from github-actions bot
19+
if: |
20+
!contains(github.event.head_commit.message, '[skip ci]') &&
21+
github.event.head_commit.author.name != 'github-actions[bot]'
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 0 # Full history needed
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract commits since last release
31+
id: commits
32+
run: |
33+
# Find last version tag
34+
PREV_TAG=$(git describe --tags --abbrev=0 --match "v[0-9]*" 2>/dev/null || echo "")
35+
36+
if [ -z "$PREV_TAG" ]; then
37+
# No previous release, get all commits
38+
COMMITS=$(git log --pretty=format:"%s" --no-merges)
39+
else
40+
# Get commits since last release
41+
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"%s" --no-merges)
42+
fi
43+
44+
# Categorize commits
45+
FIXED=""
46+
ADDED=""
47+
CHANGED=""
48+
49+
while IFS= read -r commit; do
50+
# Skip empty lines and bot commits
51+
[ -z "$commit" ] && continue
52+
echo "$commit" | grep -q "skip ci" && continue
53+
echo "$commit" | grep -q "Bump version" && continue
54+
55+
# Categorize by conventional commit prefix or keywords
56+
if echo "$commit" | grep -qiE "^(fix|fixed|bugfix)"; then
57+
FIXED="${FIXED}- ${commit#*: }\n"
58+
elif echo "$commit" | grep -qiE "^(feat|add|added)"; then
59+
ADDED="${ADDED}- ${commit#*: }\n"
60+
elif echo "$commit" | grep -qiE "^(change|changed|update|refactor)"; then
61+
CHANGED="${CHANGED}- ${commit#*: }\n"
62+
else
63+
# Default to Changed for uncategorized
64+
CHANGED="${CHANGED}- ${commit}\n"
65+
fi
66+
done <<< "$COMMITS"
67+
68+
# Save to output
69+
{
70+
echo "fixed<<EOF"
71+
echo -e "$FIXED"
72+
echo "EOF"
73+
echo "added<<EOF"
74+
echo -e "$ADDED"
75+
echo "EOF"
76+
echo "changed<<EOF"
77+
echo -e "$CHANGED"
78+
echo "EOF"
79+
} >> $GITHUB_OUTPUT
80+
81+
- name: Update CHANGELOG.md
82+
run: |
83+
# Check if there are any changes to add
84+
if [ -z "${{ steps.commits.outputs.fixed }}${{ steps.commits.outputs.added }}${{ steps.commits.outputs.changed }}" ]; then
85+
echo "No new commits to add to CHANGELOG"
86+
exit 0
87+
fi
88+
89+
# Create temporary file with new unreleased section
90+
cat > /tmp/unreleased.txt <<'EOF'
91+
## [Unreleased]
92+
93+
EOF
94+
95+
# Add Fixed section if not empty
96+
if [ -n "${{ steps.commits.outputs.fixed }}" ]; then
97+
echo "### Fixed" >> /tmp/unreleased.txt
98+
echo "${{ steps.commits.outputs.fixed }}" >> /tmp/unreleased.txt
99+
fi
100+
101+
# Add Added section if not empty
102+
if [ -n "${{ steps.commits.outputs.added }}" ]; then
103+
echo "### Added" >> /tmp/unreleased.txt
104+
echo "${{ steps.commits.outputs.added }}" >> /tmp/unreleased.txt
105+
fi
106+
107+
# Add Changed section if not empty
108+
if [ -n "${{ steps.commits.outputs.changed }}" ]; then
109+
echo "### Changed" >> /tmp/unreleased.txt
110+
echo "${{ steps.commits.outputs.changed }}" >> /tmp/unreleased.txt
111+
fi
112+
113+
# Replace [Unreleased] section in CHANGELOG
114+
# Find line number of [Unreleased]
115+
UNRELEASED_LINE=$(grep -n "## \[Unreleased\]" CHANGELOG.md | cut -d: -f1 | head -1)
116+
117+
if [ -n "$UNRELEASED_LINE" ]; then
118+
# Find next ## line (start of previous version)
119+
NEXT_VERSION_LINE=$(tail -n +$((UNRELEASED_LINE + 1)) CHANGELOG.md | grep -n "^## \[" | head -1 | cut -d: -f1)
120+
121+
if [ -n "$NEXT_VERSION_LINE" ]; then
122+
# Calculate absolute line number
123+
NEXT_VERSION_LINE=$((UNRELEASED_LINE + NEXT_VERSION_LINE))
124+
125+
# Build new CHANGELOG
126+
head -n $((UNRELEASED_LINE - 1)) CHANGELOG.md > /tmp/changelog_new.md
127+
cat /tmp/unreleased.txt >> /tmp/changelog_new.md
128+
tail -n +$NEXT_VERSION_LINE CHANGELOG.md >> /tmp/changelog_new.md
129+
130+
mv /tmp/changelog_new.md CHANGELOG.md
131+
fi
132+
fi
133+
134+
- name: Commit CHANGELOG changes
135+
run: |
136+
git config user.name "github-actions[bot]"
137+
git config user.email "github-actions[bot]@users.noreply.github.com"
138+
139+
# Check if there are changes
140+
if git diff --quiet CHANGELOG.md; then
141+
echo "No changes to CHANGELOG.md"
142+
exit 0
143+
fi
144+
145+
git add CHANGELOG.md
146+
git commit -m "Update CHANGELOG from recent commits [skip ci]"
147+
git push origin main

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- ResourceFileParser now preserves original file order when writing .resx files
12+
- ResourceFileParser no longer removes XML schema declarations
13+
- Write operations now perform in-place updates, minimizing git diffs
14+
15+
### Added
16+
- Demo GIF showcasing all LRM features
17+
- 5 new comprehensive tests for file preservation (Write_ShouldPreserveOriginalOrder, etc.)
18+
- Demo script (demo.sh) with automatic backup/restore mechanism
19+
- Demo GIF creation guide in CONTRIBUTING.md
20+
- Assets folder for media files
21+
22+
### Changed
23+
- ResourceFileParser.Write() now updates entries in-place instead of recreating all elements
24+
1025
## [0.6.2] - 2025-01-09
1126

1227
### Added

0 commit comments

Comments
 (0)