forked from Kong/kong-build-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-kong.sh
executable file
·145 lines (108 loc) · 3.81 KB
/
release-kong.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env bash
set -eo pipefail
CWD=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
BUILD_DIR="$CWD/output"
PULP_HOST=
PULP_USERNAME=
PULP_PASSWORD=
# release finals into prod, others into stage
if [[ "$KONG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
PULP_HOST="$PULP_HOST_PROD"
PULP_USERNAME="$PULP_PROD_USR"
PULP_PASSWORD="$PULP_PROD_PSW"
else
PULP_HOST="$PULP_HOST_STAGE"
PULP_USERNAME="$PULP_STAGE_USR"
PULP_PASSWORD="$PULP_STAGE_PSW"
fi
PULP_DOCKER_IMAGE="kong/release-script"
KONG_PACKAGE_NAME=$KONG_PACKAGE_NAME
KONG_VERSION=$KONG_VERSION
OFFICIAL_RELEASE=$OFFICIAL_RELEASE
DOCKER_REPOSITORY="kong/kong"
DOCKER_TAG="latest"
case "$RESTY_IMAGE_BASE" in
debian|ubuntu)
OUTPUT_FILE_SUFFIX=".$RESTY_IMAGE_TAG.$ARCHITECTURE.deb"
;;
centos)
OUTPUT_FILE_SUFFIX=".el$RESTY_IMAGE_TAG.$ARCHITECTURE.rpm"
;;
rhel)
OUTPUT_FILE_SUFFIX=".rhel$RESTY_IMAGE_TAG.$ARCHITECTURE.rpm"
;;
alpine)
OUTPUT_FILE_SUFFIX=".$ARCHITECTURE.apk.tar.gz"
;;
amazonlinux)
OUTPUT_FILE_SUFFIX=".aws.$ARCHITECTURE.rpm"
;;
src)
OUTPUT_FILE_SUFFIX=".tar.gz"
;;
esac
DIST_FILE="$KONG_PACKAGE_NAME-$KONG_VERSION$OUTPUT_FILE_SUFFIX"
function push_docker_images() {
docker tag \
"localhost:5000/kong-$RESTY_IMAGE_BASE-$RESTY_IMAGE_TAG" \
"$DOCKER_REPOSITORY:$ARCHITECTURE-$KONG_VERSION"
echo "FROM $DOCKER_REPOSITORY:$ARCHITECTURE-$KONG_VERSION" | docker build \
--label org.opencontainers.image.version="$KONG_VERSION" \
--label org.opencontainers.image.created="$DOCKER_LABEL_CREATED" \
--label org.opencontainers.image.revision="$DOCKER_LABEL_REVISION" \
-t "$DOCKER_REPOSITORY:$ARCHITECTURE-$KONG_VERSION" -
docker push "$DOCKER_REPOSITORY:$ARCHITECTURE-$KONG_VERSION"
docker manifest create \
-a "$DOCKER_REPOSITORY:$KONG_VERSION" \
"$DOCKER_REPOSITORY:$ARCHITECTURE-$KONG_VERSION"
docker manifest push "$DOCKER_REPOSITORY:$KONG_VERSION"
docker tag \
"localhost:5000/kong-$RESTY_IMAGE_BASE-$RESTY_IMAGE_TAG" \
"$DOCKER_REPOSITORY:$ARCHITECTURE-$DOCKER_TAG"
echo "FROM $DOCKER_REPOSITORY:$ARCHITECTURE-$DOCKER_TAG" | docker build \
--label org.opencontainers.image.version="$KONG_VERSION" \
--label org.opencontainers.image.created="$DOCKER_LABEL_CREATED" \
--label org.opencontainers.image.revision="$DOCKER_LABEL_REVISION" \
-t "$DOCKER_REPOSITORY:$ARCHITECTURE-$DOCKER_TAG" -
docker push "$DOCKER_REPOSITORY:$ARCHITECTURE-$DOCKER_TAG"
docker manifest create -a "$DOCKER_REPOSITORY:$DOCKER_TAG" \
"$DOCKER_REPOSITORY:$ARCHITECTURE-$DOCKER_TAG"
docker manifest push "$DOCKER_REPOSITORY:$DOCKER_TAG"
}
function push_package() {
# src has no dist-version
local dist_version="--dist-version $RESTY_IMAGE_TAG"
if [ "$RESTY_IMAGE_BASE" == "src" ]; then
dist_version=
curl -L "https://github.com/Kong/kong/archive/$KONG_VERSION.tar.gz" \
-o "output/$KONG_PACKAGE_NAME-$KONG_VERSION$OUTPUT_FILE_SUFFIX"
fi
if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
dist_version=
fi
set -x
eval $(docker-machine env -u) # release-scripts do not need to run within the arm64 box
docker run \
-e PULP_HOST="$PULP_HOST" \
-e PULP_USERNAME="$PULP_USERNAME" \
-e PULP_PASSWORD="$PULP_PASSWORD" \
-v "$BUILD_DIR:/files:ro" \
-i $PULP_DOCKER_IMAGE \
--file "/files/$DIST_FILE" \
--dist-name "$RESTY_IMAGE_BASE" $dist_version \
--major-version "${KONG_VERSION%%.*}.x" \
--package-type gateway \
--publish
set +x
}
# only push docker images for alpine builds
# this is for "release per commit" builds
if [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
push_docker_images
if [ "$RELEASE_DOCKER_ONLY" == "true" ]; then
exit 0
fi
fi
push_package
echo -e "\nReleasing Kong version '$KONG_VERSION' of '$RESTY_IMAGE_BASE $RESTY_IMAGE_TAG' done"
exit 0