Skip to content

Commit febe511

Browse files
authored
HBASE-27359 Publish binaries and maven artifacts for both hadoop2 and hadoop3 (#4856)
Signed-off-by: Xiaolin Ha <[email protected]>
1 parent 31bb688 commit febe511

File tree

5 files changed

+136
-40
lines changed

5 files changed

+136
-40
lines changed

dev-support/create-release/hbase-rm/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
# * Java 8
2222
FROM ubuntu:22.04
2323

24-
2524
# Install extra needed repos and refresh.
2625
#
2726
# This is all in a single "RUN" command so that if anything changes, "apt update" is run to fetch
@@ -39,6 +38,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y update \
3938
python3-pip='22.0.2+dfsg-*' \
4039
subversion='1.14.1-*' \
4140
wget='1.21.2-*' \
41+
patch='2.7.6-*' \
4242
&& apt-get clean \
4343
&& rm -rf /var/lib/apt/lists/* \
4444
&& update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java \

dev-support/create-release/prepend_releasenotes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
if pattern.match(line):
3232
break
3333
line = prev_r.readline()
34+
w.writelines('# RELEASENOTES')
3435
for newline in new_r:
3536
w.writelines(newline)
3637
while line:

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ if [[ "$1" == "tag" ]]; then
130130
# So, here we prepend the project name to the version, but only for the hbase sub-projects.
131131
jira_fix_version="${RELEASE_VERSION}"
132132
shopt -s nocasematch
133-
if [[ "${PROJECT}" =~ ^hbase- ]]; then
133+
if [[ "${PROJECT}" == "hbase-thirdparty" ]]; then
134+
jira_fix_version="thirdparty-${RELEASE_VERSION}"
135+
elif [[ "${PROJECT}" =~ ^hbase- ]]; then
134136
jira_fix_version="${PROJECT}-${RELEASE_VERSION}"
135137
fi
136138
shopt -u nocasematch
137-
update_releasenotes "$(pwd)/${PROJECT}" "${jira_fix_version}" "${PREV_VERSION}"
139+
update_releasenotes "$(pwd)/${PROJECT}" "${jira_fix_version}"
138140

139141
cd "${PROJECT}"
140142

@@ -302,15 +304,31 @@ if [[ "$1" == "publish-release" ]]; then
302304
mvn_log="${BASE_DIR}/mvn_deploy_release.log"
303305
log "Staging release in nexus"
304306
maven_deploy release "$mvn_log"
305-
declare staged_repo_id="dryrun-no-repo"
307+
declare staged_repo_id
308+
declare hadoop3_staged_repo_id
306309
if ! is_dry_run; then
307-
staged_repo_id=$(grep -o "Closing staging repository with ID .*" "$mvn_log" \
310+
mapfile -t staged_repo_ids < <(grep -o "Closing staging repository with ID .*" "$mvn_log" \
308311
| sed -e 's/Closing staging repository with ID "\([^"]*\)"./\1/')
309-
log "Release artifacts successfully published to repo ${staged_repo_id}"
312+
log "Release artifacts successfully published to repo: " "${staged_repo_ids[@]}"
313+
repo_count="${#staged_repo_ids[@]}"
314+
if [[ "${repo_count}" == "2" ]]; then
315+
staged_repo_id=${staged_repo_ids[0]}
316+
hadoop3_staged_repo_id=${staged_repo_ids[1]}
317+
elif [[ "${repo_count}" == "1" ]]; then
318+
staged_repo_id=${staged_repo_ids[0]}
319+
hadoop3_staged_repo_id="not-applicable"
320+
else
321+
staged_repo_id="not-applicable"
322+
hadoop3_staged_repo_id="not-applicable"
323+
fi
310324
rm "$mvn_log"
311325
else
312326
log "Dry run: Release artifacts successfully built, but not published due to dry run."
327+
staged_repo_id="dryrun-no-repo"
328+
hadoop3_staged_repo_id="dryrun-no-repo"
313329
fi
330+
export staged_repo_id
331+
export hadoop3_staged_repo_id
314332
# Dump out email to send. Where we find vote.tmpl depends
315333
# on where this script is run from
316334
PROJECT_TEXT="${PROJECT//-/ }" #substitute like 's/-/ /g'

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

Lines changed: 107 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function banner {
7575
}
7676

7777
function log {
78-
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") ${1}"
78+
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ") $*"
7979
}
8080

8181
# current number of seconds since epoch
@@ -298,12 +298,11 @@ EOF
298298
fi
299299
GPG_ARGS=("${GPG_ARGS[@]}" --local-user "${GPG_KEY}")
300300

301-
if ! is_dry_run; then
302-
if [ -z "$ASF_PASSWORD" ]; then
303-
stty -echo && printf "ASF_PASSWORD: " && read -r ASF_PASSWORD && printf '\n' && stty echo
304-
fi
305-
else
306-
ASF_PASSWORD="***INVALID***"
301+
# The nexus staging plugin needs the password to contact to remote server even if
302+
# skipRemoteStaging is set to true, not sure why so here we need the password even
303+
# if this is a dry run
304+
if [ -z "$ASF_PASSWORD" ]; then
305+
stty -echo && printf "ASF_PASSWORD: " && read -r ASF_PASSWORD && printf '\n' && stty echo
307306
fi
308307

309308
export ASF_PASSWORD
@@ -561,7 +560,6 @@ function get_jira_name {
561560
function update_releasenotes {
562561
local project_dir="$1"
563562
local jira_fix_version="$2"
564-
local previous_jira_fix_version="$3"
565563
local jira_project
566564
local timing_token
567565
timing_token="$(start_step)"
@@ -583,15 +581,15 @@ function update_releasenotes {
583581
"${project_dir}/CHANGES.md" || true
584582
else
585583
# should be hbase 3.x, will copy CHANGES.md from archive.a.o/dist
586-
curl --location --fail --silent --show-error --output ${project_dir}/CHANGES.md "https://archive.apache.org/dist/hbase/${previous_jira_fix_version}/CHANGES.md"
584+
curl --location --fail --silent --show-error --output ${project_dir}/CHANGES.md "https://archive.apache.org/dist/hbase/${PREV_VERSION}/CHANGES.md"
587585
fi
588586
if [ -f "${project_dir}/RELEASENOTES.md" ]; then
589587
sed -i -e \
590588
"/^# ${jira_project} ${jira_fix_version} Release Notes/,/^# ${jira_project}/{//!d; /^# ${jira_project} ${jira_fix_version} Release Notes/d;}" \
591589
"${project_dir}/RELEASENOTES.md" || true
592590
else
593591
# should be hbase 3.x, will copy CHANGES.md from archive.a.o/dist
594-
curl --location --fail --silent --show-error --output ${project_dir}/RELEASENOTES.md "https://archive.apache.org/dist/hbase/${previous_jira_fix_version}/RELEASENOTES.md"
592+
curl --location --fail --silent --show-error --output ${project_dir}/RELEASENOTES.md "https://archive.apache.org/dist/hbase/${PREV_VERSION}/RELEASENOTES.md"
595593
fi
596594

597595
# Yetus will not generate CHANGES if no JIRAs fixed against the release version
@@ -645,39 +643,30 @@ make_src_release() {
645643
stop_step "${timing_token}"
646644
}
647645

648-
# Make binary release.
649-
# Takes as arguments first the project name -- e.g. hbase or hbase-operator-tools
650-
# -- and then the version string. Expects to find checkout adjacent to this script
651-
# named for 'project', the first arg passed.
652-
# Expects the following three defines in the environment:
653-
# - GPG needs to be defined, with the path to GPG: defaults 'gpg'.
654-
# - GIT_REF which is the tag to create the tgz from: defaults to 'master'.
655-
# - MVN Default is "mvn -B --settings $MAVEN_SETTINGS_FILE".
656-
# For example:
657-
# $ GIT_REF="master" make_src_release hbase-operator-tools 1.0.0
658-
make_binary_release() {
646+
build_release_binary() {
659647
local project="${1}"
660648
local version="${2}"
661649
local base_name="${project}-${version}"
662-
local timing_token
663-
timing_token="$(start_step)"
664-
rm -rf "${base_name}"-bin*
665-
cd "$project" || exit
650+
local extra_flags=()
651+
if [[ "${version}" = *-hadoop3 ]] || [[ "${version}" = *-hadoop3-SNAPSHOT ]]; then
652+
extra_flags=("-Drevision=${version}" "-Dhadoop.profile=3.0")
653+
fi
666654

655+
cd "$project" || exit
667656
git clean -d -f -x
668657
# Three invocations of maven. This seems to work. One to
669658
# populate the repo, another to build the site, and then
670659
# a third to assemble the binary artifact. Trying to do
671660
# all in the one invocation fails; a problem in our
672661
# assembly spec to in maven. TODO. Meantime, three invocations.
673-
cmd=("${MVN[@]}" clean install -DskipTests)
662+
cmd=("${MVN[@]}" "${extra_flags[@]}" clean install -DskipTests)
674663
echo "${cmd[*]}"
675664
"${cmd[@]}"
676-
cmd=("${MVN[@]}" site -DskipTests)
665+
cmd=("${MVN[@]}" "${extra_flags[@]}" site -DskipTests)
677666
echo "${cmd[*]}"
678667
"${cmd[@]}"
679668
kick_gpg_agent
680-
cmd=("${MVN[@]}" install assembly:single -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}")
669+
cmd=("${MVN[@]}" "${extra_flags[@]}" install assembly:single -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}")
681670
echo "${cmd[*]}"
682671
"${cmd[@]}"
683672

@@ -694,6 +683,30 @@ make_binary_release() {
694683
cd .. || exit
695684
log "No ${f_bin_prefix}*-bin.tar.gz product; expected?"
696685
fi
686+
}
687+
688+
# Make binary release.
689+
# Takes as arguments first the project name -- e.g. hbase or hbase-operator-tools
690+
# -- and then the version string. Expects to find checkout adjacent to this script
691+
# named for 'project', the first arg passed.
692+
# Expects the following three defines in the environment:
693+
# - GPG needs to be defined, with the path to GPG: defaults 'gpg'.
694+
# - GIT_REF which is the tag to create the tgz from: defaults to 'master'.
695+
# - MVN Default is "mvn -B --settings $MAVEN_SETTINGS_FILE".
696+
# For example:
697+
# $ GIT_REF="master" make_src_release hbase-operator-tools 1.0.0
698+
make_binary_release() {
699+
local project="${1}"
700+
local version="${2}"
701+
local base_name="${project}-${version}"
702+
local timing_token
703+
timing_token="$(start_step)"
704+
rm -rf "${base_name}"-bin*
705+
706+
build_release_binary "${project}" "${version}"
707+
if should_build_with_hadoop3 "$project/pom.xml"; then
708+
build_release_binary "${project}" "$(get_hadoop3_version "${version}")"
709+
fi
697710

698711
stop_step "${timing_token}"
699712
}
@@ -746,6 +759,7 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
746759
# Invoke with cwd=$PROJECT
747760
local deploy_type="$1"
748761
local mvn_log_file="$2" #secondary log file used later to extract staged_repo_id
762+
local staging_dir
749763
if [[ "$deploy_type" != "snapshot" && "$deploy_type" != "release" ]]; then
750764
error "unrecognized deploy type, must be 'snapshot'|'release'"
751765
fi
@@ -759,6 +773,8 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
759773
elif [[ "$deploy_type" == "release" ]] && [[ "$RELEASE_VERSION" =~ SNAPSHOT ]]; then
760774
error "Non-snapshot release version must not include the word 'SNAPSHOT'; you gave version '$RELEASE_VERSION'"
761775
fi
776+
# Just output to parent directory, the staging directory has a staging prefix already
777+
staging_dir="$(dirname "$(pwd)")/local-staged"
762778
# Publish ${PROJECT} to Maven repo
763779
# shellcheck disable=SC2154
764780
log "Publishing ${PROJECT} checkout at '$GIT_REF' ($git_hash)"
@@ -767,20 +783,44 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
767783
maven_set_version "$RELEASE_VERSION"
768784
# Prepare for signing
769785
kick_gpg_agent
770-
declare -a mvn_goals=(clean)
771-
if ! is_dry_run; then
772-
mvn_goals=("${mvn_goals[@]}" deploy)
786+
declare -a mvn_extra_flags=()
787+
if is_dry_run; then
788+
# In dry run mode, skip deploying to remote repo
789+
mvn_extra_flags=("${mvn_extra_flags[@]}" -DskipRemoteStaging)
773790
fi
774-
log "${MVN[@]}" -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}" "${mvn_goals[@]}"
791+
log "${MVN[@]}" clean deploy -DskipTests -Dcheckstyle.skip=true \
792+
-DaltStagingDirectory="${staging_dir}" "${PUBLISH_PROFILES[@]}" "${mvn_extra_flags[@]}"
775793
log "Logging to ${mvn_log_file}. This will take a while..."
776794
rm -f "$mvn_log_file"
777795
# The tortuous redirect in the next command allows mvn's stdout and stderr to go to mvn_log_file,
778796
# while also sending stderr back to the caller.
779797
# shellcheck disable=SC2094
780-
if ! "${MVN[@]}" -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}" \
781-
"${mvn_goals[@]}" 1>> "$mvn_log_file" 2> >( tee -a "$mvn_log_file" >&2 ); then
798+
if ! "${MVN[@]}" clean deploy -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}" \
799+
-DaltStagingDirectory="${staging_dir}" "${PUBLISH_PROFILES[@]}" "${mvn_extra_flags[@]}" \
800+
1>> "$mvn_log_file" 2> >( tee -a "$mvn_log_file" >&2 ); then
782801
error "Deploy build failed, for details see log at '$mvn_log_file'."
783802
fi
803+
local hadoop3_version
804+
if should_build_with_hadoop3 pom.xml; then
805+
hadoop3_version="$(get_hadoop3_version "${RELEASE_VERSION}")"
806+
hadoop3_staging_dir="${staging_dir}-hadoop3"
807+
log "Deploying artifacts for hadoop3..."
808+
log "${MVN[@]}" clean deploy -DskipTests -Dcheckstyle.skip=true \
809+
-Drevision="${hadoop3_version}" -Dhadoop.profile=3.0 \
810+
-DaltStagingDirectory="${hadoop3_staging_dir}" "${PUBLISH_PROFILES[@]}" "${mvn_extra_flags[@]}"
811+
{
812+
echo "========================================================================"
813+
echo "Deploy build for hadoop3"
814+
echo "========================================================================"
815+
} >> "$mvn_log_file"
816+
# shellcheck disable=SC2094
817+
if ! "${MVN[@]}" clean deploy -DskipTests -Dcheckstyle.skip=true "${PUBLISH_PROFILES[@]}" \
818+
-Drevision="${hadoop3_version}" -Dhadoop.profile=3.0 \
819+
-DaltStagingDirectory="${hadoop3_staging_dir}" "${PUBLISH_PROFILES[@]}" "${mvn_extra_flags[@]}" \
820+
1>> "$mvn_log_file" 2> >( tee -a "$mvn_log_file" >&2 ); then
821+
error "Deploy build failed, for details see log at '$mvn_log_file'."
822+
fi
823+
fi
784824
log "BUILD SUCCESS."
785825
stop_step "${timing_token}"
786826
return 0
@@ -798,3 +838,36 @@ function is_tracked() {
798838
git ls-files --error-unmatch "$file" &>/dev/null
799839
return $?
800840
}
841+
842+
# When we have all the below conditions matched, we will build hadoop3 binaries
843+
# 1. Use $revision place holder as version in pom
844+
# 2. Has a hadoop-2.0 profile
845+
# 3. Has a hadoop-3.0 profile
846+
function should_build_with_hadoop3() {
847+
local pom="$1"
848+
maven_version="$(parse_version < "${pom}")"
849+
# We do not want to expand ${revision} here, see https://maven.apache.org/maven-ci-friendly.html
850+
# If we use ${revision} as placeholder, the way to bump maven version will be different
851+
# shellcheck disable=SC2016
852+
if [[ "${maven_version}" != '${revision}' ]]; then
853+
return 1
854+
fi
855+
if ! xmllint --xpath "//*[local-name()='project']/*[local-name()='profiles']/*[local-name()='profile']/*[local-name()='id']/text()" "${pom}" \
856+
| grep -q ^hadoop-2.0$; then
857+
return 1
858+
fi
859+
if ! xmllint --xpath "//*[local-name()='project']/*[local-name()='profiles']/*[local-name()='profile']/*[local-name()='id']/text()" "${pom}" \
860+
| grep -q ^hadoop-3.0$; then
861+
return 1
862+
fi
863+
return 0
864+
}
865+
866+
function get_hadoop3_version() {
867+
local version="$1"
868+
if [[ "${version}" =~ -SNAPSHOT$ ]]; then
869+
echo "${version/-SNAPSHOT/-hadoop3-SNAPSHOT}"
870+
else
871+
echo "${version}-hadoop3"
872+
fi
873+
}

dev-support/create-release/vote.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Maven artifacts are available in a staging repository at:
2323

2424
https://repository.apache.org/content/repositories/${staged_repo_id}/
2525

26+
Maven artifacts for hadoop3 are available in a staging repository at:
27+
28+
https://repository.apache.org/content/repositories/${hadoop3_staged_repo_id}/
29+
2630
Artifacts were signed with the ${GPG_KEY} key which can be found in:
2731

2832
https://downloads.apache.org/hbase/KEYS

0 commit comments

Comments
 (0)