Skip to content

Commit 4e7d867

Browse files
Marcelo Vanzintgravescs
authored andcommitted
[SPARK-24372][BUILD] Add scripts to help with preparing releases.
The "do-release.sh" script asks questions about the RC being prepared, trying to find out as much as possible automatically, and then executes the existing scripts with proper arguments to prepare the release. This script was used to prepare the 2.3.1 release candidates, so was tested in that context. The docker version runs that same script inside a docker image especially crafted for building Spark releases. That image is based on the work by Felix C. linked in the bug. At this point is has been only midly tested. I also added a template for the vote e-mail, with placeholders for things that need to be replaced, although there is no automation around that for the moment. It shouldn't be hard to hook up certain things like version and tags to this, or to figure out certain things like the repo URL from the output of the release scripts. Author: Marcelo Vanzin <[email protected]> Closes #21515 from vanzin/SPARK-24372.
1 parent 33e77fa commit 4e7d867

File tree

8 files changed

+736
-85
lines changed

8 files changed

+736
-85
lines changed

dev/.rat-excludes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ spark-warehouse
106106
structured-streaming/*
107107
kafka-source-initial-offset-version-2.1.0.bin
108108
kafka-source-initial-offset-future-version.bin
109+
vote.tmpl
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
#
21+
# Creates a Spark release candidate. The script will update versions, tag the branch,
22+
# build Spark binary packages and documentation, and upload maven artifacts to a staging
23+
# repository. There is also a dry run mode where only local builds are performed, and
24+
# nothing is uploaded to the ASF repos.
25+
#
26+
# Run with "-h" for options.
27+
#
28+
29+
set -e
30+
SELF=$(cd $(dirname $0) && pwd)
31+
. "$SELF/release-util.sh"
32+
33+
function usage {
34+
local NAME=$(basename $0)
35+
cat <<EOF
36+
Usage: $NAME [options]
37+
38+
This script runs the release scripts inside a docker image. The image is hardcoded to be called
39+
"spark-rm" and will be re-generated (as needed) on every invocation of this script.
40+
41+
Options are:
42+
43+
-d [path] : required: working directory (output will be written to an "output" directory in
44+
the working directory).
45+
-n : dry run mode. Performs checks and local builds, but do not upload anything.
46+
-t [tag] : tag for the spark-rm docker image to use for building (default: "latest").
47+
-j [path] : path to local JDK installation to use for building. By default the script will
48+
use openjdk8 installed in the docker image.
49+
-s [step] : runs a single step of the process; valid steps are: tag, build, docs, publish
50+
EOF
51+
}
52+
53+
WORKDIR=
54+
IMGTAG=latest
55+
JAVA=
56+
RELEASE_STEP=
57+
while getopts "d:hj:ns:t:" opt; do
58+
case $opt in
59+
d) WORKDIR="$OPTARG" ;;
60+
n) DRY_RUN=1 ;;
61+
t) IMGTAG="$OPTARG" ;;
62+
j) JAVA="$OPTARG" ;;
63+
s) RELEASE_STEP="$OPTARG" ;;
64+
h) usage ;;
65+
?) error "Invalid option. Run with -h for help." ;;
66+
esac
67+
done
68+
69+
if [ -z "$WORKDIR" ] || [ ! -d "$WORKDIR" ]; then
70+
error "Work directory (-d) must be defined and exist. Run with -h for help."
71+
fi
72+
73+
if [ -d "$WORKDIR/output" ]; then
74+
read -p "Output directory already exists. Overwrite and continue? [y/n] " ANSWER
75+
if [ "$ANSWER" != "y" ]; then
76+
error "Exiting."
77+
fi
78+
fi
79+
80+
cd "$WORKDIR"
81+
rm -rf "$WORKDIR/output"
82+
mkdir "$WORKDIR/output"
83+
84+
get_release_info
85+
86+
# Place all RM scripts and necessary data in a local directory that must be defined in the command
87+
# line. This directory is mounted into the image.
88+
for f in "$SELF"/*; do
89+
if [ -f "$f" ]; then
90+
cp "$f" "$WORKDIR"
91+
fi
92+
done
93+
94+
GPG_KEY_FILE="$WORKDIR/gpg.key"
95+
fcreate_secure "$GPG_KEY_FILE"
96+
$GPG --export-secret-key --armor "$GPG_KEY" > "$GPG_KEY_FILE"
97+
98+
run_silent "Building spark-rm image with tag $IMGTAG..." "docker-build.log" \
99+
docker build -t "spark-rm:$IMGTAG" --build-arg UID=$UID "$SELF/spark-rm"
100+
101+
# Write the release information to a file with environment variables to be used when running the
102+
# image.
103+
ENVFILE="$WORKDIR/env.list"
104+
fcreate_secure "$ENVFILE"
105+
106+
function cleanup {
107+
rm -f "$ENVFILE"
108+
rm -f "$GPG_KEY_FILE"
109+
}
110+
111+
trap cleanup EXIT
112+
113+
cat > $ENVFILE <<EOF
114+
DRY_RUN=$DRY_RUN
115+
SKIP_TAG=$SKIP_TAG
116+
RUNNING_IN_DOCKER=1
117+
GIT_BRANCH=$GIT_BRANCH
118+
NEXT_VERSION=$NEXT_VERSION
119+
RELEASE_VERSION=$RELEASE_VERSION
120+
RELEASE_TAG=$RELEASE_TAG
121+
GIT_REF=$GIT_REF
122+
SPARK_PACKAGE_VERSION=$SPARK_PACKAGE_VERSION
123+
ASF_USERNAME=$ASF_USERNAME
124+
GIT_NAME=$GIT_NAME
125+
GIT_EMAIL=$GIT_EMAIL
126+
GPG_KEY=$GPG_KEY
127+
ASF_PASSWORD=$ASF_PASSWORD
128+
GPG_PASSPHRASE=$GPG_PASSPHRASE
129+
RELEASE_STEP=$RELEASE_STEP
130+
EOF
131+
132+
JAVA_VOL=
133+
if [ -n "$JAVA" ]; then
134+
echo "JAVA_HOME=/opt/spark-java" >> $ENVFILE
135+
JAVA_VOL="--volume $JAVA:/opt/spark-java"
136+
fi
137+
138+
echo "Building $RELEASE_TAG; output will be at $WORKDIR/output"
139+
docker run -ti \
140+
--env-file "$ENVFILE" \
141+
--volume "$WORKDIR:/opt/spark-rm" \
142+
$JAVA_VOL \
143+
"spark-rm:$IMGTAG"

dev/create-release/do-release.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
SELF=$(cd $(dirname $0) && pwd)
21+
. "$SELF/release-util.sh"
22+
23+
while getopts "bn" opt; do
24+
case $opt in
25+
b) GIT_BRANCH=$OPTARG ;;
26+
n) DRY_RUN=1 ;;
27+
?) error "Invalid option: $OPTARG" ;;
28+
esac
29+
done
30+
31+
if [ "$RUNNING_IN_DOCKER" = "1" ]; then
32+
# Inside docker, need to import the GPG key stored in the current directory.
33+
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --import "$SELF/gpg.key"
34+
35+
# We may need to adjust the path since JAVA_HOME may be overridden by the driver script.
36+
if [ -n "$JAVA_HOME" ]; then
37+
export PATH="$JAVA_HOME/bin:$PATH"
38+
else
39+
# JAVA_HOME for the openjdk package.
40+
export JAVA_HOME=/usr
41+
fi
42+
else
43+
# Outside docker, need to ask for information about the release.
44+
get_release_info
45+
fi
46+
47+
function should_build {
48+
local WHAT=$1
49+
[ -z "$RELEASE_STEP" ] || [ "$WHAT" = "$RELEASE_STEP" ]
50+
}
51+
52+
if should_build "tag" && [ $SKIP_TAG = 0 ]; then
53+
run_silent "Creating release tag $RELEASE_TAG..." "tag.log" \
54+
"$SELF/release-tag.sh"
55+
echo "It may take some time for the tag to be synchronized to github."
56+
echo "Press enter when you've verified that the new tag ($RELEASE_TAG) is available."
57+
read
58+
else
59+
echo "Skipping tag creation for $RELEASE_TAG."
60+
fi
61+
62+
if should_build "build"; then
63+
run_silent "Building Spark..." "build.log" \
64+
"$SELF/release-build.sh" package
65+
else
66+
echo "Skipping build step."
67+
fi
68+
69+
if should_build "docs"; then
70+
run_silent "Building documentation..." "docs.log" \
71+
"$SELF/release-build.sh" docs
72+
else
73+
echo "Skipping docs step."
74+
fi
75+
76+
if should_build "publish"; then
77+
run_silent "Publishing release" "publish.log" \
78+
"$SELF/release-build.sh" publish-release
79+
else
80+
echo "Skipping publish step."
81+
fi

0 commit comments

Comments
 (0)