HBASE-24118 [Flakey Tests] TestCloseRegionWhileRSCrash
[hbase.git] / dev-support / create-release / do-release-docker.sh
blob3012d3cb2151b4502f24941655ebc536bef24b90
1 #!/usr/bin/env bash
3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
20 # Creates a HBase release candidate. The script will update versions, tag the branch,
21 # build HBase binary packages and documentation, and upload maven artifacts to a staging
22 # repository. There is also a dry run mode where only local builds are performed, and
23 # nothing is uploaded to the ASF repos.
25 # Run with "-h" for options. For example, running below will do all
26 # steps above using the 'rm' dir under Downloads as workspace:
28 # $ ./do-release-docker.sh -d ~/Downloads/rm
30 # The scripts in this directory came originally from spark [1]. They were then
31 # modified to suite the hbase context. These scripts supercedes the old
32 # ../make_rc.sh script for making release candidates because what is here is more
33 # comprehensive doing more steps of the RM process as well as running in a
34 # container so the RM build environment can be a constant.
36 # It:
37 # * Tags release
38 # * Sets version to the release version
39 # * Sets version to next SNAPSHOT version.
40 # * Builds, signs, and hashes all artifacts.
41 # * Pushes release tgzs to the dev dir in a apache dist.
42 # * Pushes to repository.apache.org staging.
44 # The entry point is here, in the do-release-docker.sh script.
46 # 1. https://github.com/apache/spark/tree/master/dev/create-release
48 set -e
50 # Set this building other hbase repos: e.g. PROJECT=hbase-operator-tools
51 export PROJECT="${PROJECT:-hbase}"
53 SELF=$(cd $(dirname "$0") && pwd)
54 . "$SELF/release-util.sh"
56 function usage {
57 local NAME
58 NAME="$(basename "$0")"
59 cat <<EOF
60 Usage: $NAME [options]
62 This script runs the release scripts inside a docker image.
64 Options:
66 -d [path] required. working directory. output will be written to "output" in here.
67 -n dry run mode. Checks and local builds, but does not upload anything.
68 -t [tag] tag for the hbase-rm docker image to use for building (default: "latest").
69 -j [path] path to local JDK installation to use building. By default the script will
70 use openjdk8 installed in the docker image.
71 -p [project] project to build; default 'hbase'; alternatively, 'hbase-thirdparty', etc.
72 -s [step] runs a single step of the process; valid steps are: tag, build, publish. if
73 none specified, runs tag, then build, and then publish.
74 EOF
77 WORKDIR=
78 IMGTAG=latest
79 JAVA=
80 RELEASE_STEP=
81 while getopts "d:hj:np:s:t:" opt; do
82 case $opt in
83 d) WORKDIR="$OPTARG" ;;
84 n) DRY_RUN=1 ;;
85 t) IMGTAG="$OPTARG" ;;
86 j) JAVA="$OPTARG" ;;
87 p) PROJECT="$OPTARG" ;;
88 s) RELEASE_STEP="$OPTARG" ;;
89 h) usage ;;
90 ?) error "Invalid option. Run with -h for help." ;;
91 esac
92 done
94 if [ -z "$WORKDIR" ] || [ ! -d "$WORKDIR" ]; then
95 error "Work directory (-d) must be defined and exist. Run with -h for help."
98 if [ -d "$WORKDIR/output" ]; then
99 read -r -p "Output directory already exists. Overwrite and continue? [y/n] " ANSWER
100 if [ "$ANSWER" != "y" ]; then
101 error "Exiting."
105 cd "$WORKDIR"
106 rm -rf "$WORKDIR/output"
107 mkdir "$WORKDIR/output"
109 get_release_info
111 # Place all RM scripts and necessary data in a local directory that must be defined in the command
112 # line. This directory is mounted into the image. Its WORKDIR, the arg passed with -d.
113 for f in "$SELF"/*; do
114 if [ -f "$f" ]; then
115 cp "$f" "$WORKDIR"
117 done
119 GPG_KEY_FILE="$WORKDIR/gpg.key"
120 fcreate_secure "$GPG_KEY_FILE"
121 $GPG --passphrase "$GPG_PASSPHRASE" --export-secret-key --armor "$GPG_KEY" > "$GPG_KEY_FILE"
123 run_silent "Building hbase-rm image with tag $IMGTAG..." "docker-build.log" \
124 docker build -t "hbase-rm:$IMGTAG" --build-arg UID=$UID "$SELF/hbase-rm"
126 # Write the release information to a file with environment variables to be used when running the
127 # image.
128 ENVFILE="$WORKDIR/env.list"
129 fcreate_secure "$ENVFILE"
131 function cleanup {
132 rm -f "$ENVFILE"
133 rm -f "$GPG_KEY_FILE"
136 trap cleanup EXIT
138 cat > "$ENVFILE" <<EOF
139 PROJECT=$PROJECT
140 DRY_RUN=$DRY_RUN
141 SKIP_TAG=$SKIP_TAG
142 RUNNING_IN_DOCKER=1
143 GIT_BRANCH=$GIT_BRANCH
144 NEXT_VERSION=$NEXT_VERSION
145 RELEASE_VERSION=$RELEASE_VERSION
146 RELEASE_TAG=$RELEASE_TAG
147 GIT_REF=$GIT_REF
148 PACKAGE_VERSION=$PACKAGE_VERSION
149 ASF_USERNAME=$ASF_USERNAME
150 GIT_NAME=$GIT_NAME
151 GIT_EMAIL=$GIT_EMAIL
152 GPG_KEY=$GPG_KEY
153 ASF_PASSWORD=$ASF_PASSWORD
154 GPG_PASSPHRASE=$GPG_PASSPHRASE
155 RELEASE_STEP=$RELEASE_STEP
156 RELEASE_STEP=$RELEASE_STEP
157 API_DIFF_TAG=$API_DIFF_TAG
160 JAVA_VOL=
161 if [ -n "$JAVA" ]; then
162 echo "JAVA_HOME=/opt/hbase-java" >> "$ENVFILE"
163 JAVA_VOL="--volume $JAVA:/opt/hbase-java"
166 echo "Building $RELEASE_TAG; output will be at $WORKDIR/output"
167 docker run -ti \
168 --env-file "$ENVFILE" \
169 --volume "$WORKDIR:/opt/hbase-rm" \
170 $JAVA_VOL \
171 "hbase-rm:$IMGTAG"