mattf-apache commented on a change in pull request #1643:
URL: https://github.com/apache/hbase/pull/1643#discussion_r420526164
##########
File path: dev-support/create-release/release-build.sh
##########
@@ -20,114 +20,180 @@
trap cleanup EXIT
# Source in utils.
-SELF=$(cd $(dirname $0) && pwd)
+SELF="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# shellcheck source=SCRIPTDIR/release-util.sh
. "$SELF/release-util.sh"
# Print usage and exit.
function exit_with_usage {
- cat << EOF
-Usage: release-build.sh <build|publish-snapshot|publish-release>
-Creates build deliverables from a tag/commit.
-Arguments:
- build Create binary packages and commit to
dist.apache.org/repos/dist/dev/hbase/
- publish-snapshot Publish snapshot release to Apache snapshots
- publish-release Publish a release to Apache release repo
-
-All other inputs are environment variables:
- GIT_REF - Release tag or commit to build from
- PACKAGE_VERSION - Release identifier in top level package directory (e.g.
2.1.2RC1)
- VERSION - (optional) Version of project being built (e.g. 2.1.2)
- ASF_USERNAME - Username of ASF committer account
- ASF_PASSWORD - Password of ASF committer account
- GPG_KEY - GPG key used to sign release artifacts
- GPG_PASSPHRASE - Passphrase for GPG key
- PROJECT - The project to build. No default.
-
-Set REPO environment to full path to repo to use
-to avoid re-downloading dependencies on each run.
+ cat <<'EOF'
+Usage: release-build.sh <tag|publish-dist|publish-snapshot|publish-release>
+Creates release deliverables from a tag or commit.
+Argument: one of 'tag', 'publish-dist', 'publish-snapshot', or
'publish-release'
+ tag Prepares for release on specified git branch: Set release
version,
+ update CHANGES and RELEASENOTES, create release tag,
+ increment version for ongoing dev, and publish to Apache
git repo.
+ publish-dist Build and publish distribution packages (tarballs) to
Apache dist repo
+ publish-snapshot Build and publish maven artifacts snapshot release to
Apache snapshots repo
+ publish-release Build and publish maven artifacts release to Apache
release repo, and
+ construct vote email from template
+
+All other inputs are environment variables. Please use do-release-docker.sh or
+do-release.sh to set up the needed environment variables. This script,
release-build.sh,
+is not intended to be called stand-alone, and such use is untested. The env
variables used are:
+
+Used for 'tag' and 'publish' stages:
+ PROJECT - The project to build. No default.
+ RELEASE_VERSION - Version used in pom files for release (e.g. 2.1.2)
+ Required for 'tag'; defaults for 'publish' to the version in pom at GIT_REF
+ RELEASE_TAG - Name of release tag (e.g. 2.1.2RC0), also used by
+ publish-dist as package version name in dist directory path
+ ASF_USERNAME - Username of ASF committer account
+ ASF_PASSWORD - Password of ASF committer account
+ DRY_RUN - 1:true (default), 0:false. If "1", does almost all the work, but
doesn't actually
+ publish anything to upstream source or object repositories. It defaults to
"1", so if you want
+ to actually publish you have to set '-f' (force) flag in do-release.sh or
do-release-docker.sh.
+
+Used only for 'tag':
+ GIT_NAME - Name to use with git
+ GIT_EMAIL - E-mail address to use with git
+ GIT_BRANCH - Git branch on which to make release. Tag is always placed at
HEAD of this branch.
+ NEXT_VERSION - Development version after release (e.g. 2.1.3-SNAPSHOT)
+
+Used only for 'publish':
+ GIT_REF - Release tag or commit to build from (defaults to $RELEASE_TAG;
only need to
+ separately define GIT_REF if RELEASE_TAG is not actually present as a tag
at publish time)
+ If both RELEASE_TAG and GIT_REF are undefined it will default to HEAD of
master.
+ GPG_KEY - GPG key id (usually email addr) used to sign release artifacts
+ GPG_PASSPHRASE - Passphrase for GPG key
+ REPO - Set to full path of a directory to use as maven local repo
(dependencies cache)
+ to avoid re-downloading dependencies for each stage. It is automatically
set if you
+ request full sequence of stages (tag, publish-dist, publish-release) in
do-release.sh.
For example:
- $ PROJECT="hbase-operator-tools" ASF_USERNAME=NAME ASF_PASSWORD=PASSWORD
GPG_PASSPHRASE=PASSWORD [email protected] ./release-build.sh build
+ $ PROJECT="hbase-operator-tools" ASF_USERNAME=NAME ASF_PASSWORD=PASSWORD
GPG_PASSPHRASE=PASSWORD [email protected] ./release-build.sh publish-dist
EOF
exit 1
}
set -e
function cleanup {
- echo "Cleaning up temp settings file." >&2
- rm "${tmp_settings}" &> /dev/null || true
# If REPO was set, then leave things be. Otherwise if we defined a repo
clean it out.
- if [[ -z "${REPO}" ]] && [[ -n "${tmp_repo}" ]]; then
- echo "Cleaning up temp repo in '${tmp_repo}'. set REPO to reuse
downloads." >&2
- rm -rf "${tmp_repo}" &> /dev/null || true
+ if [[ -z "${REPO}" ]] && [[ -n "${MAVEN_LOCAL_REPO}" ]]; then
+ echo "Cleaning up temp repo in '${MAVEN_LOCAL_REPO}'. Set REPO to reuse
downloads." >&2
+ rm -f "${MAVEN_SETTINGS_FILE}" &> /dev/null || true
+ rm -rf "${MAVEN_LOCAL_REPO}" &> /dev/null || true
fi
}
-if [ $# -eq 0 ]; then
+if [ $# -ne 1 ]; then
exit_with_usage
fi
-if [[ $@ == *"help"* ]]; then
+if [[ "$*" == *"help"* ]]; then
exit_with_usage
fi
-# Read in the ASF password.
-if [[ -z "$ASF_PASSWORD" ]]; then
- echo 'The environment variable ASF_PASSWORD is not set. Enter the password.'
- echo
- stty -echo && printf "ASF password: " && read ASF_PASSWORD && printf '\n' &&
stty echo
-fi
+init_locale
+init_java
+init_mvn
+init_python
+# Print out subset of perl version (used in git hooks)
+perl --version | grep 'This is'
-# Read in the GPG passphrase
-if [[ -z "$GPG_PASSPHRASE" ]]; then
- echo 'The environment variable GPG_PASSPHRASE is not set. Enter the
passphrase to'
- echo 'unlock the GPG signing key that will be used to sign the release!'
- echo
- stty -echo && printf "GPG passphrase: " && read GPG_PASSPHRASE && printf
'\n' && stty echo
- export GPG_PASSPHRASE
- export GPG_TTY=$(tty)
-fi
+rm -rf "${PROJECT}"
+
+if [[ "$1" == "tag" ]]; then
+ # for 'tag' stage
+ set -o pipefail
+ set -x # detailed logging during action
+ check_get_passwords ASF_PASSWORD
+ check_needed_vars PROJECT ASF_USERNAME ASF_PASSWORD RELEASE_VERSION
RELEASE_TAG NEXT_VERSION \
+ GIT_EMAIL GIT_NAME GIT_BRANCH
+ ASF_REPO="gitbox.apache.org/repos/asf/${PROJECT}.git"
+ encoded_username="$(python -c "import urllib; print
urllib.quote('''$ASF_USERNAME''')")"
+ encoded_password="$(python -c "import urllib; print
urllib.quote('''$ASF_PASSWORD''')")"
+ git clone "https://$encoded_username:$encoded_password@$ASF_REPO" -b
"$GIT_BRANCH" "${PROJECT}"
+
+ # 'update_releasenotes' searches the project's Jira for issues where 'Fix
Version' matches specified
+ # $jira_fix_version. For most projects this is same as ${RELEASE_VERSION}.
However, all the 'hbase-*'
+ # projects share the same HBASE jira name. To make this work, by
convention, the HBASE jira "Fix Version"
+ # field values have the sub-project name pre-pended, as in
"hbase-operator-tools-1.0.0".
+ # So, here we prepend the project name to the version, but only for the
hbase sub-projects.
+ jira_fix_version="${RELEASE_VERSION}"
+ shopt -s nocasematch
+ if [[ "${PROJECT}" =~ ^hbase- ]]; then
+ jira_fix_version="${PROJECT}-${RELEASE_VERSION}"
+ fi
+ shopt -u nocasematch
+ update_releasenotes "$(pwd)/${PROJECT}" "${jira_fix_version}"
+
+ cd "${PROJECT}"
+
+ git config user.name "$GIT_NAME"
+ git config user.email "$GIT_EMAIL"
-for env in ASF_USERNAME GPG_PASSPHRASE GPG_KEY; do
- if [ -z "${!env}" ]; then
- echo "ERROR: $env must be set to run this script"
- exit_with_usage
+ # Create release version
Review comment:
This whole block of code, starting with `if [[ "$1" == "tag" ]]; then`
is just cut in from what was formerly `release-tag.sh`. Unfortunately, `diff`
interleaved it with random chunks of deleted material from `release-build.sh`,
so the flow isn't as obvious as one would wish. The answer to your question is
item #3 below:
The flow of `tag` is, briefly:
1. Checkout the code
1. Update Release Notes -- use yetus scripts to scan Jira data and update
CHANGES.md and RELEASENOTES.md
1. Set maven version in pom.xml for the release or release candidate you are
making. This just uses the version you've specified in do-release.sh, which is
usually a release candidate version, but it's up to you.
1. Do `git commit`
1. Do `git tag` to make the tag for the release.
1. Set maven version again, this time to the dev version to be used on this
branch _after_ the release.
1. Do `git commit` again.
1. Finally, _if not a dry run,_ do a `git push` to the Apache source
repository, thereby "publishing" the tag and the new state of the dev branch.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]