Skip to content

Commit

Permalink
feat(scripts) integrate 'hub' to automate PR sending
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Dec 3, 2019
1 parent 9463aa3 commit 467e104
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 32 deletions.
57 changes: 29 additions & 28 deletions submit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,21 @@ mode=
version=
force=

function usage() {
echo "usage: $0 <-p|-m> <version>"
echo " -p for patch release (x.y.Z)"
echo " -m for minor release (x.Y.0)"
echo " -r for release candidate (x.Y.0rcZ)"
echo "example: $0 -p 1.1.2"
}

while [ "$1" ]
do
case "$1" in
--help)
usage
exit 0
;;
-p)
mode=patch
;;
Expand All @@ -32,27 +44,27 @@ do
shift
done

function usage() {
echo "usage: $0 <-p|-m> <version>"
echo " -p for patch release (x.y.Z)"
echo " -m for minor release (x.Y.0)"
echo " -r for release candidate (x.Y.0rcZ)"
echo "example: $0 -p 1.1.2"
function red() {
echo -e "\033[1;31m$@\033[0m"
}

if [ "$mode" = "" ]
then
echo "Error: mode flag is mandatory"
function die() {
red "*** $@"
echo "See also: $0 --help"
echo
usage
exit 1
}

hub --version &> /dev/null || die "hub is not in PATH. Get it from https://github.com/github/hub"

if [ "$mode" = "" ]
then
die "Error: mode flag is mandatory"
fi

if ! [ "$version" ]
then
echo "Error: missing version"
usage
exit 1
die "Error: missing version"
fi

git checkout master
Expand All @@ -68,10 +80,7 @@ then

if ! grep -q "ENV KONG_VERSION $version$" alpine/Dockerfile
then
echo "****************************************"
echo "Error: version in Dockerfile doesn't match required version."
echo "****************************************"
exit 1
die "Error: version in Dockerfile doesn't match required version."
fi
else
echo "****************************************"
Expand All @@ -81,7 +90,7 @@ then
echo "For making releases based on old versions,"
echo "Use -f to override and submit from the tag anyway."
echo "****************************************"
exit 1
die "Failed."
fi
fi

Expand Down Expand Up @@ -139,10 +148,7 @@ then

elif [ "$mode" = "rc" -a "$rc" -eq 1 ]
then
echo "****************************************"
echo "Error: rc1 automation is not implemented yet."
echo "****************************************"
exit 1
die "Error: rc1 automation is not implemented yet."

elif [ "$mode" = "minor" ]
then
Expand Down Expand Up @@ -210,9 +216,4 @@ fi
git commit -av -m "kong $version"
git push --set-upstream origin release/$version

pr="https://github.com/Kong/official-images/pull/new/release/$version"

( open "$pr" &> /dev/null \
|| xdg-open "$pr" &> /dev/null \
|| firefox "$pr" &> /dev/null \
|| echo -n "\n\n Now open $pr in your favorite browser!\n\n" ) &
hub pull-request -b docker-library:master -h "$branch" -m "bump Kong to $version"
18 changes: 14 additions & 4 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ fi

version=$1

function red() {
echo -e "\033[1;31m$@\033[0m"
}

function die() {
red "*** $@"
echo "See also: $0 --help"
echo
exit 1
}

hub --version &> /dev/null || die "hub is not in PATH. Get it from https://github.com/github/hub"

git stash
git checkout master
git checkout -B release/$version
Expand Down Expand Up @@ -58,7 +71,4 @@ fi
git commit -av -m "chore(*) bump to Kong $version"
git push --set-upstream origin release/$version

pr="https://github.com/Kong/docker-kong/pull/new/release/$version"

( open "$pr" || xdg-open "$pr" || firefox "$pr" ) &

hub pull-request -b master -h "$branch" -m "Release: $version"

0 comments on commit 467e104

Please sign in to comment.