From ff0045f5eae901bb6e9c4343ec65972f3bb4541e Mon Sep 17 00:00:00 2001 From: Louan Fontenele Date: Sun, 29 Dec 2024 07:40:32 -0300 Subject: [PATCH] Fix: Finally fixed the changelogs --- .github/scripts/generate-changelog.sh | 60 +++++++++------------------ 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/.github/scripts/generate-changelog.sh b/.github/scripts/generate-changelog.sh index 9841012..b9205fd 100644 --- a/.github/scripts/generate-changelog.sh +++ b/.github/scripts/generate-changelog.sh @@ -14,77 +14,55 @@ if [ "$LATEST_TAG" == "N/A" ]; then fi # Create or update the changelog -echo "🚀 **Release $NEW_TAG**" > $CHANGELOG_FILE +echo "## 🚀 Release $NEW_TAG" > $CHANGELOG_FILE echo "### What's Changed" >> $CHANGELOG_FILE echo "" >> $CHANGELOG_FILE -# Initialize sections for each type of change +# Categories initialization FEATURES="" FIXES="" DOCS="" MAINTENANCE="" -# Fetch commit history and categorize -if [ -n "$LATEST_TAG" ]; then - COMMITS=$(git log --pretty=format:"%s" $LATEST_TAG..HEAD) -else - COMMITS=$(git log --pretty=format:"%s" HEAD) -fi - -# Loop through each commit and categorize +# Append commit history to the correct categories while IFS= read -r line; do case "$line" in - *"Feature:"* | *"feat:"* | *"Add:"*) - FEATURES+="🌟 $line\n" - ;; - *"Fix:"* | *"fix:"* | *"Bug:"* | *"Patch:"*) - FIXES+="🐛 $line\n" - ;; - *"Doc:"* | *"docs:"* | *"Documentation:"*) - DOCS+="📄 $line\n" - ;; - *"Chore:"* | *"Refactor:"* | *"Maint:"* | *"Build:"*) - MAINTENANCE+="🧰 $line\n" - ;; - *) - # Catch-all if no category matches - MAINTENANCE+="🧰 $line\n" - ;; + "Feature:"*) FEATURES+="- ${line}\n" ;; + "Fix:"*) FIXES+="- ${line}\n" ;; + "Docs:"*) DOCS+="- ${line}\n" ;; + "Chore:"*) MAINTENANCE+="- ${line}\n" ;; esac -done <<< "$COMMITS" +done < <(git log --pretty=format:"%s" $LATEST_TAG..HEAD) -# Append categorized sections +# Add categories to changelog +echo "**🌟 Features**" >> $CHANGELOG_FILE if [ -n "$FEATURES" ]; then - echo "🌟 **Features**" >> $CHANGELOG_FILE echo -e "$FEATURES" >> $CHANGELOG_FILE else - echo "🌟 **Features**" >> $CHANGELOG_FILE - echo "_No new features_" >> $CHANGELOG_FILE + echo "_- No new features_" >> $CHANGELOG_FILE fi +echo "**🐛 Fixes**" >> $CHANGELOG_FILE if [ -n "$FIXES" ]; then - echo "🐛 **Fixes**" >> $CHANGELOG_FILE echo -e "$FIXES" >> $CHANGELOG_FILE else - echo "🐛 **Fixes**" >> $CHANGELOG_FILE - echo "_No bug fixes_" >> $CHANGELOG_FILE + echo "_- No bugs fixed_" >> $CHANGELOG_FILE fi +echo "**📄 Documentation**" >> $CHANGELOG_FILE if [ -n "$DOCS" ]; then - echo "📄 **Documentation**" >> $CHANGELOG_FILE echo -e "$DOCS" >> $CHANGELOG_FILE else - echo "📄 **Documentation**" >> $CHANGELOG_FILE - echo "_No documentation updates_" >> $CHANGELOG_FILE + echo "_- No documentation updates_" >> $CHANGELOG_FILE fi +echo "**🧰 Maintenance**" >> $CHANGELOG_FILE if [ -n "$MAINTENANCE" ]; then - echo "🧰 **Maintenance**" >> $CHANGELOG_FILE echo -e "$MAINTENANCE" >> $CHANGELOG_FILE else - echo "🧰 **Maintenance**" >> $CHANGELOG_FILE - echo "_No maintenance updates_" >> $CHANGELOG_FILE + echo "_- No maintenance updates_" >> $CHANGELOG_FILE fi echo "" >> $CHANGELOG_FILE -echo "**Full commit history:** [Compare Changes](https://github.com/${GITHUB_REPOSITORY}/compare/${LATEST_TAG}...${NEW_TAG})" >> $CHANGELOG_FILE +REPO_URL="https://github.com/${GITHUB_REPOSITORY}/compare/" +echo "**Full commit history:** [Compare Changes](${REPO_URL}${LATEST_TAG}...${NEW_TAG})" >> $CHANGELOG_FILE