#!/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 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) echo "New Features:" if [ -z "$newfeatures" ]; then echo "* No new features." else echo "$newfeatures" fi echo "" 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 echo ""