github.com/flant/helm@v2.8.1+incompatible/.circleci/deploy.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2016 The Kubernetes Authors All rights reserved.
     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  
    26  VERSION=
    27  if [[ -n "${CIRCLE_TAG:-}" ]]; then
    28    VERSION="${CIRCLE_TAG}"
    29  elif [[ "${CIRCLE_BRANCH:-}" == "master" ]]; then
    30    VERSION="canary"
    31  else
    32    echo "Skipping deploy step; this is neither master or a tag"
    33    exit
    34  fi
    35  
    36  echo "Install docker client"
    37  VER="17.03.0-ce"
    38  curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/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 -e 1234@5678.com -u _json_key -p "$(cat ${HOME}/gcloud-service-key.json)" https://gcr.io
    52  
    53  echo "Building the tiller image"
    54  make docker-build VERSION="${VERSION}"
    55  
    56  echo "Pushing image to gcr.io"
    57  docker push "gcr.io/kubernetes-helm/tiller:${VERSION}"
    58  
    59  echo "Building helm binaries"
    60  make build-cross
    61  make dist checksum VERSION="${VERSION}"
    62  
    63  echo "Pushing binaries to gs bucket"
    64  ${HOME}/google-cloud-sdk/bin/gsutil cp ./_dist/* "gs://${PROJECT_NAME}"