Skip to content

Instantly share code, notes, and snippets.

@jarrodparkes
Created October 13, 2020 14:59
Show Gist options
  • Save jarrodparkes/ce6aed2957282e87d9cba5785758c54d to your computer and use it in GitHub Desktop.
Save jarrodparkes/ce6aed2957282e87d9cba5785758c54d to your computer and use it in GitHub Desktop.
Prints release notes by scrubbing Git commit messages that use a "[PROJECT]-[TICKET]: message" format.
#!/bin/bash
# determine branch
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# determine which commits you care about
if [ "$GIT_BRANCH" == "master" ]; then
# get commits between "tip of master" and "last tagged release"
LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
COMMITS=$(git log $LAST_TAG..master --pretty=format:"%h - %s (%an)")
else
# get commits between "tip of this branch" and "master"
COMMITS=$(git log master..HEAD --pretty=format:"%h - %s (%an)")
fi
# generate bulleted rows for unique commits (identified by [PROJECT]-[TICKET])
# this assumes that commits use a "[PROJECT]-[TICKET]: message" format
TICKET_ROWS=$(echo $COMMITS | grep -o 'PROJECT-[0-9]*' | awk '!a[$0]++' | awk 'NF{print "- [" $0 "](https://domain.atlassian.net/browse/" $0 "): [ADD_USER_FACING_SUMMARY]"}')
# print formatted release notes
echo "[ADD_RELEASE_IMAGE]
### What's New
$TICKET_ROWS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment