github.phpd.cn/thought-machine/please@v12.2.0+incompatible/tools/misc/upload_release.sh (about)

     1  #!/bin/bash
     2  # Script to automatically upload new Please versions.
     3  # Will not overwrite existing versions, only adds new ones.
     4  # Should be run from the root of the repo, and only by a CI system.
     5  
     6  set -euo pipefail
     7  RED="\x1B[31m"
     8  GREEN="\x1B[32m"
     9  YELLOW="\x1B[33m"
    10  RESET="\x1B[0m"
    11  
    12  BUCKET="s3://get.please.build"
    13  
    14  VERSION="$(cat VERSION)"
    15  eval $(go env)
    16  echo -e "${GREEN}Identifying outputs...${RESET}"
    17  TARGETS="//package:please_tarball //package:servers_tarball"
    18  
    19  
    20  if [ "$GOOS" == "linux" ]; then
    21      # For Linux we upload debs as well.
    22      TARGETS="$TARGETS //package:please //package:plz_rpc_cache_server //package:plz_http_cache_server"
    23  fi
    24  
    25  FILES="$(plz-out/bin/src/please query outputs $TARGETS ${TARGETS// /_signed }_signed)"
    26  UPLOADED=''
    27  for FILE in $FILES; do
    28      BN="$(basename $FILE)"
    29      DEST="${BUCKET}/${GOOS}_${GOARCH}/${VERSION}/${BN}"
    30      echo -e "${GREEN}Checking ${DEST}...${RESET}"
    31      if aws s3 ls $DEST > /dev/null ; then
    32          echo -e "${YELLOW}${DEST} already exists, will not update${RESET}"
    33      else
    34          echo -e "${GREEN}Uploading ${FILE} to ${DEST}...${RESET}"
    35          aws s3 cp $FILE $DEST
    36          UPLOADED=true
    37      fi
    38  done
    39  
    40  if [[ "$VERSION" =~ .*(alpha|beta|pre|rc).* ]]; then
    41      echo -e "${YELLOW}Pre-release version found, will not update latest_version.${RESET}"
    42  elif [ "$UPLOADED" = true ]; then
    43      echo -e "${GREEN}Uploaded at least one file, updating latest_version...${RESET}"
    44      aws s3 cp "VERSION" "${BUCKET}/latest_version"
    45  else
    46      echo -e "${YELLOW}Didn't upload anything, will not update latest_version${RESET}"
    47  fi