github.com/rohankumardubey/nomad@v0.11.8/scripts/dist.sh (about) 1 #!/usr/bin/env bash 2 set -e 3 4 # Get the version from the command line 5 VERSION=$1 6 if [ -z "${VERSION}" ]; then 7 echo "Please specify a version. (format: 0.4.0-rc1)" 8 exit 1 9 fi 10 11 gpg_signing_key=348FFC4C 12 13 verify_hc_releases() { 14 if ! command -v hc-releases 2>/dev/null >/dev/null 15 then 16 echo "hc-releases binary is not present" >&2 17 exit 1 18 fi 19 } 20 21 verify_gpg_key() { 22 if ! gpg --list-keys "${gpg_signing_key}" >/dev/null 2>/dev/null 23 then 24 echo "gpg key ${gpg_signing_key} is not present" >&2 25 exit 1 26 fi 27 } 28 29 verify_s3_access() { 30 if ! aws s3 ls s3://hc-releases/ >/dev/null 2>/dev/null 31 then 32 echo "AWS credentials is not configured" >&2 33 exit 1 34 fi 35 } 36 37 if [ -z "${NO_PREFLIGHT}" ]; then 38 verify_hc_releases 39 verify_gpg_key 40 verify_s3_access 41 fi 42 43 # Get the parent directory of where this script is. 44 SOURCE="${BASH_SOURCE[0]}" 45 while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done 46 DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" 47 48 # Change into that dir because we expect that 49 cd "${DIR}" 50 51 # Generate the tag. 52 if [ -z "${NOTAG}" ]; then 53 echo "==> Tagging..." 54 git commit --allow-empty -a --gpg-sign=${gpg_signing_key} -m "Release v$VERSION" 55 git tag -a -m "Version $VERSION" -s -u ${gpg_signing_key} "v${VERSION}" HEAD 56 fi 57 58 # Zip all the files 59 rm -rf ./pkg/dist 60 mkdir -p ./pkg/dist 61 62 #find ./pkg -mindepth 1 -maxdepth 1 -type f -exec cp ./pkg/{} ./pkg/dist/nomad_"${VERSION}"_{} \; 63 #for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do 64 find ./pkg -mindepth 1 -maxdepth 1 -type f -print0 | while read -d '' -r FILENAME; do 65 FILENAME=$(basename "$FILENAME") 66 cp "./pkg/${FILENAME}" "./pkg/dist/nomad_${VERSION}_${FILENAME}" 67 done 68 69 # Make the checksums 70 pushd ./pkg/dist 71 shasum -a256 ./* > "./nomad_${VERSION}_SHA256SUMS" 72 if [ -z "${NOSIGN}" ]; then 73 echo "==> Signing..." 74 gpg --default-key 348FFC4C --detach-sig "./nomad_${VERSION}_SHA256SUMS" 75 fi 76 popd 77 78 # Upload 79 if [ -z "${HC_RELEASE}" ]; then 80 hc-releases upload "${DIR}/pkg/dist" && hc-releases publish 81 fi