-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-patch-release
executable file
·285 lines (233 loc) · 9.24 KB
/
make-patch-release
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env bash
source "$(dirname "$0")/common.sh"
check_requirements
#-------------------------------------------------------------------------------
function usage() {
echo "Make a Kong patch release using this script:"
echo ""
echo "Usage:"
if [ "$version" = "<x.y.z>" ]
then
echo " List executed steps for a given release"
echo " $0 $version $1 $3"
echo
fi
c=1
step "check_milestone" "ensure all PRs marked on the release milestone are 100% merged"
step "check_dependencies" "ensure all kong dependencies are bumped in the rockspec"
step "create" "create the branch"
step "write_changelog" "prepare the changelog"
step "commit_changelog" "commit the changelog"
step "update_copyright" "update copyright file"
step "update_admin_api_def" "update Admin API definition"
step "version_bump" "bump and commit the version number"
step "submit_release_pr" "push and submit a release PR"
step "docs_pr" "push and submit a docs.konghq.com PR for the release"
step "merge" "merge, tag and sign the release"
step "approve_docker" "get humans to review and approve machine-provided pull request at docker-kong repo"
step "merge_docker" "merge, tag and sign Kong's docker-kong PR"
step "submit_docker" "submit a PR to docker-library/official-images"
step "merge_homebrew" "humans approve and merge machine PR to homebrew-kong"
step "upload_luarock" "upload to LuaRocks" "<api-key>"
step "merge_vagrant" "humans approve and merge machine PR to kong-vagrant"
step "merge_pongo" "humans approve and merge machine PR to kong-pongo"
step "announce" "Get announcement messages for Kong Nation and Slack #general"
#----------------------------------------------------------------------------------------
# The following steps are run by Jenkins, they should not be run by a human
# However we need to keep them here because Jenkins expects them to be here
step "update_docker" "(ran by Jenkins now) update and submit a PR to Kong's docker-kong repo"
step "homebrew" "(ran by Jenkins now) bump version and submit a PR to homebrew-kong"
step "vagrant" "(ran by Jenkins now) bump version and submit a PR to kong-vagrant"
step "pongo" "(ran by Jenkins now) bump version and submit a PR to kong-pongo"
exit 0
}
#-------------------------------------------------------------------------------
# Default help
#-------------------------------------------------------------------------------
if [ "$1" = "-h" ] || [ "$1" = "--help" ] || ! [ "$1" ]
then
version="<x.y.z>"
usage "$@"
fi
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
version="$1"
step="$2"
major=${version%%.*}
rest=${version#*.}
minor=${rest%%.*}
patch=${rest##*.}
rockspec="kong-$version-0.rockspec"
branch="release/$version"
base="release/$major.$minor.x"
if ! [[ "$version" =~ ^[0-9]+.[0-9]+.[0-9]$ ]]
then
die "first argument must be a version in x.y.z format"
fi
if [ "$step" = "" ]
then
usage "$@"
fi
EDITOR="${EDITOR-$VISUAL}"
case "$step" in
check_dependencies) check_dependencies ;;
check_milestone) check_milestone ;;
#---------------------------------------------------------------------------
create)
if [ $(git status --untracked-files=no --porcelain | wc -l) != "0" ]
then
die "Local tree is not clean, please commit or stash before running this."
fi
set -e
git checkout "$base"
git pull
git checkout -B "$branch"
SUCCESS "Release branch was created locally." \
"Ensure to cherry-pick all required changes into $branch." \
"And proceed to the next step:" \
" $0 $version cherry_pick"
;;
#---------------------------------------------------------------------------
write_changelog) write_changelog "$version" ;;
commit_changelog) commit_changelog "$version" ;;
update_copyright) update_copyright "$version" ;;
update_admin_api_def) update_admin_api_def "$version" ;;
#---------------------------------------------------------------------------
version_bump)
if ! grep -q "patch = $patch" kong/meta.lua
then
sed -i.bak 's/patch = [0-9]*/patch = '$patch'/' kong/meta.lua
git add kong/meta.lua
fi
if ! [ -f "$rockspec" ]
then
git mv kong-*-0.rockspec "$rockspec"
sed -i.bak 's/^version = ".*"/version = "'$version'-0"/' "$rockspec"
sed -i.bak 's/^ tag = ".*"/ tag = "'$version'"/' "$rockspec"
fi
git status
git diff
CONFIRM "If everything looks all right, press Enter to make the release commit" \
"or Ctrl-C to cancel."
git add $rockspec
git commit -m "release: $version"
git log -n 1
SUCCESS "Version bump for the release is now committed locally." \
"You are ready to run the next step:" \
" $0 $version submit_release_pr"
;;
#---------------------------------------------------------------------------
submit_release_pr) submit_release_pr "$branch" "$version" ;;
#---------------------------------------------------------------------------
merge)
CONFIRM "Press Enter to merge the PR into master and push the tag and Github release" \
"or Ctrl-C to cancel."
set -e
git checkout "$branch"
git pull
git checkout master
git pull
git merge "$branch"
git push
git tag -s "$version" -m "$version"
git push origin "$version"
make_github_release_file
hub release create -F release-$version.txt "$version"
rm -f release-$version.txt
SUCCESS "Make sure the packages are built and available on download.konghq.com" \
"before continuing to the following steps." \
"They should be visible on https://internal.builds.konghq.com/job/kong/view/tags/. " \
"An recurrent task checks for new releases every 15 minutes on the server. " \
"If needed, the link 'Scan Multibranch Pipeline Now' will scan on-demmand. It can be used " \
"to attempt to rebuild, if there was an error."
"As the packages are built, you may run the following steps in parallel:" \
"* 'upload_luarock'" \
"* 'merge_homebrew'" \
"* 'merge_vagrant'" \
"* 'merge_pongo'" \
"* 'approve_docker', then 'merge_docker', then 'submit_docker'"
;;
#---------------------------------------------------------------------------
docs_pr) docs_pr "$branch" ;;
approve_docker) approve_docker ;;
merge_docker) merge_docker "$branch" "$version" ;;
submit_docker) submit_docker "$version";;
merge_homebrew)merge_homebrew ;;
merge_pongo) merge_pongo ;;
merge_vagrant) merge_vagrant ;;
upload_luarock) upload_luarock "$rockspec" "$3" ;;
announce) announce "$major" "$minor" "$patch" ;;
# JENKINS-ONLY STEPS: -----------------------------------------------------
update_docker)
update_docker "$version"
SUCCESS "Make sure you get the PR above approved and merged" \
"before continuing to the step 'merge_docker'."
;;
homebrew)
if [ -d ../homebrew-kong ]
then
cd ../homebrew-kong
else
cd ..
git clone [email protected]:Kong/homebrew-kong.git
cd homebrew-kong
fi
git checkout master
git pull
git checkout -B "$branch"
bump_homebrew
git diff
CONFIRM "If everything looks all right, press Enter to commit and send a PR to [email protected]:Kong/homebrew-kong" \
"or Ctrl-C to cancel."
set -e
git add Formula/kong.rb
git commit -m "chore(kong) bump kong to $version"
git push --set-upstream origin "$branch"
hub pull-request -b master -h "$branch" -m "Release: $version"
SUCCESS "Make sure you get the PR above approved and merged."
;;
pongo)
if [ -d ../kong-pongo ]
then
cd ../kong-pongo
else
cd ..
git clone [email protected]:Kong/kong-pongo.git
cd kong-pongo
fi
git checkout master
git pull
./assets/add_version.sh CE "$version"
if [[ ! $? -eq 0 ]]; then
exit 1
fi
SUCCESS "Make sure you get the PR above approved and merged."
;;
vagrant)
if [ -d ../kong-vagrant ]
then
cd ../kong-vagrant
else
cd ..
git clone [email protected]:Kong/kong-vagrant.git
cd kong-vagrant
fi
git checkout master
git pull
git checkout -B "$branch"
bump_vagrant
git diff
CONFIRM "If everything looks all right, press Enter to commit and send a PR to [email protected]:Kong/kong-vagrant" \
"or Ctrl-C to cancel."
set -e
git add README.md Vagrantfile
git commit -m "chore(*) bump Kong to $version"
git push --set-upstream origin "$branch"
hub pull-request -b master -h "$branch" -m "Release: $version"
SUCCESS "Make sure you get the PR above approved and merged."
;;
*)
die "Unknown step!"
;;
esac