Skip to content

Instantly share code, notes, and snippets.

@particledecay
Last active May 14, 2020 22:58
Show Gist options
  • Save particledecay/7e4bfad1236856a194139bce3655b755 to your computer and use it in GitHub Desktop.
Save particledecay/7e4bfad1236856a194139bce3655b755 to your computer and use it in GitHub Desktop.
Generate a changelog/release notes using Conventional Commit standards
# one-liner
if [ -z "$(git tag -l --sort=v:refname | tail -1)" ]; then git log --oneline --all; else git log --oneline $(git tag -l --sort=v:refname | tail -1)..$(git rev-parse --abbrev-ref HEAD); fi | awk '$2 ~ /:/' | sort -sk 2,2 | awk 'BEGIN {print "## Changelog"} NR == 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)} NR > 1 && $2 !~ type {print ""} NR > 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)}'
# nicely formatted
if [ -z "$(git tag -l --sort=v:refname | tail -1)" ]
then
git log --oneline --all
else
git log --oneline $(git tag -l --sort=v:refname | tail -1)..$(git rev-parse --abbrev-ref HEAD)
fi | awk '$2 ~ /:/' \
| sort -sk 2,2 \
| awk 'BEGIN {print "## Changelog"}
NR == 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)}
NR > 1 && $2 !~ type {print ""}
NR > 1 {print "- " $0; type = gensub(/(\w+).*:/, "\\1", 1, $2)}'
@particledecay
Copy link
Author

Edited to avoid grouping by scope unnecessarily

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