Skip to content

Instantly share code, notes, and snippets.

@tystr
Last active October 26, 2017 18:16
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 tystr/1ff84b539791116929396bf2d3626416 to your computer and use it in GitHub Desktop.
Save tystr/1ff84b539791116929396bf2d3626416 to your computer and use it in GitHub Desktop.
Simple script for building a changelog since the last tag
#!/bin/bash
#
# Author: Tyler Stroud <tyler@tylerstroud.com>
# Date: 2017-10-25
#
# This script will build a changelog containing commit messages for all commits since the most recent tag.
# It will prepend a new entry using today's date and the specified tagname followed by the commit messages
# to CHANGELOG.md
#
# Usage:
# $ ./changelog.sh v1.2.3-the-new-tag-i-am-preparing-to-create
if [ -z "$1" ]; then
echo -e "You must specify a tag name. This should be the name of the tag you are about to create."
echo -e "Usage:\n $0 tagname"
exit 1;
fi
TAG=$1
DATE=`date +%Y-%m-%d`
CHANGELOG=$(git log `git describe --tags --abbrev=0 HEAD^`..HEAD --pretty="* %s")
TEMPFILE=$(mktemp /tmp/changelog.XXXXXXXX)
tee $TEMPFILE <<EOF
### $TAG ($DATE)
$CHANGELOG
EOF
# Comment these 2 lines if you do not wish to actually modify your CHANGELOG.md file.
/bin/cat CHANGELOG.md >> $TEMPFILE
/bin/mv $TEMPFILE CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment