forked from Kong/docker-kong
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·105 lines (80 loc) · 2.67 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
set -e
if ! [ "$1" ]
then
echo "usage: $0 <version>"
echo "example: $0 1.2.3"
exit 1
fi
version=$1
if [[ "$version" =~ "rc" ]]; then
version="${version//-}"
fi
function red() {
echo -e "\033[1;31m$@\033[0m"
}
function die() {
red "*** $@"
echo "See also: $0 --help"
echo
exit 1
}
# get kong url from dockerfile
# and fill it up with needed args
function get_url() {
dockerfile=$1
arch=$2
args=$3
eval $args
raw_url=$(egrep -o 'https?://download.konghq.com/gateway-[^ ]+' $dockerfile | sed 's/\"//g')
# set variables contained in raw url
KONG_VERSION=$version
ARCH=$arch
eval echo $raw_url
}
hub --version &> /dev/null || die "hub is not in PATH. Get it from https://github.com/github/hub"
#kbt_in_kong_v=$(curl -sL https://raw.githubusercontent.com/Kong/kong/$version/.requirements | grep 'KONG_BUILD_TOOLS_VERSION\=' | awk -F"=" '{print $2}' | tr -d "'[:space:]")
kbt_in_kong_v=4.33.19
if [[ -n "$kbt_in_kong_v" ]]; then
sed -i.bak 's/KONG_BUILD_TOOLS?=.*/KONG_BUILD_TOOLS?='$kbt_in_kong_v'/g' Makefile
fi
# Dockerfile.deb
url=$(get_url Dockerfile.rpm amd64 "VERSION=8")
echo $url
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)
sed -i.bak 's/ARG KONG_SHA256=.*/ARG KONG_SHA256=\"'$new_sha'\"/g' Dockerfile.rpm
sed -i.bak 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile.rpm
pushd ubuntu
url=$(get_url Dockerfile amd64 "UBUNTU_CODENAME=jammy")
echo $url
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)
sed -i.bak 's/ARG KONG_AMD64_SHA=.*/ARG KONG_AMD64_SHA=\"'$new_sha'\"/g' Dockerfile
url=$(get_url Dockerfile arm64 "UBUNTU_CODENAME=jammy")
echo $url
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)
sed -i.bak 's/ARG KONG_ARM64_SHA=.*/ARG KONG_ARM64_SHA=\"'$new_sha'\"/g' Dockerfile
sed -i.bak 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile
popd
# Dockerfile.deb
url=$(get_url Dockerfile.deb amd64 "CODENAME=bullseye")
echo $url
curl -fL $url -o /tmp/kong
new_sha=$(sha256sum /tmp/kong | cut -b1-64)
sed -i.bak 's/ARG KONG_SHA256=.*/ARG KONG_SHA256=\"'$new_sha'\"/g' Dockerfile.deb
sed -i.bak 's/ARG KONG_VERSION=.*/ARG KONG_VERSION='$version'/g' Dockerfile.deb
echo "****************************************"
git diff
echo "****************************************"
echo "Everything looks all right? (y/n)"
echo "(Answering y will commit, push the branch, and open a browser with the PR)"
read
if ! [ "$REPLY" == "y" ]
then
exit 1
fi
git commit -av -m "chore(*) bump to Kong $version"
git push --set-upstream origin release/$version
hub pull-request -b master -h "$branch" -m "Release: $version"