github.com/ddnomad/packer@v1.3.2/scripts/dist.sh (about)

     1  #!/usr/bin/env 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 version"
    16      exit 1
    17  fi
    18  
    19  # Tag, unless told not to
    20  if [ -z $NOTAG ]; then
    21    echo "==> Tagging..."
    22    git commit --allow-empty -a --gpg-sign=348FFC4C -m "Cut version $VERSION"
    23    git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" $RELBRANCH
    24  fi
    25  
    26  # Zip all the files
    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  if [ -z $NOSIGN ]; then
    43    echo "==> Signing..."
    44    pushd ./pkg/dist
    45    rm -f ./packer_${VERSION}_SHA256SUMS*
    46    shasum -a256 * > ./packer_${VERSION}_SHA256SUMS
    47    gpg --default-key 348FFC4C --detach-sig ./packer_${VERSION}_SHA256SUMS
    48    popd
    49  fi
    50  
    51  hc-releases upload $DIR/pkg/dist/
    52  hc-releases publish
    53  
    54  exit 0