Move duplicate code to common_release.sh

This commit is contained in:
Mina Lee 2016-06-16 18:17:37 -07:00
parent a3eb67673c
commit 903bc12511
3 changed files with 126 additions and 122 deletions

61
dev/common_release.sh Normal file
View file

@ -0,0 +1,61 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# common fucntions
if [[ -z "${TAR}" ]]; then
TAR="/usr/bin/tar"
fi
if [[ -z "${SHASUM}" ]]; then
SHASUM="/usr/bin/shasum"
fi
if [[ -z "${WORKING_DIR}" ]]; then
WORKING_DIR="/tmp/zeppelin-release"
fi
mkdir "${WORKING_DIR}"
usage() {
echo "usage) $0 [Release version] [Branch or Tag]"
echo " ex. $0 0.6.0 v0.6.0"
exit 1
}
function git_clone() {
echo "Clone the source"
# clone source
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git "${WORKING_DIR}/zeppelin"
if [[ $? -ne 0 ]]; then
echo "Can not clone source repository"
exit 1
fi
cd "${WORKING_DIR}/zeppelin"
git checkout "${GIT_TAG}"
echo "Checked out ${GIT_TAG}"
# remove unnecessary files
rm "${WORKING_DIR}/zeppelin/.gitignore"
rm -rf "${WORKING_DIR}/zeppelin/.git"
rm -rf "${WORKING_DIR}/zeppelin/.github"
rm -rf "${WORKING_DIR}/zeppelin/docs"
}

View file

