Skip to content

Commit cd1f08c

Browse files
committed
Refactor create release script
1 parent e764f5f commit cd1f08c

File tree

1 file changed

+58
-55
lines changed

1 file changed

+58
-55
lines changed

dev/create_release.sh

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -27,105 +27,108 @@
2727
# http://www.apache.org/dev/publishing-maven-artifacts.html
2828

2929
if [[ -z "${TAR}" ]]; then
30-
TAR=/usr/bin/tar
30+
TAR=/usr/bin/tar
3131
fi
3232

3333
if [[ -z "${SHASUM}" ]]; then
34-
SHASUM="/usr/bin/shasum -a 512"
34+
SHASUM="/usr/bin/shasum -a 512"
3535
fi
3636

3737

3838
if [[ -z "${WORKING_DIR}" ]]; then
39-
WORKING_DIR=/tmp/zeppelin-release
39+
WORKING_DIR=/tmp/zeppelin-release
4040
fi
4141

4242
if [[ -z "${GPG_PASSPHRASE}" ]]; then
43-
echo "You need GPG_PASSPHRASE variable set"
44-
exit 1
43+
echo "You need GPG_PASSPHRASE variable set"
44+
exit 1
4545
fi
4646

4747

4848
if [[ $# -ne 2 ]]; then
49-
echo "usage) $0 [Release name] [Branch or Tag]"
50-
echo " ex. $0 0.6.0 branch-0.6"
51-
exit 1
49+
echo "usage) $0 [Release version] [Tag]"
50+
echo " ex. $0 0.6.0 v0.6.0-rc1"
51+
exit 1
5252
fi
5353

54-
RELEASE_NAME="${1}"
55-
BRANCH="${2}"
56-
54+
RELEASE_VERSION="${1}"
55+
GIT_TAG="${2}"
5756

5857
if [[ -d "${WORKING_DIR}" ]]; then
59-
echo "Dir ${WORKING_DIR} already exists"
60-
exit 1
58+
echo "Dir ${WORKING_DIR} already exists"
59+
exit 1
6160
fi
6261

6362
mkdir ${WORKING_DIR}
6463

6564
echo "Cloning the source and packaging"
6665
# clone source
67-
git clone -b ${BRANCH} [email protected]:apache/zeppelin.git ${WORKING_DIR}/zeppelin
66+
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git ${WORKING_DIR}/zeppelin
67+
6868
if [[ $? -ne 0 ]]; then
69-
echo "Can not clone source repository"
70-
exit 1
69+
echo "Can not clone source repository"
70+
exit 1
7171
fi
7272

73+
cd ${WORKING_DIR}/zeppelin
74+
git checkout ${GIT_TAG}
75+
echo "Checked out ${GIT_TAG}"
76+
7377
# remove unnecessary files
7478
rm ${WORKING_DIR}/zeppelin/.gitignore
7579
rm -rf ${WORKING_DIR}/zeppelin/.git
7680

7781

78-
7982
# create source package
8083
cd ${WORKING_DIR}
81-
cp -r zeppelin zeppelin-${RELEASE_NAME}
82-
${TAR} cvzf zeppelin-${RELEASE_NAME}.tgz zeppelin-${RELEASE_NAME}
84+
cp -r zeppelin zeppelin-${RELEASE_VERSION}
85+
${TAR} cvzf zeppelin-${RELEASE_VERSION}.tgz zeppelin-${RELEASE_VERSION}
8386

8487
echo "Signing the source package"
8588
cd ${WORKING_DIR}
86-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --armor --output zeppelin-${RELEASE_NAME}.tgz.asc --detach-sig ${WORKING_DIR}/zeppelin-${RELEASE_NAME}.tgz
87-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --print-md MD5 zeppelin-${RELEASE_NAME}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_NAME}.tgz.md5
88-
${SHASUM} zeppelin-${RELEASE_NAME}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_NAME}.tgz.sha512
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
8992

9093

9194
function make_binary_release() {
92-
BIN_RELEASE_NAME="${1}"
93-
BUILD_FLAGS="${2}"
94-
95-
cp -r ${WORKING_DIR}/zeppelin ${WORKING_DIR}/zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}
96-
cd ${WORKING_DIR}/zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}
97-
echo "mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}"
98-
mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}
99-
if [[ $? -ne 0 ]]; then
100-
echo "Build failed. ${BUILD_FLAGS}"
101-
exit 1
102-
fi
103-
104-
# re-create package with proper dir name with binary license
105-
cd zeppelin-distribution/target/zeppelin-*
106-
mv zeppelin-* zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}
107-
cat ../../src/bin_license/LICENSE >> zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}/LICENSE
108-
cat ../../src/bin_license/NOTICE >> zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}/NOTICE
109-
cp ../../src/bin_license/licenses/* zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}/licenses/
110-
${TAR} cvzf zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}
111-
112-
# sign bin package
113-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --armor --output zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.asc --detach-sig zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz
114-
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --print-md MD5 zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz > zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.md5
115-
${SHASUM} zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz > zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.sha512
116-
117-
mv zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz ${WORKING_DIR}/
118-
mv zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.asc ${WORKING_DIR}/
119-
mv zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.md5 ${WORKING_DIR}/
120-
mv zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}.tgz.sha512 ${WORKING_DIR}/
121-
122-
# clean up build dir
123-
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_NAME}-bin-${BIN_RELEASE_NAME}
95+
BIN_RELEASE_NAME="${1}"
96+
BUILD_FLAGS="${2}"
97+
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}
100+
echo "mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}"
101+
mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}
102+
if [[ $? -ne 0 ]]; then
103+
echo "Build failed. ${BUILD_FLAGS}"
104+
exit 1
105+
fi
106+
107+
# re-create package with proper dir name with binary license
108+
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}
114+
115+
# 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}/
124+
125+
# clean up build dir
126+
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
124127
}
125128

126129
make_binary_release all "-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark"
127130

128131
# remove non release files and dirs
129132
rm -rf ${WORKING_DIR}/zeppelin
130-
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_NAME}
133+
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}
131134
echo "Release files are created under ${WORKING_DIR}"

0 commit comments

Comments
 (0)