41 lines
1.1 KiB
Bash
41 lines
1.1 KiB
Bash
#!/bin/bash
|
|
|
|
# Get tags sorted by creation date
|
|
tags=$(git tag --sort=creatordate)
|
|
|
|
# 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
|
|
|
|
# Determine the number of tags
|
|
len=${#tagArray[@]}
|
|
|
|
# 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."
|
|
exit 1
|
|
fi
|
|
|
|
# Generate release notes from commits between the two latest tags
|
|
echo ""
|
|
echo "Release Notes from $secondLastTag to $latestTag:"
|
|
echo ""
|
|
|
|
# Separate features and fixes
|
|
features=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'feature:' | sed 's/feature:/* /g' | sort | uniq)
|
|
fixes=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'fix:' | sed 's/fix:/* /g' | sort | uniq)
|
|
|
|
echo "New Features:"
|
|
echo "$features"
|
|
echo ""
|
|
echo "Fixes:"
|
|
echo "$fixes"
|
|
echo ""
|