open-consul/scripts/dist.sh

75 lines
1.6 KiB
Bash
Raw Normal View History

2013-12-19 19:22:08 +00:00
#!/bin/bash
set -e
2014-04-16 23:53:26 +00:00
# Get the version from the command line
VERSION=$1
if [ -z $VERSION ]; then
echo "Please specify a version."
exit 1
fi
# Make sure we have a bintray API key
if [ -z $BINTRAY_API_KEY ]; then
echo "Please set your bintray API key in the BINTRAY_API_KEY env var."
exit 1
fi
2013-12-19 19:22:08 +00:00
# Get the parent directory of where this script is.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
# Change into that dir because we expect that
cd $DIR
2014-04-16 23:53:26 +00:00
# Zip all the files
rm -rf ./dist/pkg
mkdir -p ./dist/pkg
for FILENAME in $(find ./dist -mindepth 1 -maxdepth 1 -type f); do
FILENAME=$(basename $FILENAME)
EXTENSION="${FILENAME##*.}"
2014-04-16 23:53:26 +00:00
PLATFORM="${FILENAME%.*}"
if [ "${EXTENSION}" != "exe" ]; then
EXTENSION=""
else
EXTENSION=".${EXTENSION}"
fi
CONSULNAME="consul${EXTENSION}"
pushd ./dist
2014-05-01 18:01:54 +00:00
if [ "${FILENAME}" = "ui.zip" ]; then
cp ${FILENAME} ./pkg/${VERSION}_web_ui.zip
else
2014-05-20 19:48:17 +00:00
if [ "${EXTENSION}" = "" ]; then
chmod +x ${FILENAME}
fi
2014-05-01 18:01:54 +00:00
cp ${FILENAME} ${CONSULNAME}
zip ./pkg/${VERSION}_${PLATFORM}.zip ${CONSULNAME}
rm ${CONSULNAME}
fi
popd
2013-12-19 19:22:08 +00:00
done
# Make the checksums
2014-04-16 23:53:26 +00:00
pushd ./dist/pkg
shasum -a256 * > ./${VERSION}_SHA256SUMS
2013-12-19 19:22:08 +00:00
popd
2014-04-16 23:53:26 +00:00
# Upload
for ARCHIVE in ./dist/pkg/*; do
ARCHIVE_NAME=$(basename ${ARCHIVE})
echo Uploading: $ARCHIVE_NAME
curl \
-T ${ARCHIVE} \
-umitchellh:${BINTRAY_API_KEY} \
"https://api.bintray.com/content/mitchellh/consul/consul/${VERSION}/${ARCHIVE_NAME}"
done
2013-12-19 19:22:08 +00:00
exit 0