Preparing Github release notes from Github pull requests

When doing releases for Project Calico, I like to include the highlights of what's been merged since the previous release.
Release notes on Github are written in markdown and automagically create links when issues or pull requests are referenced with a "#", e.g. #662 will create a link to
But it doesn't fill in a title for the link, so I like to write my release note with lines like "#705 pool should always come from client" which provides a link and a title.

Rather than tediously copying and pasting all the text to create these links, I wrote a one-liner to do it for me.

git log $PREVIOUS_RELEASE..master --merges --format="%s" |grep -P -o '#\d+' | grep -P -o '\d+' |xargs -I ^ -n 1 curl -s^ | jq -r '"#" + (.number |tostring) + " " + .title'


git log $PREVIOUS_RELEASE..master --merges --format="%s"

  • Print the commit message of the merges that have happened since the last release. e.g. Merge pull request #662 from tomdee/kubernetes-versioning

grep -P -o '#\d+' | grep -P -o '\d+'

  • Pull out just the number part of the #XXX PR number.
  • -o ensures that just the matched part of the line is output

xargs -I ^ -n 1 curl -s^

  • Run curl for each of the PR numbers that were merged. -s makes curl silent.
  • xargs is run with -I to control the replace character and -n 1 ensures that curl is called for each PR.

jq -r '"#" + (.number |tostring) + " " + .title'

  • Use jq to pull out the PR number and title and format it to get the desired output.
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.