Skip to content

Commit

Permalink
[MINOR][BUILD] Improve release-build script
Browse files Browse the repository at this point in the history
Improved release-build.sh based on the 0.5.0-incubating release process.

Includes:

- Instead of forcing user to set env it prompts for required info, this also protects password inout
- Creates temp dir to hold files created in release process and makes sure git ignores it

Author: Alex Bozarth <[email protected]>

Closes apache#76 from ajbozarth/script.
  • Loading branch information
ajbozarth committed Feb 9, 2018
1 parent f47b742 commit ec8dffd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ reports/
metastore_db/
derby.log
dependency-reduced-pom.xml
release-staging/

# For python setup.py, which pollutes the source dirs.
python-api/dist
Expand Down
60 changes: 42 additions & 18 deletions dev/release-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,36 @@ if [[ $@ == *"help"* ]]; then
exit_with_usage
fi

for env in ASF_USERNAME ASF_PASSWORD GPG_PASSPHRASE RELEASE_RC; do
if [ -z "${!env}" ]; then
echo "ERROR: $env must be set to run this script"
exit_with_usage
fi
done

# Explicitly set locale in order to make `sort` output consistent across machines.
# See https://stackoverflow.com/questions/28881 for more details.
export LC_ALL=C

# Setup env

# Commit ref to checkout when building
GIT_REF=${GIT_REF:-master}
if [ -z "$GIT_REF" ]; then
read -p "Choose git branch/tag [master]: " GIT_REF
GIT_REF=${GIT_REF:-master}
echo $GIT_REF
fi

# Set RELEASE_RC
if [ -z "$RELEASE_RC" ]; then
read -p "Choose RC [rc1]: " RELEASE_RC
RELEASE_RC=${RELEASE_RC:-rc1}
echo $RELEASE_RC
fi

# Get ASF Login
if [ -z "$ASF_USERNAME" ]; then
read -p "ASF username: " ASF_USERNAME
echo $ASF_USERNAME
fi

if [ -z "$ASF_PASSWORD" ]; then
read -s -p "ASF password: " ASF_PASSWORD
echo
fi

# Destination directory on remote server
RELEASE_STAGING_LOCATION="https://dist.apache.org/repos/dist/dev/incubator/livy"
Expand All @@ -74,7 +91,11 @@ BASE_DIR=$(pwd)

MVN="mvn"

rm -rf incubator-livy
# Use temp staging dir for release process
rm -rf release-staging
mkdir release-staging
cd release-staging

git clone https://git-wip-us.apache.org/repos/asf/incubator-livy.git
cd incubator-livy
git checkout $GIT_REF
Expand All @@ -96,11 +117,11 @@ if [[ "$1" == "package" ]]; then
echo "Packaging release tarballs"
cp -r incubator-livy livy-$LIVY_VERSION-src
zip -r livy-$LIVY_VERSION-src.zip livy-$LIVY_VERSION-src
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --armour --output livy-$LIVY_VERSION-src.zip.asc \
echo "" | $GPG --passphrase-fd 0 --armour --output livy-$LIVY_VERSION-src.zip.asc \
--detach-sig livy-$LIVY_VERSION-src.zip
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md MD5 livy-$LIVY_VERSION-src.zip > \
echo "" | $GPG --passphrase-fd 0 --print-md MD5 livy-$LIVY_VERSION-src.zip > \
livy-$LIVY_VERSION-src.zip.md5
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
echo "" | $GPG --passphrase-fd 0 --print-md \
SHA512 livy-$LIVY_VERSION-src.zip > livy-$LIVY_VERSION-src.zip.sha512
rm -rf livy-$LIVY_VERSION-src

Expand All @@ -115,13 +136,13 @@ if [[ "$1" == "package" ]]; then

echo "Copying and signing regular binary distribution"
cp assembly/target/livy-$LIVY_VERSION-bin.zip .
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --armour \
echo "" | $GPG --passphrase-fd 0 --armour \
--output livy-$LIVY_VERSION-bin.zip.asc \
--detach-sig livy-$LIVY_VERSION-bin.zip
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
echo "" | $GPG --passphrase-fd 0 --print-md \
MD5 livy-$LIVY_VERSION-bin.zip > \
livy-$LIVY_VERSION-bin.zip.md5
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --print-md \
echo "" | $GPG --passphrase-fd 0 --print-md \
SHA512 livy-$LIVY_VERSION-bin.zip > \
livy-$LIVY_VERSION-bin.zip.sha512

Expand All @@ -147,7 +168,10 @@ fi

if [[ "$1" == "publish-release" ]]; then
tmp_dir=$(mktemp -d livy-repo-XXXXX)
tmp_repo=`readlink -f "$tmp_dir"`
# the following recreates `readlink -f "$tmp_dir"` since readlink -f is unsupported on MacOS
cd $tmp_dir
tmp_repo=$(pwd)
cd ..

cd incubator-livy
# Publish Livy to Maven release repo
Expand Down Expand Up @@ -176,7 +200,7 @@ if [[ "$1" == "publish-release" ]]; then
echo "Creating hash and signature files"
for file in $(find . -type f)
do
echo $GPG_PASSPHRASE | $GPG --passphrase-fd 0 --output $file.asc \
echo "" | $GPG --passphrase-fd 0 --output $file.asc \
--detach-sig --armour $file;
if [ $(command -v md5) ]; then
# Available on OS X; -q to keep only hash
Expand Down Expand Up @@ -212,5 +236,5 @@ if [[ "$1" == "publish-release" ]]; then
fi

cd ..
rm -rf incubator-livy
rm -rf release-staging
echo "ERROR: expects to be called with 'package', 'publish-release'"

0 comments on commit ec8dffd

Please sign in to comment.