2017-01-20 15:10:13 -05:00
|
|
|
#!/bin/zsh
|
|
|
|
|
|
|
|
LAST_RELEASE=$1
|
2017-10-10 00:31:19 -04:00
|
|
|
DO_PR_CHECK=1
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
|
2020-02-12 12:25:54 -05:00
|
|
|
is_doc_or_tech_debt_pr(){
|
2017-10-10 00:31:19 -04:00
|
|
|
if ! (($+commands[jq])); then
|
|
|
|
DO_PR_CHECK=0
|
|
|
|
echo "jq not found"
|
|
|
|
return 1
|
|
|
|
fi
|
2020-06-12 11:25:52 -04:00
|
|
|
out=$(cat pull.json | python -m json.tool \
|
2020-06-15 05:25:45 -04:00
|
|
|
| jq '[.labels[].name == "docs" or .labels[].name == "tech-debt" or .labels[].name == "website"] | any')
|
2017-10-10 00:31:19 -04:00
|
|
|
grep -q true <<< $out
|
|
|
|
return $?
|
|
|
|
}
|
2017-01-20 15:10:13 -05:00
|
|
|
|
|
|
|
if [ -z $LAST_RELEASE ]; then
|
|
|
|
echo "you need to give the previous release version. prepare_changelog.sh v<version>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-10 00:31:19 -04:00
|
|
|
get_prs(){
|
2020-02-14 11:33:33 -05:00
|
|
|
# git log v0.10.2...c3861d167533fb797b0fae0c380806625712e5f7 |
|
2020-03-27 07:19:49 -04:00
|
|
|
git log HEAD...${LAST_RELEASE} --first-parent --oneline --grep="Merge pull request #[0-9]\+" --grep="(#[0-9]\+)$" |
|
2020-02-14 11:33:33 -05:00
|
|
|
grep -o "#\([0-9]\+\)" | awk -F\# '{print $2}' | while read line
|
2017-10-10 00:31:19 -04:00
|
|
|
do
|
|
|
|
grep -q "GH-${line}" CHANGELOG.md
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo $line
|
|
|
|
fi
|
|
|
|
done | while read PR_NUM
|
|
|
|
do
|
2020-06-12 11:25:52 -04:00
|
|
|
if [[ -z "${GITHUB_TOKEN}" ]] || [[ -z "${GITHUB_USERNAME}" ]] ; then
|
|
|
|
out=$(curl -fsS "https://api.github.com/repos/hashicorp/packer/issues/${PR_NUM}" -o pull.json)
|
|
|
|
else
|
|
|
|
# authenticated call
|
|
|
|
out=$(curl -u ${GITHUB_USERNAME}:${GITHUB_TOKEN} -fsS "https://api.github.com/repos/hashicorp/packer/issues/${PR_NUM}" -o pull.json)
|
|
|
|
fi
|
|
|
|
exy="$?"
|
|
|
|
if [ $exy -ne 0 ]; then
|
|
|
|
echo "bad response from github: manually check PR ${PR_NUM}"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (($DO_PR_CHECK)) && is_doc_or_tech_debt_pr; then
|
2020-06-15 05:25:45 -04:00
|
|
|
echo "Skipping PR ${PR_NUM}: labeled as tech debt, docs or website. (waiting a second so we don't get rate-limited...)"
|
2017-10-10 00:31:19 -04:00
|
|
|
continue
|
|
|
|
fi
|
2020-06-12 11:25:52 -04:00
|
|
|
echo "$(cat pull.json | python -m json.tool | jq '.title') - https://github.com/hashicorp/packer/pull/${PR_NUM}"
|
2017-10-10 00:31:19 -04:00
|
|
|
done
|
|
|
|
}
|
2017-01-20 15:10:13 -05:00
|
|
|
|
2020-02-12 12:25:54 -05:00
|
|
|
#is_doc_or_tech_debt_pr 52061111
|
|
|
|
# is_doc_or_tech_debt_pr 5206 # non-doc pr
|
|
|
|
#is_doc_or_tech_debt_pr 5434 # doc pr
|
2017-10-10 00:31:19 -04:00
|
|
|
#echo $?
|
|
|
|
#exit
|
|
|
|
|
|
|
|
# prpid=$!
|
|
|
|
# trap 'kill -9 ${prpid}; exit' INT TERM
|
|
|
|
|
|
|
|
get_prs | while read line; do
|
2017-01-20 15:10:13 -05:00
|
|
|
echo $line
|
2017-10-10 00:31:19 -04:00
|
|
|
if [[ "$line" =~ "bad" ]]; then
|
|
|
|
exit 1
|
2020-05-05 20:22:25 -04:00
|
|
|
elif [[ "$line" =~ "Skipping" ]]; then
|
|
|
|
sleep 1 # GH will rate limit us if we have several in a row
|
|
|
|
continue
|
2017-10-10 00:31:19 -04:00
|
|
|
fi
|
2020-06-15 05:25:45 -04:00
|
|
|
rm -f pull.json
|
2017-01-20 15:10:13 -05:00
|
|
|
vared -ch ok
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
#TODO: just generate it automatically using PR titles and tags
|