fix: release notes script further tested and fixed
This commit is contained in:
parent
783bfb47dc
commit
d888b88e1a
2 changed files with 29 additions and 11 deletions
|
|
@ -12,6 +12,7 @@ The idea is to get rather automated release notes. To have this as easy as possi
|
||||||
- `nonotes:` - for git commits we don't want to see in the release notes
|
- `nonotes:` - for git commits we don't want to see in the release notes
|
||||||
|
|
||||||
- tags for each version, we will output only the change log from the last and second last tag
|
- tags for each version, we will output only the change log from the last and second last tag
|
||||||
|
- you can add tags with `git tag -a <tag> -m "<message>"`
|
||||||
|
|
||||||
[resources/scripts/release-notes.bash](resources/scripts/release-notes.bash) is an example bash script to generate the release notes. You can run it with the following command:
|
[resources/scripts/release-notes.bash](resources/scripts/release-notes.bash) is an example bash script to generate the release notes. You can run it with the following command:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,22 +3,39 @@
|
||||||
# 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 IFS
|
# Convert tags into an array using a mapfile or read -a
|
||||||
IFS=$'\n' tagArray=("$tags")
|
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
|
||||||
|
|
||||||
# Get the number of tags
|
# Determine the number of tags
|
||||||
len=${#tagArray[@]}
|
len=${#tagArray[@]}
|
||||||
|
|
||||||
# Extract the last and second last tags based on length
|
# Get the last two tags if there are at least two tags
|
||||||
latestTag=${tagArray[$len-1]}
|
if [ "$len" -gt 1 ]; then
|
||||||
secondLastTag=${tagArray[$len-2]}
|
latestTag=${tagArray[$len-1]}
|
||||||
|
secondLastTag=${tagArray[$len-2]}
|
||||||
# Check if the tags are assigned correctly
|
else
|
||||||
if [ -z "$latestTag" ] || [ -z "$secondLastTag" ]; then
|
echo "Not enough tags found. Need at least two."
|
||||||
echo "Not enough tags found."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate release notes from commits between the two latest tags
|
# Generate release notes from commits between the two latest tags
|
||||||
|
echo ""
|
||||||
echo "Release Notes from $secondLastTag to $latestTag:"
|
echo "Release Notes from $secondLastTag to $latestTag:"
|
||||||
git log "$secondLastTag".."$latestTag" --pretty=format:"%s" | grep -E 'feature:|fix:' | sort | uniq | sed -e 's/feature:/\nNew Feature:/g' -e 's/fix:/\nFix:/g'
|
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 ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue