github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/scripts/dist.sh (about) 1 #!/bin/bash 2 set -e 3 4 # Get the parent directory of where this script is. 5 SOURCE="${BASH_SOURCE[0]}" 6 while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done 7 DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" 8 9 # Change into that dir because we expect that 10 cd $DIR 11 12 # Get the version from the command line 13 VERSION=$1 14 if [ -z $VERSION ]; then 15 echo "Please specify a version." 16 exit 1 17 fi 18 19 # Make sure we have a bintray API key 20 if [ -z $BINTRAY_API_KEY ]; then 21 echo "Please set your bintray API key in the BINTRAY_API_KEY env var." 22 exit 1 23 fi 24 25 # Zip and copy to the dist dir 26 echo "==> Packaging..." 27 rm -rf ./pkg/dist 28 mkdir -p ./pkg/dist 29 for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do 30 OSARCH=$(basename ${PLATFORM}) 31 32 if [ $OSARCH = "dist" ]; then 33 continue 34 fi 35 36 echo "--> ${OSARCH}" 37 pushd $PLATFORM >/dev/null 2>&1 38 zip ../dist/packer_${VERSION}_${OSARCH}.zip ./* 39 popd >/dev/null 2>&1 40 done 41 42 # Make the checksums 43 echo "==> Checksumming..." 44 pushd ./pkg/dist >/dev/null 2>&1 45 shasum -a256 * > ./packer_${VERSION}_SHA256SUMS 46 popd >/dev/null 2>&1 47 48 echo "==> Uploading..." 49 for ARCHIVE in ./pkg/dist/*; do 50 ARCHIVE_NAME=$(basename ${ARCHIVE}) 51 52 echo Uploading: $ARCHIVE_NAME 53 curl \ 54 -T ${ARCHIVE} \ 55 -umitchellh:${BINTRAY_API_KEY} \ 56 "https://api.bintray.com/content/mitchellh/packer/packer/${VERSION}/${ARCHIVE_NAME}" 57 done