github.com/deemoprobe/k8s-first-commit@v0.0.0-20230430165612-a541f1982be3/src/release/release.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2014 Google Inc. 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  
    17  # This script will build and release Kubernetes.
    18  #
    19  # The main parameters to this script come from the config.sh file.  This is set
    20  # up by default for development releases.  Feel free to edit it or override some
    21  # of the variables there.
    22  
    23  # exit on any error
    24  set -e
    25  
    26  source $(dirname $0)/config.sh
    27  
    28  cd $(dirname $0)/../..
    29  
    30  # First build the release tar.  This gets copied on to the master and installed
    31  # from there.  It includes the go source for the necessary servers along with
    32  # the salt configs.
    33  rm -rf release/*
    34  
    35  MASTER_RELEASE_DIR=release/master-release
    36  mkdir -p $MASTER_RELEASE_DIR/bin
    37  mkdir -p $MASTER_RELEASE_DIR/src/scripts
    38  mkdir -p $MASTER_RELEASE_DIR/third_party/go
    39  
    40  echo "Building release tree"
    41  cp src/release/master-release-install.sh $MASTER_RELEASE_DIR/src/scripts/master-release-install.sh
    42  cp -r src/saltbase $MASTER_RELEASE_DIR/src/saltbase
    43  cp -r third_party $MASTER_RELEASE_DIR/third_party/go/src
    44  
    45  function find_go_files() {
    46    find * -not \( \
    47        \( \
    48          -wholename 'third_party' \
    49          -o -wholename 'release' \
    50        \) -prune \
    51      \) -name '*.go'
    52  }
    53  for f in $(find_go_files); do
    54    mkdir -p $MASTER_RELEASE_DIR/src/go/$(dirname ${f})
    55    cp ${f} ${MASTER_RELEASE_DIR}/src/go/${f}
    56  done
    57  
    58  echo "Packaging release"
    59  tar cz -C release -f release/master-release.tgz master-release
    60  
    61  echo "Building launch script"
    62  # Create the local install script.  These are the tools to install the local
    63  # tools and launch a new cluster.
    64  LOCAL_RELEASE_DIR=release/local-release
    65  mkdir -p $LOCAL_RELEASE_DIR/src
    66  
    67  cp -r src/templates $LOCAL_RELEASE_DIR/src/templates
    68  cp -r src/scripts $LOCAL_RELEASE_DIR/src/scripts
    69  
    70  tar cz -C $LOCAL_RELEASE_DIR -f release/launch-kubernetes.tgz .
    71  
    72  echo "#!/bin/bash" >> release/launch-kubernetes.sh
    73  echo "RELEASE_TAG=$RELEASE_TAG" >> release/launch-kubernetes.sh
    74  echo "RELEASE_PREFIX=$RELEASE_PREFIX" >> release/launch-kubernetes.sh
    75  echo "RELEASE_NAME=$RELEASE_NAME" >> release/launch-kubernetes.sh
    76  echo "RELEASE_FULL_PATH=$RELEASE_FULL_PATH" >> release/launch-kubernetes.sh
    77  cat src/release/launch-kubernetes-base.sh >> release/launch-kubernetes.sh
    78  chmod a+x release/launch-kubernetes.sh
    79  
    80  # Now copy everything up to the release structure on GS
    81  echo "Uploading to Google Storage"
    82  if ! gsutil ls $RELEASE_BUCKET > /dev/null; then
    83    echo "Creating $RELEASE_BUCKET"
    84    gsutil mb $RELEASE_BUCKET
    85  fi
    86  for x in master-release.tgz launch-kubernetes.tgz launch-kubernetes.sh; do
    87    gsutil -q cp release/$x $RELEASE_FULL_PATH/$x
    88  
    89    make_public_readable $RELEASE_FULL_PATH/$x
    90  done
    91  set_tag $RELEASE_FULL_TAG_PATH $RELEASE_FULL_PATH
    92  
    93  echo "Release pushed ($RELEASE_PREFIX$RELEASE_NAME).  Launch with:"
    94  echo
    95  echo "  curl -s -L ${RELEASE_FULL_PATH/gs:\/\//http://storage.googleapis.com/}/launch-kubernetes.sh | bash"
    96  echo