2024-05-12 13:34:47 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Get tags sorted by creation date
|
|
|
|
|
tags=$(git tag --sort=creatordate)
|
|
|
|
|
|
2024-05-12 13:46:11 +02:00
|
|
|
# Convert tags into an array using a mapfile or read -a
|
|
|
|
|
if [[ $(echo "$BASH_VERSION" | cut -d. -f1) -ge 4 ]]; then
|
|
|
|
|
# For Bash 4 and newer
|
|
|
|
|
readarray -t tagArray <<< "$tags"
|
|
|
|
|
else
|
|
|
|
|
# For older Bash versions like the default on macOS
|
|
|
|
|
IFS=$'\n' read -d '' -ra tagArray <<< "$tags"
|
|
|
|
|
fi
|
2024-05-12 13:34:47 +02:00
|
|
|
|
2024-05-12 13:46:11 +02:00
|
|
|
# Determine the number of tags
|
2024-05-12 13:34:47 +02:00
|
|
|
len=${#tagArray[@]}
|
|
|
|
|
|
2024-05-12 13:46:11 +02:00
|
|
|
# Get the last two tags if there are at least two tags
|
|
|
|
|
if [ "$len" -gt 1 ]; then
|
|
|
|
|
latestTag=${tagArray[$len-1]}
|
|
|
|
|
secondLastTag=${tagArray[$len-2]}
|
|
|
|
|
else
|
|
|
|
|
echo "Not enough tags found. Need at least two."
|
2024-05-12 13:34:47 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Generate release notes from commits between the two latest tags
|
2024-05-12 13:46:11 +02:00
|
|
|
echo ""
|
2024-05-12 13:34:47 +02:00
|
|
|
echo "Release Notes from $secondLastTag to $latestTag:"
|
2024-05-12 13:46:11 +02:00
|
|
|
echo ""
|
|
|
|
|
|
2024-05-13 09:46:03 +02:00
|
|
|
# Separate types of commits
|
|
|
|
|
newfeatures=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'new:' | sed 's/new:/* /g' | sort | uniq)
|
|
|
|
|
updatedfeatures=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'update:' | sed 's/update:/* /g' | sort | uniq)
|
|
|
|
|
fixedfeatures=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'fix:' | sed 's/fix:/* /g' | sort | uniq)
|
|
|
|
|
deletedfeatures=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'delete:' | sed 's/delete:/* /g' | sort | uniq)
|
2024-05-12 13:46:11 +02:00
|
|
|
|
|
|
|
|
echo "New Features:"
|
2024-05-13 09:46:03 +02:00
|
|
|
if [ -z "$newfeatures" ]; then
|
|
|
|
|
echo "* No new features."
|
|
|
|
|
else
|
|
|
|
|
echo "$newfeatures"
|
|
|
|
|
fi
|
2024-05-12 13:46:11 +02:00
|
|
|
echo ""
|
2024-05-13 09:46:03 +02:00
|
|
|
|
|
|
|
|
echo "Updated Features:"
|
|
|
|
|
if [ -z "$updatedfeatures" ]; then
|
|
|
|
|
echo "* No updated features."
|
|
|
|
|
else
|
|
|
|
|
echo "$updatedfeatures"
|
|
|
|
|
fi
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
echo "Fixed Features:"
|
|
|
|
|
if [ -z "$fixedfeatures" ]; then
|
|
|
|
|
echo "* No fixed features."
|
|
|
|
|
else
|
|
|
|
|
echo "$fixedfeatures"
|
|
|
|
|
fi
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
echo "Deleted Features:"
|
|
|
|
|
if [ -z "$deletedfeatures" ]; then
|
|
|
|
|
echo "* No deleted features."
|
|
|
|
|
else
|
|
|
|
|
echo "$deletedfeatures"
|
|
|
|
|
fi
|
2024-05-12 13:46:11 +02:00
|
|
|
echo ""
|