Skip to content

Commit b6d4c70

Browse files
author
Marcelo Vanzin
committed
Even more fixes.
- Some bugs I introduced in last commit. - Fix release-tag.sh with Java 1.7. - Expand dry run to tag and publish steps.
1 parent a39933e commit b6d4c70

File tree

4 files changed

+82
-70
lines changed

4 files changed

+82
-70
lines changed

dev/create-release/do-release.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ fi
4646

4747
function should_build {
4848
local WHAT=$1
49-
[ -n "$RELEASE_STEP" ] && [ "$WHAT" = "$RELEASE_STEP" ]
49+
[ -z "$RELEASE_STEP" ] || [ "$WHAT" = "$RELEASE_STEP" ]
5050
}
5151

52-
if should_build "docs" && [ $SKIP_TAG = 0 ]; then
53-
maybe_run "Creating release tag $RELEASE_TAG..." "tag.log" \
52+
if should_build "tag" && [ $SKIP_TAG = 0 ]; then
53+
run_silent "Creating release tag $RELEASE_TAG..." "tag.log" \
5454
"$SELF/release-tag.sh"
5555
echo "It may take some time for the tag to be synchronized to github."
5656
echo "Press enter when you've verified that the new tag ($RELEASE_TAG) is available."
@@ -74,7 +74,7 @@ else
7474
fi
7575

7676
if should_build "publish"; then
77-
maybe_run "Publishing release" "publish.log" \
77+
run_silent "Publishing release" "publish.log" \
7878
"$SELF/release-build.sh" publish-release
7979
else
8080
echo "Skipping publish step."

dev/create-release/release-build.sh

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,11 @@ NEXUS_ROOT=https://repository.apache.org/service/local/staging
9090
NEXUS_PROFILE=d63f592e7eac0 # Profile for Spark staging uploads
9191
BASE_DIR=$(pwd)
9292

93-
MVN="build/mvn -B"
94-
95-
java_version=$("${JAVA_HOME}"/bin/javac -version 2>&1 | cut -d " " -f 2)
96-
MVN_EXTRA_OPTS=
97-
if [[ $java_version < "1.8." ]]; then
98-
# Needed for maven central when using Java 7.
99-
export SBT_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2"
100-
MVN_EXTRA_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2"
101-
MVN="$MVN $MVN_EXTRA_OPTS"
102-
fi
93+
init_java
94+
init_maven_sbt
10395

10496
rm -rf spark
105-
git clone https://git-wip-us.apache.org/repos/asf/spark.git
97+
git clone "$ASF_REPO"
10698
cd spark
10799
git checkout $GIT_REF
108100
git_hash=`git rev-parse --short HEAD`
@@ -138,22 +130,16 @@ PUBLISH_PROFILES="$BASE_PROFILES $HIVE_PROFILES -Pspark-ganglia-lgpl -Pkinesis-a
138130
# Profiles for building binary releases
139131
BASE_RELEASE_PROFILES="$BASE_PROFILES -Psparkr"
140132

141-
# Verify we have the right java version set
142-
if [ -z "$JAVA_HOME" ]; then
143-
echo "Please set JAVA_HOME."
144-
exit 1
145-
fi
146-
147133
if [[ ! $SPARK_VERSION < "2.2." ]]; then
148-
if [[ $java_version < "1.8." ]]; then
149-
echo "Java version $java_version is less than required 1.8 for 2.2+"
134+
if [[ $JAVA_VERSION < "1.8." ]]; then
135+
echo "Java version $JAVA_VERSION is less than required 1.8 for 2.2+"
150136
echo "Please set JAVA_HOME correctly."
151137
exit 1
152138
fi
153139
else
154-
if ! [[ $java_version =~ 1\.7\..* ]]; then
140+
if ! [[ $JAVA_VERSION =~ 1\.7\..* ]]; then
155141
if [ -z "$JAVA_7_HOME" ]; then
156-
echo "Java version $java_version is higher than required 1.7 for pre-2.2"
142+
echo "Java version $JAVA_VERSION is higher than required 1.7 for pre-2.2"
157143
echo "Please set JAVA_HOME correctly."
158144
exit 1
159145
else
@@ -378,13 +364,15 @@ if [[ "$1" == "publish-release" ]]; then
378364

379365
# Using Nexus API documented here:
380366
# https://support.sonatype.com/entries/39720203-Uploading-to-a-Staging-Repository-via-REST-API
381-
echo "Creating Nexus staging repository"
382-
repo_request="<promoteRequest><data><description>Apache Spark $SPARK_VERSION (commit $git_hash)</description></data></promoteRequest>"
383-
out=$(curl -X POST -d "$repo_request" -u $ASF_USERNAME:$ASF_PASSWORD \
384-
-H "Content-Type:application/xml" -v \
385-
$NEXUS_ROOT/profiles/$NEXUS_PROFILE/start)
386-
staged_repo_id=$(echo $out | sed -e "s/.*\(orgapachespark-[0-9]\{4\}\).*/\1/")
387-
echo "Created Nexus staging repository: $staged_repo_id"
367+
if ! is_dry_run; then
368+
echo "Creating Nexus staging repository"
369+
repo_request="<promoteRequest><data><description>Apache Spark $SPARK_VERSION (commit $git_hash)</description></data></promoteRequest>"
370+
out=$(curl -X POST -d "$repo_request" -u $ASF_USERNAME:$ASF_PASSWORD \
371+
-H "Content-Type:application/xml" -v \
372+
$NEXUS_ROOT/profiles/$NEXUS_PROFILE/start)
373+
staged_repo_id=$(echo $out | sed -e "s/.*\(orgapachespark-[0-9]\{4\}\).*/\1/")
374+
echo "Created Nexus staging repository: $staged_repo_id"
375+
fi
388376

389377
tmp_repo=$(mktemp -d spark-repo-XXXXX)
390378

@@ -393,7 +381,7 @@ if [[ "$1" == "publish-release" ]]; then
393381

394382
$MVN -DzincPort=$ZINC_PORT -Dmaven.repo.local=$tmp_repo -DskipTests $SCALA_2_11_PROFILES $PUBLISH_PROFILES clean install
395383

396-
if [[ $PUBLISH_SCALA_2_10 = 1 ]]; then
384+
if ! is_dry_run && [[ $PUBLISH_SCALA_2_10 = 1 ]]; then
397385
./dev/change-scala-version.sh 2.10
398386
$MVN -DzincPort=$((ZINC_PORT + 1)) -Dmaven.repo.local=$tmp_repo -Dscala-2.10 \
399387
-DskipTests $PUBLISH_PROFILES $SCALA_2_10_PROFILES clean install
@@ -429,23 +417,26 @@ if [[ "$1" == "publish-release" ]]; then
429417
sha1sum $file | cut -f1 -d' ' > $file.sha1
430418
done
431419

432-
nexus_upload=$NEXUS_ROOT/deployByRepositoryId/$staged_repo_id
433-
echo "Uplading files to $nexus_upload"
434-
for file in $(find . -type f)
435-
do
436-
# strip leading ./
437-
file_short=$(echo $file | sed -e "s/\.\///")
438-
dest_url="$nexus_upload/org/apache/spark/$file_short"
439-
echo " Uploading $file_short"
440-
curl -u $ASF_USERNAME:$ASF_PASSWORD --upload-file $file_short $dest_url
441-
done
420+
if ! is_dry_run; then
421+
nexus_upload=$NEXUS_ROOT/deployByRepositoryId/$staged_repo_id
422+
echo "Uplading files to $nexus_upload"
423+
for file in $(find . -type f)
424+
do
425+
# strip leading ./
426+
file_short=$(echo $file | sed -e "s/\.\///")
427+
dest_url="$nexus_upload/org/apache/spark/$file_short"
428+
echo " Uploading $file_short"
429+
curl -u $ASF_USERNAME:$ASF_PASSWORD --upload-file $file_short $dest_url
430+
done
431+
432+
echo "Closing nexus staging repository"
433+
repo_request="<promoteRequest><data><stagedRepositoryId>$staged_repo_id</stagedRepositoryId><description>Apache Spark $SPARK_VERSION (commit $git_hash)</description></data></promoteRequest>"
434+
out=$(curl -X POST -d "$repo_request" -u $ASF_USERNAME:$ASF_PASSWORD \
435+
-H "Content-Type:application/xml" -v \
436+
$NEXUS_ROOT/profiles/$NEXUS_PROFILE/finish)
437+
echo "Closed Nexus staging repository: $staged_repo_id"
438+
fi
442439

443-
echo "Closing nexus staging repository"
444-
repo_request="<promoteRequest><data><stagedRepositoryId>$staged_repo_id</stagedRepositoryId><description>Apache Spark $SPARK_VERSION (commit $git_hash)</description></data></promoteRequest>"
445-
out=$(curl -X POST -d "$repo_request" -u $ASF_USERNAME:$ASF_PASSWORD \
446-
-H "Content-Type:application/xml" -v \
447-
$NEXUS_ROOT/profiles/$NEXUS_PROFILE/finish)
448-
echo "Closed Nexus staging repository: $staged_repo_id"
449440
popd
450441
rm -rf $tmp_repo
451442
cd ..

dev/create-release/release-tag.sh

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
# limitations under the License.
1818
#
1919

20+
SELF=$(cd $(dirname $0) && pwd)
21+
. "$SELF/release-util.sh"
22+
2023
function exit_with_usage {
2124
cat << EOF
2225
usage: tag-release.sh
@@ -36,6 +39,7 @@ EOF
3639
}
3740

3841
set -e
42+
set -o pipefail
3943

4044
if [[ $@ == *"help"* ]]; then
4145
exit_with_usage
@@ -54,8 +58,10 @@ for env in ASF_USERNAME ASF_PASSWORD RELEASE_VERSION RELEASE_TAG NEXT_VERSION GI
5458
fi
5559
done
5660

61+
init_java
62+
init_maven_sbt
63+
5764
ASF_SPARK_REPO="git-wip-us.apache.org/repos/asf/spark.git"
58-
MVN="build/mvn --force"
5965

6066
rm -rf spark
6167
git clone "https://$ASF_USERNAME:$ASF_PASSWORD@$ASF_SPARK_REPO" -b $GIT_BRANCH
@@ -94,9 +100,15 @@ sed -i".tmp7" 's/SPARK_VERSION_SHORT:.*$/SPARK_VERSION_SHORT: '"$R_NEXT_VERSION"
94100

95101
git commit -a -m "Preparing development version $NEXT_VERSION"
96102

97-
# Push changes
98-
git push origin $RELEASE_TAG
99-
git push origin HEAD:$GIT_BRANCH
100-
101-
cd ..
102-
rm -rf spark
103+
if ! is_dry_run; then
104+
# Push changes
105+
git push origin $RELEASE_TAG
106+
git push origin HEAD:$GIT_BRANCH
107+
108+
cd ..
109+
rm -rf spark
110+
else
111+
cd ..
112+
mv spark spark.tag
113+
echo "Clone with version changes and tag available as spark.tag in the output directory."
114+
fi

dev/create-release/release-util.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ function run_silent {
6565
fi
6666
}
6767

68-
function maybe_run {
69-
if is_dry_run; then
70-
local BANNER="$1"
71-
local LOG_FILE="$2"
72-
shift 2
73-
echo "======= DRY RUN ======="
74-
echo "= $BANNER"
75-
echo "Command: $@"
76-
echo "Log file: $LOG_FILE"
77-
else
78-
run_silent "$@"
79-
fi
80-
}
81-
8268
function fcreate_secure {
8369
local FPATH="$1"
8470
rm -f "$FPATH"
@@ -217,3 +203,26 @@ EOF
217203
function is_dry_run {
218204
[[ $DRY_RUN = 1 ]]
219205
}
206+
207+
# Initializes JAVA_VERSION to the version of the JVM in use.
208+
function init_java {
209+
if [ -z "$JAVA_HOME" ]; then
210+
error "JAVA_HOME is not set."
211+
fi
212+
JAVA_VERSION=$("${JAVA_HOME}"/bin/javac -version 2>&1 | cut -d " " -f 2)
213+
export JAVA_VERSION
214+
}
215+
216+
# Initializes MVN_EXTRA_OPTS and SBT_OPTS depending on the JAVA_VERSION in use. Requires init_java.
217+
function init_maven_sbt {
218+
MVN="build/mvn -B"
219+
MVN_EXTRA_OPTS=
220+
SBT_OPTS=
221+
if [[ $JAVA_VERSION < "1.8." ]]; then
222+
# Needed for maven central when using Java 7.
223+
SBT_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2"
224+
MVN_EXTRA_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2"
225+
MVN="$MVN $MVN_EXTRA_OPTS"
226+
fi
227+
export MVN MVN_EXTRA_OPTS SBT_OPTS
228+
}

0 commit comments

Comments
 (0)