github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/scripts/changelog.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Create a changelog. 4 # 5 # The env variable RANGE specifies the range of commits to be searched for the changelog. 6 # If unset the latest tag until origin/master will be set. 7 # 8 # The env variable GITHUB_AUTH can be set in the form user:token to specify a GitHub 9 # personal access token. Otherwise one could run into GitHub rate limits. 10 # Go to https://github.com/settings/tokens to generate a token. 11 # 12 set -e 13 14 jq --version >/dev/null 2>&1 || { 15 echo "could not find jq (JSON command line processor), is it installed?" 16 exit 255 17 } 18 19 if [ -z "${RANGE}" ]; then 20 LATEST_TAG=$(git describe --abbrev=0) 21 RANGE="${LATEST_TAG}..origin/master" 22 fi 23 24 if [ ! -z "${GITHUB_AUTH}" ]; then 25 GITHUB_AUTH="-u ${GITHUB_AUTH}" 26 fi 27 28 for pr in $(git log --pretty=%s --first-parent "${RANGE}" | egrep -o '#\w+' | tr -d '#'); do 29 body=$(curl -s "${GITHUB_AUTH}" https://api.github.com/repos/rkt/rkt/pulls/"${pr}" | \ 30 jq -r '{title: .title, body: .body}') 31 32 echo "-" \ 33 "$(echo "${body}" | jq -r .title | sed 's/\.$//g')" \ 34 "([#${pr}](https://github.com/rkt/rkt/pull/$pr))." \ 35 "$(echo "${body}" | jq -r .body | awk -v RS='\r\n\r\n' NR==1 | tr -d '\r')" 36 done