github.com/hashicorp/packer@v1.14.3/scripts/dist.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright (c) HashiCorp, Inc.
     3  # SPDX-License-Identifier: BUSL-1.1
     4  
     5  set -e
     6  
     7  # Get the parent directory of where this script is.
     8  SOURCE="${BASH_SOURCE[0]}"
     9  while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
    10  DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
    11  
    12  # Change into that dir because we expect that
    13  cd $DIR
    14  
    15  # Get the version from the command line
    16  VERSION=$1
    17  if [ -z $VERSION ]; then
    18      echo "Please specify version"
    19      exit 1
    20  fi
    21  
    22  # Tag, unless told not to
    23  if [ -z $NOTAG ]; then
    24    echo "==> Tagging..."
    25    git commit --allow-empty -a --gpg-sign=348FFC4C -m "Cut version $VERSION"
    26    git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" $RELBRANCH
    27  fi
    28  
    29  # Zip all the files
    30  rm -rf ./pkg/dist
    31  mkdir -p ./pkg/dist
    32  for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do
    33    OSARCH=$(basename ${PLATFORM})
    34  
    35    if [ $OSARCH = "dist" ]; then
    36      continue
    37    fi
    38  
    39    echo "--> ${OSARCH}"
    40    pushd $PLATFORM >/dev/null 2>&1
    41    zip ../dist/packer_${VERSION}_${OSARCH}.zip ./*
    42    popd >/dev/null 2>&1
    43  done
    44  
    45  ./scripts/sign.sh
    46  if [ $? -ne 0 ]; then
    47    exit 1
    48  fi
    49  
    50  if [ -z $NOSIGN ]; then
    51    echo "==> Signing..."
    52    pushd ./pkg/dist
    53    rm -f ./packer_${VERSION}_SHA256SUMS*
    54    shasum -a256 * > ./packer_${VERSION}_SHA256SUMS
    55    gpg --default-key 348FFC4C --detach-sig ./packer_${VERSION}_SHA256SUMS
    56    popd
    57  fi
    58  
    59  hc-releases upload $DIR/pkg/dist/
    60  hc-releases publish
    61  
    62  exit 0