@ -18,25 +18,19 @@
#
# The script helps making a release.
# You need specify a release name and branch|tag name.
# You need to specify release version and branch|tag name.
#
# Here's some helpful documents for the release
# Here are some helpful documents for the release.
# http://www.apache.org/dev/release.html
# http://www.apache.org/dev/release-publishing
# http://www.apache.org/dev/release-signing.html
# http://www.apache.org/dev/publishing-maven-artifacts.html
if [[ -z "${TAR}" ]]; then
TAR=/usr/bin/tar
fi
BASEDIR="$(dirname "$0")"
. "${BASEDIR}/common_release.sh"
echo "${BASEDIR}/common_release.sh"
if [[ -z "${SHASUM}" ]]; then
SHASUM="/usr/bin/shasum -a 512"
fi
if [[ -z "${WORKING_DIR}" ]]; then
WORKING_DIR=/tmp/zeppelin-release
if [[ $# -ne 2 ]]; then
usage
fi
if [[ -z "${GPG_PASSPHRASE}" ]]; then
@ -44,59 +38,34 @@ if [[ -z "${GPG_PASSPHRASE}" ]]; then
exit 1
fi
RELEASE_VERSION="$1"
GIT_TAG="$2"
if [[ $# -ne 2 ]]; then
echo "usage) $0 [Release version] [Tag]"
echo " ex. $0 0.6.0 v0.6.0-rc1"
exit 1
fi
RELEASE_VERSION="${1}"
GIT_TAG="${2}"
if [[ -d "${WORKING_DIR}" ]]; then
echo "Dir ${WORKING_DIR} already exists"
exit 1
fi
mkdir ${WORKING_DIR}
echo "Cloning the source and packaging"
# clone source
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git ${WORKING_DIR}/zeppelin
if [[ $? -ne 0 ]]; then
echo "Can not clone source repository"
exit 1
fi
cd ${WORKING_DIR}/zeppelin
git checkout ${GIT_TAG}
echo "Checked out ${GIT_TAG}"
# remove unnecessary files
rm ${WORKING_DIR}/zeppelin/.gitignore
rm -rf ${WORKING_DIR}/zeppelin/.git
# create source package
cd ${WORKING_DIR}
cp -r zeppelin zeppelin-${RELEASE_VERSION}
${TAR} cvzf zeppelin-${RELEASE_VERSION}.tgz zeppelin-${RELEASE_VERSION}
echo "Signing the source package"
cd ${WORKING_DIR}
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --armor --output zeppelin-${RELEASE_VERSION}.tgz.asc --detach-sig ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz
echo $GPG_PASSPHRASE | gpg --passphrase-fd 0 --print-md MD5 zeppelin-${RELEASE_VERSION}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.md5
${SHASUM} zeppelin-${RELEASE_VERSION}.tgz > ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.sha512
function make_source_package() {
# create source package
cd ${WORKING_DIR}
cp -r "zeppelin" "zeppelin-${RELEASE_VERSION}"
${TAR} cvzf "zeppelin-${RELEASE_VERSION}.tgz" "zeppelin-${RELEASE_VERSION}"
echo "Signing the source package"
cd "${WORKING_DIR}"
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --armor \
--output "zeppelin-${RELEASE_VERSION}.tgz.asc" \
--detach-sig "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz"
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 \
--print-md MD5 "zeppelin-${RELEASE_VERSION}.tgz" > \
"${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.md5"
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 \
--print-md SHA512 "zeppelin-${RELEASE_VERSION}.tgz" > \
"${WORKING_DIR}/zeppelin-${RELEASE_VERSION}.tgz.sha512"
}
function make_binary_release() {
BIN_RELEASE_NAME="${1}"
BUILD_FLAGS="${2}"
BIN_RELEASE_NAME="$1"
BUILD_FLAGS="$2"
cp -r ${WORKING_DIR}/zeppelin ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
cd ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
cp -r "${WORKING_DIR}/zeppelin" "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
cd "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
echo "mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}"
mvn clean package -Pbuild-distr -DskipTests ${BUILD_FLAGS}
if [[ $? -ne 0 ]]; then
@ -106,29 +75,36 @@ function make_binary_release() {
# re-create package with proper dir name with binary license
cd zeppelin-distribution/target/zeppelin-*
mv zeppelin-* zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
cat ../../src/bin_license/LICENSE >> zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/LICENSE
cat ../../src/bin_license/NOTICE >> zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/NOTICE
cp ../../src/bin_license/licenses/* zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/licenses/
${TAR} cvzf zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
mv zeppelin-* "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
cat ../../src/bin_license/LICENSE >> "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/LICENSE"
cat ../../src/bin_license/NOTICE >> "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/NOTICE"
cp ../../src/bin_license/licenses/* "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}/licenses/"
${TAR} cvzf "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
# sign bin package
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
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
${SHASUM} zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz > zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512
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"
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"
${SHASUM} -a 512 "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" > \
"zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512"
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz ${WORKING_DIR}/
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc ${WORKING_DIR}/
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5 ${WORKING_DIR}/
mv zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512 ${WORKING_DIR}/
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz" "${WORKING_DIR}/"
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.asc" "${WORKING_DIR}/"
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.md5" "${WORKING_DIR}/"
mv "zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}.tgz.sha512" "${WORKING_DIR}/"
# clean up build dir
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}
rm -rf "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}-bin-${BIN_RELEASE_NAME}"
}
git_clone
make_source_package
make_binary_release all "-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark"
# remove non release files and dirs
rm -rf ${WORKING_DIR}/zeppelin
rm -rf ${WORKING_DIR}/zeppelin-${RELEASE_VERSION}
rm -rf "${WORKING_DIR}/zeppelin"
rm -rf "${WORKING_DIR}/zeppelin-${RELEASE_VERSION}"
echo "Release files are created under ${WORKING_DIR}"

View file

@ -17,30 +17,20 @@
# limitations under the License.
#
# The script helps publishing release to mavene.
# You need to specify release version and tag name.
# The script helps publishing release to maven.
# You need to specify release version and branch|tag name.
#
# Here are some helpful documents for the release.
# http://www.apache.org/dev/release.html
# http://www.apache.org/dev/release-publishing
# http://www.apache.org/dev/release-signing.html
# Here's some helpful documents for the release.
# http://www.apache.org/dev/publishing-maven-artifacts.html
if [[ -z "${SHASUM}" ]]; then
SHASUM="/usr/bin/shasum -a 1"
BASEDIR="$(dirname "$0")"
. "${BASEDIR}/common_release.sh"
if [[ $# -ne 2 ]]; then
usage
fi
if [[ -z "${WORKING_DIR}" ]]; then
WORKING_DIR="/tmp/zeppelin-release"
fi
if [ $# -ne 2 ]; then
echo "usage) $0 [Release version] [Tag]"
echo " ex. $0 0.6.0 v0.6.0"
exit 1
fi
for var in GPG_PASSPHRASE; do ASF_USERID ASF_PASSWORD; do
for var in GPG_PASSPHRASE ASF_USERID ASF_PASSWORD; do
if [[ -z "${!var}" ]]; then
echo "You need ${var} variable set"
exit 1
@ -52,35 +42,11 @@ export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m"
RELEASE_VERSION="$1"
GIT_TAG="$2"
PUBLISH_PROFILES="-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark -Psparkr -Pr"
PUBLISH_PROFILES="-Pspark-1.6 -Phadoop-2.4 -Pyarn -Ppyspark"
PROJECT_OPTIONS="-pl !zeppelin-distribution"
NEXUS_STAGING="https://repository.apache.org/service/local/staging"
NEXUS_PROFILE="153446d1ac37c4"
if [[ -d "${WORKING_DIR}" ]]; then
echo "Dir ${WORKING_DIR} already exists"
exit 1
fi
mkdir "${WORKING_DIR}"
echo "Cloning the source"
# clone source
git clone https://git-wip-us.apache.org/repos/asf/zeppelin.git "${WORKING_DIR}/zeppelin"
if [[ $? -ne 0 ]]; then
echo "Can not clone source repository"
exit 1
fi
cd "${WORKING_DIR}/zeppelin"
git checkout "${GIT_TAG}"
echo "Checked out ${GIT_TAG}"
# remove unnecessary files
rm "${WORKING_DIR}/zeppelin/.gitignore"
rm -rf "${WORKING_DIR}/zeppelin/.git"
function publish_to_maven() {
cd "${WORKING_DIR}/zeppelin"
@ -117,7 +83,7 @@ function publish_to_maven() {
echo "${GPG_PASSPHRASE}" | gpg --passphrase-fd 0 --output "${file}.asc" \
--detach-sig --armor "${file}"
md5 -q "${file}" > "${file}.md5"
${SHASUM} "${file}" | cut -f1 -d' ' > "${file}.sha1"
${SHASUM} -a 1 "${file}" | cut -f1 -d' ' > "${file}.sha1"
done
nexus_upload="${NEXUS_STAGING}/deployByRepositoryId/${staged_repo_id}"
@ -140,7 +106,8 @@ function publish_to_maven() {
rm -rf "${tmp_repo}"
}
git_clone
publish_to_maven
# remove working directory
rm -rf "${WORKING_DIR}"
rm -rf "${WORKING_DIR}/zeppelin"