Skip to content

Instantly share code, notes, and snippets.

@diego-betto
Last active March 20, 2024 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego-betto/4e9a74b7dba5b68a9d30428c177e2d54 to your computer and use it in GitHub Desktop.
Save diego-betto/4e9a74b7dba5b68a9d30428c177e2d54 to your computer and use it in GitHub Desktop.
Bash script to generate a CHANGELOG.md file based on git tags
#!/bin/bash
shopt -s lastpipe
footerTags=()
echo "# Changelog
This document maintains a list of released versions and changes done in respective versions.
" > ./CHANGELOG.md
git tag -l --sort=-creatordate | while read tag; do
echo '## Version'" [${tag}]" >> ./CHANGELOG.md
echo '' >> ./CHANGELOG.md
git log ${tag}..${NEXT_TAG} --pretty=format:'* %s ' >> ./CHANGELOG.md
echo ''>> ./CHANGELOG.md
echo '--'>> ./CHANGELOG.md
echo ''>> ./CHANGELOG.md
footerTags+=("${tag}...${NEXT_TAG}")
NEXT_TAG=${tag}
done
echo $footerTags
for str in ${footerTags[@]}; do
echo str
tag="${str##*...}"
echo "[${tag}]: $1/-/compare/${str}" >> ./CHANGELOG.md
done
echo 'done'
@diego-betto
Copy link
Author

Footer links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment