Skip to content

Commit 903bc12

Browse files
committed
Move duplicate code to common_release.sh
1 parent a3eb676 commit 903bc12

File tree

3 files changed

+128
-124
lines changed

3 files changed

+128
-124
lines changed

dev/common_release.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
# common fucntions
21+
22+
if [[ -z "${TAR}" ]]; then
23+
TAR="/usr/bin/tar"
24+
fi
25+
26+
if [[ -z "${SHASUM}" ]]; then
27+
SHASUM="/usr/bin/shasum"
28+
fi
29+
30+
if [[ -z "${WORKING_DIR}" ]]; then
31+
WORKING_DIR="/tmp/zeppelin-release"
32+
fi
33+
34+
mkdir "${WORKING_DIR}"
35+
36+
usage() {
37+
echo "usage) $0 [Release version] [Branch or Tag]"
38+
echo " ex. $0 0.6.0 v0.6.0"
39+
exit 1
40+
}
41+
42+
function git_clone() {
43+
echo "Clone the source"
44+
# clone source
45+
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git "${WORKING_DIR}/zeppelin"
46+
47+
if [[ $? -ne 0 ]]; then
48+
echo "Can not clone source repository"
49+
exit 1
50+
fi
51+
52+
cd "${WORKING_DIR}/zeppelin"
53+
git checkout "${GIT_TAG}"
54+
echo "Checked out ${GIT_TAG}"
55+
56+
# remove unnecessary files
57+
rm "${WORKING_DIR}/zeppelin/.gitignore"
58+
rm -rf "${WORKING_DIR}/zeppelin/.git"
59+
rm -rf "${WORKING_DIR}/zeppelin/.github"
60+
rm -rf "${WORKING_DIR}/zeppelin/docs"
61+
}

dev/create_release.sh

Lines changed: 55 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -18,85 +18,54 @@
1818
#
1919

2020
# The script helps making a release.
21-
# You need specify a release name and branch|tag name.
21+
# You need to specify release version and branch|tag name.
2222
#
23-
# Here's some helpful documents for the release
23+
# Here are some helpful documents for the release.
2424
# http://www.apache.org/dev/release.html
2525
# http://www.apache.org/dev/release-publishing
2626
# http://www.apache.org/dev/release-signing.html
27-
# http://www.apache.org/dev/publishing-maven-artifacts.html
28-
29-
if [[ -z "${TAR}" ]]; then
30-
TAR=/usr/bin/tar
31-
fi
32-
33-
if [[ -z "${SHASUM}" ]]; then
34-
SHASUM="/usr/bin/shasum -a 512"
35-
fi
3627

28+
BASEDIR="$(dirname "$0")"
29+
. "${BASEDIR}/common_release.sh"
30+
echo "${BASEDIR}/common_release.sh"
3731

38-
if [[ -z "${WORKING_DIR}" ]]; then
39-
WORKING_DIR=/tmp/zeppelin-release
32+
if [[ $# -ne 2 ]]; then
33+
usage
4034
fi
4135

4236
if [[ -z "${GPG_PASSPHRASE}" ]]; then
4337
echo "You need GPG_PASSPHRASE variable set"
4438
exit 1
4539
fi
4640

47-
48-
if [[ $# -ne 2 ]]; then
49-
echo "usage) $0 [Release version] [Tag]"
50-
echo " ex. $0 0.6.0 v0.6.0-rc1"
51-
exit 1
52-
fi
53-
54-
RELEASE_VERSION="${1}"
55-
GIT_TAG="${2}"
56-
57-
if [[ -d "${WORKING_DIR}" ]]; then
58-
echo "Dir ${WORKING_DIR} already exists"
59-
exit 1
60-
fi
61-
62-
mkdir ${WORKING_DIR}
63-
64-
echo "Cloning the source and packaging"
65-
# clone source
66-
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git ${WORKING_DIR}/zeppelin
67-
68-
if [[ $? -ne 0 ]]; then
69-
echo "Can not clone source repository"
70-
exit 1
71-
fi
72-
73-
cd ${WORKING_DIR}/zeppelin
74-
git checkout ${GIT_TAG}
75-
echo "Checked out ${GIT_TAG}"
76-
77-
# remove unnecessary files
78-
rm ${WORKING_DIR}/zeppelin/.gitignore
79-
rm -rf ${WORKING_DIR}/zeppelin/.git
80-
81-
82-
# create source package
83-
cd ${WORKING_DIR}
84-
cp -r zeppelin zeppelin-${RELEASE_VERSION}
85-
${TAR} cvzf zeppelin-${RELEASE_VERSION}.tgz zeppelin-${RELEASE_VERSION}
86-
87-
echo "Signing the source package"
88-
cd ${WORKING_DIR}
89-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --armor --output zeppelin-${RELEASE_VERSION}.tgz.asc --detach-sig ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz
90-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --print-md MD5 zeppelin-${RELEASE_VERSION}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.md5
91-
${SHASUM} zeppelin-${RELEASE_VERSION}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.sha512
92-
41+
RELEASE_VERSION="$1"
42+
GIT_TAG="$2"
43+
44+
function make_source_package() {
45+
# create source package
46+
cd ${WORKING_DIR}
47+
cp -r "zeppelin" "zeppelin-${RELEASE_VERSION}"
48+
${TAR} cvzf "zeppelin-${RELEASE_VERSION}.tgz" "zeppelin-${RELEASE_VERSION}"
49+
50+
echo "Signing the source package"
51+
cd "${WORKING_DIR}"
52+
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --armor \
53+
--output "zeppelin-${RELEASE_VERSION}.tgz.asc" \
54+
--detach-sig "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz"
55+
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 \
56+
--print-md MD5 "zeppelin-${RELEASE_VERSION}.tgz" > \
57+
"${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.md5"
58+
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 \
59+
--print-md SHA512 "zeppelin-${RELEASE_VERSION}.tgz" > \
60+
"${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.sha512"
61+
}
9362

9463
function make_binary_release() {
95-
BIN_RELEASE_NAME="${1}"
96-
BUILD_FLAGS="${2}"
64+
BIN_RELEASE_NAME="$1"
65+
BUILD_FLAGS="$2"
9766

98-
cp -r ${WORKING_DIR}/zeppelin ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
99-
cd ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
67+
cp -r "${WORKING_DIR}/zeppelin" "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
68+
cd "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
10069
echo "mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}"
10170
mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}
10271
if [[ $? -ne 0 ]]; then
@@ -106,29 +75,36 @@ function make_binary_release() {
10675

10776
# re-create package with proper dir name with binary license
10877
cd zeppelin-distribution/target/zeppelin-*
109-
mv zeppelin-* zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
110-
cat ../../src/bin_license/LICENSE >> zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/LICENSE
111-
cat ../../src/bin_license/NOTICE >> zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/NOTICE
112-
cp ../../src/bin_license/licenses/* zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/licenses/
113-
${TAR} cvzf zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
78+
mv zeppelin-* "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
79+
cat ../../src/bin_license/LICENSE >> "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/LICENSE"
80+
cat ../../src/bin_license/NOTICE >> "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/NOTICE"
81+
cp ../../src/bin_license/licenses/* "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/licenses/"
82+
${TAR} cvzf "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
11483

11584
# sign bin package
116-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --armor --output zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc --detach-sig zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz
117-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --print-md MD5 zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz > zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5
118-
${SHASUM} zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz > zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512
119-
120-
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz ${WORKING_DIR}/
121-
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc ${WORKING_DIR}/
122-
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5 ${WORKING_DIR}/
123-
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512 ${WORKING_DIR}/
85+
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --armor \
86+
--output "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc" \
87+
--detach-sig "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz"
88+
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --print-md MD5 \
89+
"zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" > \
90+
"zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5"
91+
${SHASUM} -a 512 "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" > \
92+
"zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512"
93+
94+
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" "${WORKING_DIR}/"
95+
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc" "${WORKING_DIR}/"
96+
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5" "${WORKING_DIR}/"
97+
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512" "${WORKING_DIR}/"
12498

12599
# clean up build dir
126-
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
100+
rm -rf "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
127101
}
128102

103+
git_clone
104+
make_source_package
129105
make_binary_release all "-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark"
130106

131107
# remove non release files and dirs
132-
rm -rf ${WORKING_DIR}/zeppelin
133-
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}
108+
rm -rf "${WORKING_DIR}/zeppelin"
109+
rm -rf "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}"
134110
echo "Release files are created under ${WORKING_DIR}"

dev/publish_release.sh

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,20 @@
1717
# limitations under the License.
1818
#
1919

20-
# The script helps publishing release to mavene.
21-
# You need to specify release version and tag name.
20+
# The script helps publishing release to maven.
21+
# You need to specify release version and branch|tag name.
2222
#
23-
# Here are some helpful documents for the release.
24-
# http://www.apache.org/dev/release.html
25-
# http://www.apache.org/dev/release-publishing
26-
# http://www.apache.org/dev/release-signing.html
23+
# Here's some helpful documents for the release.
2724
# http://www.apache.org/dev/publishing-maven-artifacts.html
2825

29-
if [[ -z "${SHASUM}" ]]; then
30-
SHASUM="/usr/bin/shasum -a 1"
31-
fi
32-
33-
if [[ -z "${WORKING_DIR}" ]]; then
34-
WORKING_DIR="/tmp/zeppelin-release"
35-
fi
26+
BASEDIR="$(dirname "$0")"
27+
. "${BASEDIR}/common_release.sh"
3628

37-
if [ $# -ne 2 ]; then
38-
echo "usage) $0 [Release version] [Tag]"
39-
echo " ex. $0 0.6.0 v0.6.0"
40-
exit 1
29+
if [[ $# -ne 2 ]]; then
30+
usage
4131
fi
4232

43-
for var in GPG_PASSPHRASE; do ASF_USERID ASF_PASSWORD; do
33+
for var in GPG_PASSPHRASE ASF_USERID ASF_PASSWORD; do
4434
if [[ -z "${!var}" ]]; then
4535
echo "You need ${var} variable set"
4636
exit 1
@@ -52,35 +42,11 @@ export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m"
5242
RELEASE_VERSION="$1"
5343
GIT_TAG="$2"
5444

55-
PUBLISH_PROFILES="-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark -Psparkr -Pr"
45+
PUBLISH_PROFILES="-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark"
5646
PROJECT_OPTIONS="-pl !zeppelin-distribution"
5747
NEXUS_STAGING="https://repository.apache.org/service/local/staging"
5848
NEXUS_PROFILE="153446d1ac37c4"
5949

60-
if [[ -d "${WORKING_DIR}" ]]; then
61-
echo "Dir ${WORKING_DIR} already exists"
62-
exit 1
63-
fi
64-
65-
mkdir "${WORKING_DIR}"
66-
67-
echo "Cloning the source"
68-
# clone source
69-
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git "${WORKING_DIR}/zeppelin"
70-
71-
if [[ $? -ne 0 ]]; then
72-
echo "Can not clone source repository"
73-
exit 1
74-
fi
75-
76-
cd "${WORKING_DIR}/zeppelin"
77-
git checkout "${GIT_TAG}"
78-
echo "Checked out ${GIT_TAG}"
79-
80-
# remove unnecessary files
81-
rm "${WORKING_DIR}/zeppelin/.gitignore"
82-
rm -rf "${WORKING_DIR}/zeppelin/.git"
83-
8450
function publish_to_maven() {
8551
cd "${WORKING_DIR}/zeppelin"
8652

@@ -117,7 +83,7 @@ function publish_to_maven() {
11783
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --output "${file}.asc" \
11884
--detach-sig --armor "${file}"
11985
md5 -q "${file}" > "${file}.md5"
120-
${SHASUM} "${file}" | cut -f1 -d' ' > "${file}.sha1"
86+
${SHASUM} -a 1 "${file}" | cut -f1 -d' ' > "${file}.sha1"
12187
done
12288

12389
nexus_upload="${NEXUS_STAGING}/deployByRepositoryId/${staged_repo_id}"
@@ -140,7 +106,8 @@ function publish_to_maven() {
140106
rm -rf "${tmp_repo}"
141107
}
142108

109+
git_clone
143110
publish_to_maven
144111

145112
# remove working directory
146-
rm -rf "${WORKING_DIR}"
113+
rm -rf "${WORKING_DIR}/zeppelin"

0 commit comments

Comments
 (0)