github.com/sdbaiguanghe/helm@v2.16.7+incompatible/.circleci/deploy.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright The Helm Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  set -euo pipefail
    17  
    18  # Skip on pull request builds
    19  if [[ -n "${CIRCLE_PR_NUMBER:-}" ]]; then
    20    exit
    21  fi
    22  
    23  : ${GCLOUD_SERVICE_KEY:?"GCLOUD_SERVICE_KEY environment variable is not set"}
    24  : ${PROJECT_NAME:?"PROJECT_NAME environment variable is not set"}
    25  : ${AZURE_STORAGE_CONNECTION_STRING:?"AZURE_STORAGE_CONNECTION_STRING environment variable is not set"}
    26  : ${AZURE_STORAGE_CONTAINER_NAME:?"AZURE_STORAGE_CONTAINER_NAME environment variable is not set"}
    27  
    28  VERSION=
    29  if [[ -n "${CIRCLE_TAG:-}" ]]; then
    30    VERSION="${CIRCLE_TAG}"
    31  else
    32    echo "Skipping deploy step; this is not a tag"
    33    exit
    34  fi
    35  
    36  echo "Install docker client"
    37  VER="17.09.0-ce"
    38  curl -L -o /tmp/docker-$VER.tgz https://download.docker.com/linux/static/stable/x86_64/docker-$VER.tgz
    39  tar -xz -C /tmp -f /tmp/docker-$VER.tgz
    40  mv /tmp/docker/* /usr/bin
    41  
    42  echo "Install gcloud components"
    43  export CLOUDSDK_CORE_DISABLE_PROMPTS=1
    44  curl https://sdk.cloud.google.com | bash
    45  ${HOME}/google-cloud-sdk/bin/gcloud --quiet components update
    46  
    47  echo "Configuring gcloud authentication"
    48  echo "${GCLOUD_SERVICE_KEY}" | base64 --decode > "${HOME}/gcloud-service-key.json"
    49  ${HOME}/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file "${HOME}/gcloud-service-key.json"
    50  ${HOME}/google-cloud-sdk/bin/gcloud config set project "${PROJECT_NAME}"
    51  docker login -u _json_key -p "$(cat ${HOME}/gcloud-service-key.json)" https://gcr.io
    52  
    53  echo "Installing Azure CLI"
    54  apt update
    55  apt install -y apt-transport-https
    56  echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ stretch main" | tee /etc/apt/sources.list.d/azure-cli.list
    57  curl -L https://packages.microsoft.com/keys/microsoft.asc | apt-key add
    58  apt update
    59  apt install -y azure-cli
    60  
    61  echo "Building the tiller image"
    62  make docker-build VERSION="${VERSION}"
    63  
    64  echo "Pushing image to gcr.io"
    65  docker push "gcr.io/kubernetes-helm/tiller:${VERSION}"
    66  
    67  echo "Building helm binaries"
    68  make build-cross
    69  make dist checksum VERSION="${VERSION}"
    70  
    71  echo "Pushing binaries to gs bucket"
    72  ${HOME}/google-cloud-sdk/bin/gsutil cp ./_dist/* "gs://${PROJECT_NAME}"
    73  
    74  echo "Pushing binaries to Azure"
    75  az storage blob upload-batch -s _dist/ -d "$AZURE_STORAGE_CONTAINER_NAME" --pattern 'helm-*' --connection-string "$AZURE_STORAGE_CONNECTION_STRING"
    76  
    77  echo "Pushing KEYS file to Azure"
    78  az storage blob upload -f "KEYS" -n "KEYS" -c "$AZURE_STORAGE_CONTAINER_NAME" --connection-string "$AZURE_STORAGE_CONNECTION_STRING"