Skip to content

Commit

Permalink
Fix: Finally fixed the changelogs
Browse files Browse the repository at this point in the history
  • Loading branch information
louanfontenele committed Dec 29, 2024
1 parent 231675f commit ff0045f
Showing 1 changed file with 19 additions and 41 deletions.
60 changes: 19 additions & 41 deletions .github/scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ff0045f

Please sign in to comment.