forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_release_candidate.sh
executable file
·346 lines (302 loc) · 13 KB
/
build_release_candidate.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
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This script will create a Release Candidate, includes:
# 1. Build and stage java artifacts
# 2. Stage source release on dist.apache.org
# 3. Stage python source distribution and wheels on dist.apache.org
# 4. Stage SDK docker images
# 5. Create a PR to update beam-site
set -e
if [[ "$JAVA_HOME" ]]; then
version=$("$JAVA_HOME/bin/java" -version 2>&1 | awk -F '"' '/version/ {print $2}')
if [[ ! `echo $version | sed "s/1\.8\..*/1.8/"` == "1.8" ]]; then
echo "Java version $version detected. Set \$JAVA_HOME to point to a JDK 8 installation."
exit 1
fi
else
echo "\$JAVA_HOME must be set."
exit 1
fi
LOCAL_CLONE_DIR=build_release_candidate
LOCAL_JAVA_STAGING_DIR=java_staging_dir
LOCAL_PYTHON_STAGING_DIR=python_staging_dir
LOCAL_PYTHON_VIRTUALENV=${LOCAL_PYTHON_STAGING_DIR}/venv
LOCAL_WEBSITE_UPDATE_DIR=website_update_dir
LOCAL_PYTHON_DOC=python_doc
LOCAL_JAVA_DOC=java_doc
LOCAL_WEBSITE_REPO=beam_website_repo
USER_REMOTE_URL=
USER_GITHUB_ID=
GIT_REPO_BASE_URL=apache/beam
GIT_REPO_URL=https://github.com/${GIT_REPO_BASE_URL}
ROOT_SVN_URL=https://dist.apache.org/repos/dist/dev/beam
GIT_BEAM_ARCHIVE=https://github.com/apache/beam/archive
GIT_BEAM_WEBSITE=https://github.com/apache/beam-site.git
PYTHON_ARTIFACTS_DIR=python
BEAM_ROOT_DIR=beam
WEBSITE_ROOT_DIR=beam-site
echo "================Setting Up Environment Variables==========="
echo "Which release version are you working on: "
read RELEASE
RELEASE_BRANCH=release-${RELEASE}
echo "Which release candidate number(e.g. 1) are you going to create: "
read RC_NUM
echo "Please enter your github username(ID): "
read USER_GITHUB_ID
USER_REMOTE_URL=https://github.com/${USER_GITHUB_ID}/beam-site
echo "=================Pre-requirements===================="
echo "Please make sure you have configured and started your gpg by running ./preparation_before_release.sh."
echo "================Listing all GPG keys================="
gpg --list-keys --keyid-format LONG --fingerprint --fingerprint
echo "Please copy the public key which is associated with your Apache account:"
read SIGNING_KEY
echo "================Checking Environment Variables=============="
echo "beam repo will be cloned into: ${LOCAL_CLONE_DIR}"
echo "working on release version: ${RELEASE}"
echo "working on release branch: ${RELEASE_BRANCH}"
echo "will create release candidate: RC${RC_NUM}"
echo "Your forked beam-site URL: ${USER_REMOTE_URL}"
echo "Your signing key: ${SIGNING_KEY}"
echo "Please review all environment variables and confirm: [y|N]"
read confirmation
if [[ $confirmation != "y" ]]; then
echo "Please rerun this script and make sure you have the right inputs."
exit
fi
echo "[Current Step]: Build and stage java artifacts"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "============Building and Staging Java Artifacts============="
echo "--------Cloning Beam Repo and Checkout Release Branch-------"
cd ~
if [[ -d ${LOCAL_CLONE_DIR} ]]; then
rm -rf ${LOCAL_CLONE_DIR}
fi
mkdir -p ${LOCAL_CLONE_DIR}
cd ${LOCAL_CLONE_DIR}
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}
RELEASE_COMMIT=$(git rev-parse --verify ${RELEASE_BRANCH})
echo "-------------Building Java Artifacts with Gradle-------------"
git config credential.helper store
if git rev-parse "v${RELEASE}-RC${RC_NUM}" >/dev/null 2>&1; then
echo "Tag v${RELEASE}-RC${RC_NUM} already exists."
echo "Delete the tag and create a new tag commit (y) or skip this step (n)? [y/N]"
read confirmation
if [[ $confirmation = "y" ]]; then
# Delete tag with the git push <from>:<to> format, as shown here:
# https://git-scm.com/docs/git-push#Documentation/git-push.txt-codegitpushoriginexperimentalcode
git push origin :refs/tags/v${RELEASE}-RC${RC_NUM}
fi
fi
if [[ $confirmation = "y" ]]; then # Expected to be "y" unless user chose to skip creating tag.
./gradlew release -Prelease.newVersion=${RELEASE}-SNAPSHOT \
-Prelease.releaseVersion=${RELEASE}-RC${RC_NUM} \
-Prelease.useAutomaticVersion=true --info --no-daemon
git push origin "${RELEASE_BRANCH}"
git push origin "v${RELEASE}-RC${RC_NUM}"
fi
echo "-------------Staging Java Artifacts into Maven---------------"
gpg --local-user ${SIGNING_KEY} --output /dev/null --sign ~/.bashrc
./gradlew publish -Psigning.gnupg.keyName=${SIGNING_KEY} -PisRelease --no-daemon
echo "You need to close the staging repository manually on Apache Nexus. See the release guide for instructions."
rm -rf ~/${LOCAL_CLONE_DIR}
fi
echo "[Current Step]: Stage source release on dist.apache.org"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "=========Staging Source Release on dist.apache.org==========="
cd ~
if [[ -d ${LOCAL_JAVA_STAGING_DIR} ]]; then
rm -rf ${LOCAL_JAVA_STAGING_DIR}
fi
mkdir -p ${LOCAL_JAVA_STAGING_DIR}
cd ${LOCAL_JAVA_STAGING_DIR}
svn co ${ROOT_SVN_URL}
mkdir -p beam/${RELEASE}
cd beam/${RELEASE}
echo "----------------Downloading Source Release-------------------"
SOURCE_RELEASE_ZIP="apache-beam-${RELEASE}-source-release.zip"
# Check whether there is an existing dist dir
if (svn ls "${SOURCE_RELEASE_ZIP}"); then
echo "Removing existing ${SOURCE_RELEASE_ZIP}."
svn delete "${SOURCE_RELEASE_ZIP}"
fi
echo "Downloading: ${GIT_BEAM_ARCHIVE}/release-${RELEASE}.zip"
wget ${GIT_BEAM_ARCHIVE}/release-${RELEASE}.zip -O "${SOURCE_RELEASE_ZIP}"
echo "----Signing Source Release ${SOURCE_RELEASE_ZIP}-----"
gpg --local-user ${SIGNING_KEY} --armor --detach-sig "${SOURCE_RELEASE_ZIP}"
echo "----Creating Hash Value for ${SOURCE_RELEASE_ZIP}----"
sha512sum ${SOURCE_RELEASE_ZIP} > ${SOURCE_RELEASE_ZIP}.sha512
svn add --force .
svn status
echo "Please confirm these changes are ready to commit: [y|N] "
read confirmation
if [[ $confirmation != "y" ]]; then
echo "Exit without staging source release on dist.apache.org."
else
svn commit --no-auth-cache --non-interactive -m "Staging Java artifacts for Apache Beam ${RELEASE} RC${RC_NUM}"
fi
rm -rf ~/${LOCAL_JAVA_STAGING_DIR}
fi
echo "[Current Step]: Stage python source distribution and wheels on dist.apache.org"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "============Staging Python Binaries on dist.apache.org========="
cd ~
if [[ -d "${LOCAL_PYTHON_STAGING_DIR}" ]]; then
rm -rf "${LOCAL_PYTHON_STAGING_DIR}"
fi
mkdir -p "${LOCAL_PYTHON_STAGING_DIR}"
cd "${LOCAL_PYTHON_STAGING_DIR}"
echo '-------------------Cloning Beam Release Branch-----------------'
git clone "${GIT_REPO_URL}"
cd "${BEAM_ROOT_DIR}"
git checkout "${RELEASE_BRANCH}"
RELEASE_COMMIT=$(git rev-parse --verify HEAD)
echo '-------------------Creating Python Virtualenv-----------------'
python3 -m venv "${LOCAL_PYTHON_VIRTUALENV}"
source "${LOCAL_PYTHON_VIRTUALENV}/bin/activate"
pip install requests python-dateutil
echo '--------------Fetching GitHub Actions Artifacts--------------'
SVN_ARTIFACTS_DIR="beam/${RELEASE}/${PYTHON_ARTIFACTS_DIR}"
svn co https://dist.apache.org/repos/dist/dev/beam
mkdir -p "${SVN_ARTIFACTS_DIR}"
python release/src/main/scripts/download_github_actions_artifacts.py \
--github-user "${USER_GITHUB_ID}" \
--repo-url "${GIT_REPO_BASE_URL}" \
--release-branch "${RELEASE_BRANCH}" \
--release-commit "${RELEASE_COMMIT}" \
--artifacts_dir "${SVN_ARTIFACTS_DIR}"
cd "${SVN_ARTIFACTS_DIR}"
echo "------Checking Hash Value for apache-beam-${RELEASE}.zip-----"
sha512sum -c "apache-beam-${RELEASE}.zip.sha512"
echo "------Signing Source Release apache-beam-${RELEASE}.zip------"
gpg --local-user "${SIGNING_KEY}" --armor --detach-sig "apache-beam-${RELEASE}.zip"
for artifact in *.whl; do
echo "----------Checking Hash Value for ${artifact} wheel-----------"
sha512sum -c "${artifact}.sha512"
done
for artifact in *.whl; do
echo "------------------Signing ${artifact} wheel-------------------"
gpg --local-user "${SIGNING_KEY}" --armor --detach-sig "${artifact}"
done
cd ..
svn add --force ${PYTHON_ARTIFACTS_DIR}
svn status
echo "Please confirm these changes are ready to commit: [y|N] "
read confirmation
if [[ $confirmation != "y" ]]; then
echo "Exit without staging python artifacts on dist.apache.org."
else
svn commit --no-auth-cache --non-interactive -m "Staging Python artifacts for Apache Beam ${RELEASE} RC${RC_NUM}"
fi
rm -rf "${HOME:?}/${LOCAL_PYTHON_STAGING_DIR}"
fi
echo "[Current Step]: Stage docker images"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "============Staging SDK docker images on docker hub========="
cd ~
if [[ -d ${LOCAL_CLONE_DIR} ]]; then
rm -rf ${LOCAL_CLONE_DIR}
fi
mkdir -p ${LOCAL_CLONE_DIR}
cd ${LOCAL_CLONE_DIR}
echo '-------------------Cloning Beam Release Branch-----------------'
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}
./gradlew :pushAllDockerImages -Pdocker-pull-licenses -Pdocker-tag=${RELEASE}_rc${RC_NUM}
rm -rf ~/${LOCAL_CLONE_DIR}
fi
echo "[Current Step]: Update beam-site"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "==============Creating PR for Updating Website==============="
cd ~
if [[ -d ${LOCAL_WEBSITE_UPDATE_DIR} ]]; then
rm -rf ${LOCAL_WEBSITE_UPDATE_DIR}
fi
mkdir -p ${LOCAL_WEBSITE_UPDATE_DIR}
cd ${LOCAL_WEBSITE_UPDATE_DIR}
mkdir -p ${LOCAL_PYTHON_DOC}
mkdir -p ${LOCAL_JAVA_DOC}
mkdir -p ${LOCAL_WEBSITE_REPO}
echo "------------------Building Python Doc------------------------"
python3 -m venv "${LOCAL_PYTHON_VIRTUALENV}"
source "${LOCAL_PYTHON_VIRTUALENV}/bin/activate"
cd ${LOCAL_PYTHON_DOC}
pip install tox
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}
RELEASE_COMMIT=$(git rev-parse --verify ${RELEASE_BRANCH})
cd sdks/python && pip install -r build-requirements.txt && tox -e py38-docs
GENERATED_PYDOC=~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_PYTHON_DOC}/${BEAM_ROOT_DIR}/sdks/python/target/docs/_build
rm -rf ${GENERATED_PYDOC}/.doctrees
echo "----------------------Building Java Doc----------------------"
cd ~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_JAVA_DOC}
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}
./gradlew :sdks:java:javadoc:aggregateJavadoc
GENERATE_JAVADOC=~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_JAVA_DOC}/${BEAM_ROOT_DIR}/sdks/java/javadoc/build/docs/javadoc/
echo "------------------Updating Release Docs---------------------"
cd ~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_WEBSITE_REPO}
git clone ${GIT_BEAM_WEBSITE}
cd ${WEBSITE_ROOT_DIR}
git checkout release-docs
git checkout -b updates_release_${RELEASE} release-docs
echo "..........Copying generated javadoc into beam-site.........."
cp -r ${GENERATE_JAVADOC} javadoc/${RELEASE}
echo "............Copying generated pydoc into beam-site.........."
cp -r ${GENERATED_PYDOC} pydoc/${RELEASE}
git add -A
git commit -m "Update beam-site for release ${RELEASE}." -m "Content generated from commit ${RELEASE_COMMIT}."
git push -f ${USER_REMOTE_URL}
# Check if hub is installed. See https://stackoverflow.com/a/677212
if ! hash hub 2> /dev/null; then
echo "You don't have hub installed, do you want to install hub with sudo permission? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
HUB_VERSION=2.5.0
HUB_ARTIFACTS_NAME=hub-linux-amd64-${HUB_VERSION}
wget https://github.com/github/hub/releases/download/v${HUB_VERSION}/${HUB_ARTIFACTS_NAME}.tgz
tar zvxvf ${HUB_ARTIFACTS_NAME}.tgz
sudo ./${HUB_ARTIFACTS_NAME}/install
echo "eval "$(hub alias -s)"" >> ~/.bashrc
rm -rf ${HUB_ARTIFACTS_NAME}*
fi
fi
if hash hub 2> /dev/null; then
hub pull-request -m "Publish ${RELEASE} release" -h ${USER_GITHUB_ID}:updates_release_${RELEASE} -b apache:release-docs \
|| echo "Pull request creation did not succeed. If you created the website PR earlier it may have been updated via force-push."
else
echo "Without hub, you need to create PR manually."
fi
echo "Finished v${RELEASE}-RC${RC_NUM} creation."
rm -rf ~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_JAVA_DOC}
rm -rf ~/${LOCAL_WEBSITE_UPDATE_DIR}/${LOCAL_PYTHON_DOC}
fi