github.com/hashicorp/packer@v1.14.3/scripts/prepare_changelog.sh (about) 1 #!/bin/zsh 2 # Copyright (c) HashiCorp, Inc. 3 # SPDX-License-Identifier: BUSL-1.1 4 5 6 LAST_RELEASE=$1 7 8 set -o pipefail 9 10 if [ -z $LAST_RELEASE ]; then 11 echo "you need to give the previous release version. prepare_changelog.sh v<version>" 12 exit 1 13 fi 14 15 if [ -z "$(which jq)" ]; then 16 echo "jq command not found" 17 return 1 18 fi 19 20 if [ -z "$(which jq)" ]; then 21 echo "gh command not found" 22 return 1 23 fi 24 25 get_prs(){ 26 release_time="$(gh release view --json "createdAt" --jq '.createdAt' ${LAST_RELEASE})" 27 gh pr list -s merged -S "merged:>=$release_time -label:documentation -label:automated -label:tech-debt -label:website -label:legal -label:docs -author:hc-github-team-packer" --json "number" --jq '.[]|.number' \ 28 | while read line 29 do 30 if grep -q "GH-${line}" CHANGELOG.md; then 31 continue 32 fi 33 echo $line 34 done | while read PR_NUM 35 do 36 out=$(gh pr view ${PR_NUM} --json "title,labels,url" > pull.json) 37 if [ "$?" -ne 0 ]; then 38 echo "bad response from github: manually check PR ${PR_NUM}" 39 continue 40 fi 41 42 echo "$(jq -r '.title' < pull.json) - [GH-${PR_NUM}](https://github.com/hashicorp/packer/pull/${PR_NUM})" 43 rm -f pull.json 44 done 45 } 46 47 get_prs | while read line; do 48 echo $line 49 if [[ "$line" =~ "bad" ]]; then 50 exit 1 51 fi 52 echo "Press enter to continue with next entry." 53 vared -ch ok 54 done 55 56 #TODO: just generate it automatically using PR titles and tags