@@ -93,40 +93,100 @@ jobs:
9393 LATEST_TAG="${{ steps.get_latest_tag.outputs.latest_tag }}"
9494 NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
9595
96- echo "# Release $NEW_VERSION" > CHANGELOG .md
97- echo "" >> CHANGELOG .md
96+ echo "# Release $NEW_VERSION" > /tmp/release_notes .md
97+ echo "" >> /tmp/release_notes .md
9898
9999 if [ "$LATEST_TAG" = "v0.0.0" ]; then
100- echo "## Initial Release" >> CHANGELOG .md
101- echo "" >> CHANGELOG .md
102- echo "First release of the GitHub Copilot Agent blueprint repository." >> CHANGELOG .md
100+ echo "## Initial Release" >> /tmp/release_notes .md
101+ echo "" >> /tmp/release_notes .md
102+ echo "First release of the GitHub Copilot Agent blueprint repository." >> /tmp/release_notes .md
103103 else
104- # Get commits since last tag
105- git log $LATEST_TAG..HEAD --pretty=format:"%s" | while read -r line; do
106- # Categorize commits
104+ echo "## What's Changed" >> /tmp/release_notes.md
105+ echo "" >> /tmp/release_notes.md
106+
107+ # Collect commits in arrays by category
108+ FEAT_COMMITS=()
109+ FIX_COMMITS=()
110+ DOCS_COMMITS=()
111+ REFACTOR_COMMITS=()
112+ TEST_COMMITS=()
113+ CHORE_COMMITS=()
114+ OTHER_COMMITS=()
115+
116+ while IFS= read -r line; do
107117 if echo "$line" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
108- echo "✨ $line" >> CHANGELOG.md
118+ FEAT_COMMITS+=(" $line")
109119 elif echo "$line" | grep -qiE "^fix(\(.+\))?:"; then
110- echo "🐛 $line" >> CHANGELOG.md
120+ FIX_COMMITS+=(" $line")
111121 elif echo "$line" | grep -qiE "^docs(\(.+\))?:"; then
112- echo "📚 $line" >> CHANGELOG.md
122+ DOCS_COMMITS+=(" $line")
113123 elif echo "$line" | grep -qiE "^refactor(\(.+\))?:"; then
114- echo "♻️ $line" >> CHANGELOG.md
124+ REFACTOR_COMMITS+=(" $line")
115125 elif echo "$line" | grep -qiE "^test(\(.+\))?:"; then
116- echo "✅ $line" >> CHANGELOG.md
126+ TEST_COMMITS+=(" $line")
117127 elif echo "$line" | grep -qiE "^chore(\(.+\))?:"; then
118- echo "🔧 $line" >> CHANGELOG.md
128+ CHORE_COMMITS+=(" $line")
119129 else
120- echo "• $line" >> CHANGELOG.md
130+ OTHER_COMMITS+=(" $line")
121131 fi
122- done
132+ done < <(git log $LATEST_TAG..HEAD --pretty=format:"%s")
133+
134+ # Write categorized commits
135+ if [ ${#FEAT_COMMITS[@]} -gt 0 ]; then
136+ echo "### ✨ Features" >> /tmp/release_notes.md
137+ for commit in "${FEAT_COMMITS[@]}"; do
138+ echo "- $commit" >> /tmp/release_notes.md
139+ done
140+ echo "" >> /tmp/release_notes.md
141+ fi
142+
143+ if [ ${#FIX_COMMITS[@]} -gt 0 ]; then
144+ echo "### 🐛 Bug Fixes" >> /tmp/release_notes.md
145+ for commit in "${FIX_COMMITS[@]}"; do
146+ echo "- $commit" >> /tmp/release_notes.md
147+ done
148+ echo "" >> /tmp/release_notes.md
149+ fi
150+
151+ if [ ${#DOCS_COMMITS[@]} -gt 0 ]; then
152+ echo "### 📚 Documentation" >> /tmp/release_notes.md
153+ for commit in "${DOCS_COMMITS[@]}"; do
154+ echo "- $commit" >> /tmp/release_notes.md
155+ done
156+ echo "" >> /tmp/release_notes.md
157+ fi
158+
159+ if [ ${#REFACTOR_COMMITS[@]} -gt 0 ]; then
160+ echo "### ♻️ Refactoring" >> /tmp/release_notes.md
161+ for commit in "${REFACTOR_COMMITS[@]}"; do
162+ echo "- $commit" >> /tmp/release_notes.md
163+ done
164+ echo "" >> /tmp/release_notes.md
165+ fi
166+
167+ if [ ${#CHORE_COMMITS[@]} -gt 0 ]; then
168+ echo "### 🔧 Maintenance" >> /tmp/release_notes.md
169+ for commit in "${CHORE_COMMITS[@]}"; do
170+ echo "- $commit" >> /tmp/release_notes.md
171+ done
172+ echo "" >> /tmp/release_notes.md
173+ fi
174+
175+ if [ ${#OTHER_COMMITS[@]} -gt 0 ]; then
176+ echo "### Other Changes" >> /tmp/release_notes.md
177+ for commit in "${OTHER_COMMITS[@]}"; do
178+ echo "- $commit" >> /tmp/release_notes.md
179+ done
180+ echo "" >> /tmp/release_notes.md
181+ fi
123182 fi
124183
125184 # Read changelog into output
126- CHANGELOG=$(cat CHANGELOG.md)
127- echo "changelog<<EOF" >> $GITHUB_OUTPUT
128- echo "$CHANGELOG" >> $GITHUB_OUTPUT
129- echo "EOF" >> $GITHUB_OUTPUT
185+ {
186+ echo "changelog<<EOF"
187+ cat /tmp/release_notes.md
188+ echo "EOF"
189+ } >> $GITHUB_OUTPUT
130190
131191 cat CHANGELOG.md
132192
@@ -170,15 +230,35 @@ jobs:
170230 NEW_VERSION="${{ steps.new_version.outputs.new_version }}"
171231 DATE=$(date +%Y-%m-%d)
172232
173- # Create entry for CHANGELOG.md
174- echo "## [$NEW_VERSION] - $DATE" > /tmp/changelog_entry.md
175- echo "" >> /tmp/changelog_entry.md
176- cat CHANGELOG.md >> /tmp/changelog_entry.md
177- echo "" >> /tmp/changelog_entry.md
233+ # Create the new changelog entry from release notes
234+ {
235+ echo "## [$NEW_VERSION] - $DATE"
236+ echo ""
237+ # Extract content after the "# Release" heading from release notes
238+ tail -n +3 /tmp/release_notes.md
239+ echo ""
240+ } > /tmp/changelog_entry.md
178241
179- # Insert after the "Unreleased" section
180- sed -i.bak '/^---$/r /tmp/changelog_entry.md' CHANGELOG.md
181- rm CHANGELOG.md.bak
242+ # Read existing CHANGELOG.md
243+ if [ -f CHANGELOG.md ]; then
244+ # Insert new entry after the "---" line
245+ awk '/^---$/ { print; system("cat /tmp/changelog_entry.md"); next }1' CHANGELOG.md > /tmp/new_changelog.md
246+ mv /tmp/new_changelog.md CHANGELOG.md
247+ else
248+ # Create new CHANGELOG.md if it doesn't exist
249+ {
250+ echo "# Changelog"
251+ echo ""
252+ echo "All notable changes to this project will be documented in this file."
253+ echo ""
254+ echo "The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),"
255+ echo "and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)."
256+ echo ""
257+ echo "---"
258+ echo ""
259+ cat /tmp/changelog_entry.md
260+ } > CHANGELOG.md
261+ fi
182262
183263 # Configure git
184264 git config user.name "github-actions[bot]"
@@ -198,8 +278,8 @@ jobs:
198278 echo "**Previous**: ${{ steps.get_latest_tag.outputs.latest_tag }}" >> $GITHUB_STEP_SUMMARY
199279 echo "**Bump Type**: ${{ steps.version_bump.outputs.bump }}" >> $GITHUB_STEP_SUMMARY
200280 echo "" >> $GITHUB_STEP_SUMMARY
201- echo "### Changelog " >> $GITHUB_STEP_SUMMARY
202- cat CHANGELOG .md >> $GITHUB_STEP_SUMMARY
281+ echo "### Release Notes " >> $GITHUB_STEP_SUMMARY
282+ cat /tmp/release_notes .md >> $GITHUB_STEP_SUMMARY
203283
204284 - name : No Release Summary
205285 if : steps.check_release.outputs.needs_release == 'false'
0 commit comments