update: Example script for release notes updated to better output changes for release notes
This commit is contained in:
parent
6d09a3f60f
commit
439f90cbff
1 changed files with 40 additions and 20 deletions
|
|
@ -1,43 +1,63 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Check for the "final" flag in command line arguments
|
||||||
|
finalFlag=false
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ "$arg" == "final" ]]; then
|
||||||
|
finalFlag=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Get tags sorted by creation date
|
# Get tags sorted by creation date
|
||||||
tags=$(git tag --sort=creatordate)
|
tags=$(git tag --sort=creatordate)
|
||||||
|
|
||||||
# Convert tags into an array using a mapfile or read -a
|
# Convert tags into an array
|
||||||
if [[ $(echo "$BASH_VERSION" | cut -d. -f1) -ge 4 ]]; then
|
if [[ $(echo "$BASH_VERSION" | cut -d. -f1) -ge 4 ]]; then
|
||||||
# For Bash 4 and newer
|
|
||||||
readarray -t tagArray <<< "$tags"
|
readarray -t tagArray <<< "$tags"
|
||||||
else
|
else
|
||||||
# For older Bash versions like the default on macOS
|
|
||||||
IFS=$'\n' read -d '' -ra tagArray <<< "$tags"
|
IFS=$'\n' read -d '' -ra tagArray <<< "$tags"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine the number of tags
|
# Determine the number of tags
|
||||||
len=${#tagArray[@]}
|
len=${#tagArray[@]}
|
||||||
|
|
||||||
# Get the last two tags if there are at least two tags
|
# Find the last tag or the last "final" tag based on the flag
|
||||||
if [ "$len" -gt 1 ]; then
|
if $finalFlag; then
|
||||||
latestTag=${tagArray[$len-1]}
|
for (( i=len-1; i>=0; i-- )); do
|
||||||
secondLastTag=${tagArray[$len-2]}
|
if [[ "${tagArray[i]}" == *"final"* ]]; then
|
||||||
|
latestTag="${tagArray[i]}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -z "$latestTag" ]; then
|
||||||
|
echo "No 'final' tag found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Not enough tags found. Need at least two."
|
if [ "$len" -gt 0 ]; then
|
||||||
exit 1
|
latestTag="${tagArray[$len-1]}"
|
||||||
|
else
|
||||||
|
echo "No tags found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate release notes from commits between the two latest tags
|
# Print release notes
|
||||||
echo ""
|
echo ""
|
||||||
echo "Release Notes from $secondLastTag to $latestTag:"
|
echo "Release Notes from $latestTag to HEAD:"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Separate types of commits
|
# Fetch commit logs from the latest tag to HEAD and categorize them
|
||||||
newfeatures=$(git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep 'new:' | sed 's/new:/* /g' | sort | uniq)
|
newfeatures=$(git log "$latestTag"..HEAD --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)
|
updatedfeatures=$(git log "$latestTag"..HEAD --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)
|
fixedfeatures=$(git log "$latestTag"..HEAD --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)
|
deletedfeatures=$(git log "$latestTag"..HEAD --pretty=format:"%s" | grep 'delete:' | sed 's/delete:/* /g' | sort | uniq)
|
||||||
|
|
||||||
|
# Output formatted commit lists
|
||||||
echo "New Features:"
|
echo "New Features:"
|
||||||
if [ -z "$newfeatures" ]; then
|
if [ -z "$newfeatures" ]; then
|
||||||
echo "* No new features."
|
echo "* No new features."
|
||||||
else
|
else
|
||||||
echo "$newfeatures"
|
echo "$newfeatures"
|
||||||
fi
|
fi
|
||||||
|
|
@ -45,7 +65,7 @@ echo ""
|
||||||
|
|
||||||
echo "Updated Features:"
|
echo "Updated Features:"
|
||||||
if [ -z "$updatedfeatures" ]; then
|
if [ -z "$updatedfeatures" ]; then
|
||||||
echo "* No updated features."
|
echo "* No updated features."
|
||||||
else
|
else
|
||||||
echo "$updatedfeatures"
|
echo "$updatedfeatures"
|
||||||
fi
|
fi
|
||||||
|
|
@ -53,7 +73,7 @@ echo ""
|
||||||
|
|
||||||
echo "Fixed Features:"
|
echo "Fixed Features:"
|
||||||
if [ -z "$fixedfeatures" ]; then
|
if [ -z "$fixedfeatures" ]; then
|
||||||
echo "* No fixed features."
|
echo "* No fixed features."
|
||||||
else
|
else
|
||||||
echo "$fixedfeatures"
|
echo "$fixedfeatures"
|
||||||
fi
|
fi
|
||||||
|
|
@ -61,7 +81,7 @@ echo ""
|
||||||
|
|
||||||
echo "Deleted Features:"
|
echo "Deleted Features:"
|
||||||
if [ -z "$deletedfeatures" ]; then
|
if [ -z "$deletedfeatures" ]; then
|
||||||
echo "* No deleted features."
|
echo "* No deleted features."
|
||||||
else
|
else
|
||||||
echo "$deletedfeatures"
|
echo "$deletedfeatures"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue