Files
my-rook-config/tests/scripts/gen_release_notes.sh
T

49 lines
1.7 KiB
Bash
Raw Normal View History

2021-07-22 17:02:23 +05:30
#!/usr/bin/env bash
set -e
function help() {
print="
2021-08-03 17:07:01 +05:30
To run this command,
1. verify you are selecting right branch from GitHub UI dropdown menu
2. enter the tag you want to create
2021-07-22 17:02:23 +05:30
"
echo "$print"
exit 1
}
if [ -z "${GITHUB_USER}" ] || [ -z "${GITHUB_TOKEN}" ]; then
echo "requires both GITHUB_USER and GITHUB_TOKEN to be set as env variable"
help
fi
2021-08-06 12:01:57 +05:30
pr_list=$(git log --pretty="%s" --merges --left-only "${FROM_BRANCH}"..."${TO_TAG}" | grep pull | awk '/Merge pull request/ {print $4}' | cut -c 2-)
2021-07-22 17:02:23 +05:30
# for releases notes
function release_notes() {
for pr in $pr_list; do
# get PR title
2021-08-06 12:01:57 +05:30
backport_pr=$(curl -s -u "${GITHUB_USER}":"${GITHUB_TOKEN}" "https://api.github.com/repos/rook/rook/pulls/${pr}" | jq '.title')
2021-07-22 17:02:23 +05:30
# with upstream/release-1.6 v1.6.8, it was giving extra PR numbers, so removing after PR for changing tag is merged.
2021-08-06 12:01:57 +05:30
if [[ "$backport_pr" =~ ./*"build: Update build version to $TO_TAG"* ]]; then
2021-07-22 17:02:23 +05:30
break
fi
# check if it is manual backport PR or not, for mergify backport PR it will contain "(backport"
if [[ "$backport_pr" =~ .*"(backport".* ]]; then
# find the PR number after the #
2021-08-06 12:01:57 +05:30
original_pr=$(echo "$backport_pr" | sed -n -e 's/^.*#//p' | grep -E0o '[0-9]' | tr -d '\n')
2021-07-22 17:02:23 +05:30
else
# in manual backport PR, we'll directly fetch the owner and title from the PR number
original_pr=$pr
fi
# get the PR title and PR owner in required format
2021-08-06 12:01:57 +05:30
title_with_user=$(curl -s -u "${GITHUB_USER}":"${GITHUB_TOKEN}" "https://api.github.com/repos/rook/rook/pulls/${original_pr}" | jq '.title+ " (#, @"+.user.login+")"')
2021-07-22 17:02:23 +05:30
# add PR number after "#"
result=$(echo "$title_with_user" | sed "s/(#/(#$original_pr/" |tail -c +2)
# remove last `"`
result=${result%\"}
echo "$result"
done
}
release_notes