Skip to content

Commit f3c0a0e

Browse files
authored
HBASE-24318 Create-release scripts fixes and enhancements (#1643)
* narrow 'dry-run' limits so see svn activity up to just before check-in. * Fix several typos and, in case of dry run, enable build step to chain from tag step by keeping the tagged git repo. * Improve Maven settings.xml file, and names of variables related to it. Remove unnecessary use of "-Dmaven.repo.local", put it in settings.xml instead. Stop putting password literals in settings.xml. * stop deleting maven settings file, now that it doesn't contain password strings * Merge 'tag' into release-build.sh as another stage. Also found and fixed a couple bugs in the current release-tag.sh. * Delete redundant release-tag.sh script. * Small changes to make dev-support/create-release tools less focused on hbase project only, while retaining special behaviors for hbase sub-projects which share the hbase dist and jira locations. * Changed terminology of release publish steps, from <build|publish> to <publish-dist|publish-release>. In fact, what was formerly called "build" built the distribution tarballs AND published them to dist, while "publish" built the maven artifacts AND published them to Nexus. The new terminology clarifies what's happening, and removes the appearance of order dependendency. * Fix publish-snapshot so it does same checks as publish-release. * Factor out common maven usages, and move them to build-util.sh. * Change default polarity of DRY_RUN to default to true. Change -n ("no-publish") to -f ("force publish") to actually publish. * Fix problems in do-release.sh so it runs correctly outside of docker, including DRY_RUN being exported. * Have do-release.sh set REPO (shared maven local repository) if doing all three stages. * Cleaned up REPO directory creation. * General cleanup of comments and usage. * fix all 'shellcheck' errors * use ${BASH_SOURCE[0]} instead of $0 to determine script directory path * smarter way to read version from pom with mvn * do maven-gpg-plugin config settings in maven settings file correctly as documented * fix gpg signing failure on Mac due to gpg-agent timeout * fix various bugs to enable publish-dist, publish-snapshot, and publish-release to work correctly as individual steps and/or without docker * improve log reporting from publish-release step * fix bug in argument to checkcompatibility.py: replace PACKAGE_VERSION with GIT_REF * demote "PACKAGE_VERSION" to "package_version_name" and undocument it in favor of RELEASE_TAG. Still enable appropriate defaulting in case RELEASE_TAG is undefined. * unify RELEASE_VERSION with VERSION, to remove ambiguity and allow it to be set when only running 'publish' step without 'tag' * query confirm RELEASE_TAG * emphasize that release-build.sh is called for a single action at a time, and should be called from do-release.sh. * add '-s' option to do-release.sh * suppress maven "Download from central:" messages * Replace human wait for tag propagation Signed-off-by: Cesar Delgado <cdelgado@apple.com> Signed-off-by: stack <stack@apache.org> Signed-off-by: Sean Busbey <busbey@apache.org>
1 parent 2774510 commit f3c0a0e

File tree

8 files changed

+592
-420
lines changed

8 files changed

+592
-420
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ linklint/
2121
.checkstyle
2222
**/.checkstyle
2323
.java-version
24+
*.log
25+
**/*.log

dev-support/create-release/README.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ For usage, pass '-h':
55

66
$ ./do-release-docker.sh -h
77

8-
To run a build w/o invoking docker (not recommeneded!), use
9-
_do_release.sh_. It does not take parameters. It will ask
10-
you what commands to run with taking defaults from environment.
8+
To run a build w/o invoking docker (not recommended!), use _do_release.sh_.
9+
10+
Both scripts will query interactively for needed parameters and passphrases.
11+
For explanation of the parameters, execute:
12+
$ release-build.sh --help
1113

1214
Before starting the RC build, run a reconciliation of what is in
1315
JIRA with what is in the commit log. Make sure they align and that
@@ -19,7 +21,6 @@ Running a build on GCE is easy enough. Here are some notes if of use.
1921
Create an instance. 4CPU/15G/10G disk seems to work well enough.
2022
Once up, run the below to make your machine fit for RC building:
2123

22-
2324
# Presuming debian-compatible OS
2425
$ sudo apt-get install -y git openjdk-8-jdk maven gnupg gnupg-agent
2526
# Install docker
@@ -37,13 +38,14 @@ $ sudo add-apt-repository -y \
3738
$ sudo apt-get update
3839
$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io
3940
$ sudo usermod -a -G docker $USERID
40-
# LOGOUT and then LOGIN again so $USERID shows as part of docker groupl
41+
# LOGOUT and then LOGIN again so $USERID shows as part of docker group
4142
# Copy up private key for $USERID export from laptop and import on gce.
4243
$ gpg --import stack.duboce.net.asc
4344
$ export GPG_TTY=$(tty) # https://github.com/keybase/keybase-issues/issues/2798
4445
$ eval $(gpg-agent --disable-scdaemon --daemon --no-grab --allow-preset-passphrase --default-cache-ttl=86400 --max-cache-ttl=86400)
45-
$ git clone https://github.com/apache/hbase.git
46-
$ cd hbase
46+
$ export PROJECT="${PROJECT:-hbase}"
47+
$ git clone https://github.com/apache/${PROJECT}.git
48+
$ cd "${PROJECT}"
4749
$ mkdir ~/build
4850
$ ./dev-resources/create-release/do-release-docker.sh -d ~/build
4951
# etc.

dev-support/create-release/do-release-docker.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,16 @@
4747
#
4848
set -e
4949

50-
# Set this building other hbase repos: e.g. PROJECT=hbase-operator-tools
50+
# Set this to build other hbase repos: e.g. PROJECT=hbase-operator-tools
5151
export PROJECT="${PROJECT:-hbase}"
5252

53-
SELF=$(cd $(dirname "$0") && pwd)
53+
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
54+
# shellcheck source=SCRIPTDIR/release-util.sh
5455
. "$SELF/release-util.sh"
5556

5657
function usage {
5758
local NAME
58-
NAME="$(basename "$0")"
59+
NAME="$(basename "${BASH_SOURCE[0]}")"
5960
cat <<EOF
6061
Usage: $NAME [options]
6162
@@ -64,24 +65,26 @@ This script runs the release scripts inside a docker image.
6465
Options:
6566
6667
-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+
-f "force" -- actually publish this release. Unless you specify '-f', it will
69+
default to dry run mode, which checks and does local builds, but does not upload anything.
6870
-t [tag] tag for the hbase-rm docker image to use for building (default: "latest").
6971
-j [path] path to local JDK installation to use building. By default the script will
7072
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.
73+
-p [project] project to build, such as 'hbase' or 'hbase-thirdparty'; defaults to $PROJECT env var
74+
-s [step] runs a single step of the process; valid steps are: tag|publish-dist|publish-release.
75+
If none specified, runs tag, then publish-dist, and then publish-release.
76+
'publish-snapshot' is also an allowed, less used, option.
7477
EOF
7578
}
7679

7780
WORKDIR=
7881
IMGTAG=latest
7982
JAVA=
8083
RELEASE_STEP=
81-
while getopts "d:hj:np:s:t:" opt; do
84+
while getopts "d:fhj:p:s:t:" opt; do
8285
case $opt in
8386
d) WORKDIR="$OPTARG" ;;
84-
n) DRY_RUN=1 ;;
87+
f) DRY_RUN=0 ;;
8588
t) IMGTAG="$OPTARG" ;;
8689
j) JAVA="$OPTARG" ;;
8790
p) PROJECT="$OPTARG" ;;
@@ -90,6 +93,10 @@ while getopts "d:hj:np:s:t:" opt; do
9093
?) error "Invalid option. Run with -h for help." ;;
9194
esac
9295
done
96+
shift $((OPTIND-1))
97+
if (( $# > 0 )); then
98+
error "Arguments can only be provided with option flags, invalid args: $*"
99+
fi
93100

94101
if [ -z "$WORKDIR" ] || [ ! -d "$WORKDIR" ]; then
95102
error "Work directory (-d) must be defined and exist. Run with -h for help."
@@ -145,27 +152,27 @@ NEXT_VERSION=$NEXT_VERSION
145152
RELEASE_VERSION=$RELEASE_VERSION
146153
RELEASE_TAG=$RELEASE_TAG
147154
GIT_REF=$GIT_REF
148-
PACKAGE_VERSION=$PACKAGE_VERSION
149155
ASF_USERNAME=$ASF_USERNAME
150156
GIT_NAME=$GIT_NAME
151157
GIT_EMAIL=$GIT_EMAIL
152158
GPG_KEY=$GPG_KEY
153159
ASF_PASSWORD=$ASF_PASSWORD
154160
GPG_PASSPHRASE=$GPG_PASSPHRASE
155161
RELEASE_STEP=$RELEASE_STEP
156-
RELEASE_STEP=$RELEASE_STEP
157162
API_DIFF_TAG=$API_DIFF_TAG
158163
EOF
159164

160-
JAVA_VOL=
165+
JAVA_VOL=()
161166
if [ -n "$JAVA" ]; then
162167
echo "JAVA_HOME=/opt/hbase-java" >> "$ENVFILE"
163-
JAVA_VOL="--volume $JAVA:/opt/hbase-java"
168+
JAVA_VOL=(--volume "$JAVA:/opt/hbase-java")
164169
fi
165170

166171
echo "Building $RELEASE_TAG; output will be at $WORKDIR/output"
167-
docker run -ti \
172+
cmd=(docker run -ti \
168173
--env-file "$ENVFILE" \
169174
--volume "$WORKDIR:/opt/hbase-rm" \
170-
$JAVA_VOL \
171-
"hbase-rm:$IMGTAG"
175+
"${JAVA_VOL[@]}" \
176+
"hbase-rm:$IMGTAG")
177+
echo "${cmd[*]}"
178+
"${cmd[@]}"

dev-support/create-release/do-release.sh

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,32 @@
2323
# and passwords to use building.
2424
export PROJECT="${PROJECT:-hbase}"
2525

26-
SELF=$(cd $(dirname $0) && pwd)
26+
SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27+
# shellcheck source=SCRIPTDIR/release-util.sh
2728
. "$SELF/release-util.sh"
2829

29-
while getopts "bn" opt; do
30+
while getopts "b:fs:" opt; do
3031
case $opt in
31-
b) GIT_BRANCH=$OPTARG ;;
32-
n) DRY_RUN=1 ;;
32+
b) export GIT_BRANCH=$OPTARG ;;
33+
f) export DRY_RUN=0 ;; # "force", ie actually publish this release (otherwise defaults to dry run)
34+
s) RELEASE_STEP="$OPTARG" ;;
3335
?) error "Invalid option: $OPTARG" ;;
3436
esac
3537
done
38+
shift $((OPTIND-1))
39+
if (( $# > 0 )); then
40+
error "Arguments can only be provided with option flags, invalid args: $*"
41+
fi
3642

3743
# If running in docker, import and then cache keys.
3844
if [ "$RUNNING_IN_DOCKER" = "1" ]; then
3945
# Run gpg agent.
40-
eval $(gpg-agent --disable-scdaemon --daemon --no-grab --allow-preset-passphrase --default-cache-ttl=86400 --max-cache-ttl=86400)
41-
echo "GPG Version: `gpg --version`"
42-
# Inside docker, need to import the GPG key stored in the current directory.
43-
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --import "$SELF/gpg.key"
46+
eval "$(gpg-agent --disable-scdaemon --daemon --no-grab --allow-preset-passphrase \
47+
--default-cache-ttl=86400 --max-cache-ttl=86400)"
48+
echo "GPG Version: $(gpg --version)"
49+
# Inside docker, need to import the GPG keyfile stored in the current directory.
50+
# (On workstation, assume GPG has access to keychain/cache with key_id already imported.)
51+
echo "$GPG_PASSPHRASE" | $GPG --passphrase-fd 0 --import "$SELF/gpg.key"
4452

4553
# We may need to adjust the path since JAVA_HOME may be overridden by the driver script.
4654
if [ -n "$JAVA_HOME" ]; then
@@ -53,7 +61,15 @@ else
5361
# Outside docker, need to ask for information about the release.
5462
get_release_info
5563
fi
56-
export GPG_TTY=$(tty)
64+
GPG_TTY="$(tty)"
65+
export GPG_TTY
66+
67+
if [[ -z "$RELEASE_STEP" ]]; then
68+
# If doing all stages, leave out 'publish-snapshot'
69+
RELEASE_STEP="tag_publish-dist_publish-release"
70+
# and use shared maven local repo for efficiency
71+
export REPO="${REPO:-$(pwd)/$(mktemp -d hbase-repo-XXXXX)}"
72+
fi
5773

5874
function should_build {
5975
local WHAT=$1
@@ -66,26 +82,30 @@ function should_build {
6682
fi
6783
}
6884

69-
if should_build "tag" && [ $SKIP_TAG = 0 ]; then
85+
if should_build "tag" && [ "$SKIP_TAG" = 0 ]; then
7086
run_silent "Creating release tag $RELEASE_TAG..." "tag.log" \
71-
"$SELF/release-tag.sh"
72-
echo "It may take some time for the tag to be synchronized to github."
73-
echo "Press enter when you've verified that the new tag ($RELEASE_TAG) is available."
74-
read
87+
"$SELF/release-build.sh" tag
88+
if is_dry_run; then
89+
export TAG_SAME_DRY_RUN="true";
90+
fi
7591
else
7692
echo "Skipping tag creation for $RELEASE_TAG."
7793
fi
7894

79-
if should_build "build"; then
80-
run_silent "Building ${PROJECT}..." "build.log" \
81-
"$SELF/release-build.sh" build
95+
if should_build "publish-dist"; then
96+
run_silent "Publishing distribution packages (tarballs)" "publish-dist.log" \
97+
"$SELF/release-build.sh" publish-dist
8298
else
83-
echo "Skipping build step."
99+
echo "Skipping publish-dist step."
84100
fi
85101

86-
if should_build "publish"; then
87-
run_silent "Publishing release" "publish.log" \
102+
if should_build "publish-snapshot"; then
103+
run_silent "Publishing snapshot" "publish-snapshot.log" \
104+
"$SELF/release-build.sh" publish-snapshot
105+
106+
elif should_build "publish-release"; then
107+
run_silent "Publishing release" "publish-release.log" \
88108
"$SELF/release-build.sh" publish-release
89109
else
90-
echo "Skipping publish step."
110+
echo "Skipping publish-release step."
91111
fi

0 commit comments

Comments
 (0)