Created
October 13, 2020 14:59
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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