|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright The containerd 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 | + |
| 17 | +set -o errexit |
| 18 | +set -o nounset |
| 19 | +set -o pipefail |
| 20 | + |
| 21 | +source $(dirname "${BASH_SOURCE[0]}")/utils.sh |
| 22 | + |
| 23 | +# DEPLOY_BUCKET is the gcs bucket where the tarball should be stored in. |
| 24 | +DEPLOY_BUCKET=${DEPLOY_BUCKET:-"cri-containerd-staging"} |
| 25 | +# DEPLOY_DIR is the directory in the gcs bucket to store the tarball. |
| 26 | +DEPLOY_DIR=${DEPLOY_DIR:-""} |
| 27 | +# BUILD_DIR is the directory of the bulid out. |
| 28 | +BUILD_DIR=${BUILD_DIR:-"_output"} |
| 29 | +# TARBALL is the tarball name. |
| 30 | +TARBALL=${TARBALL:-"cri-containerd.tar.gz"} |
| 31 | +# LATEST is the name of the latest version file. |
| 32 | +LATEST=${LATEST:-"latest"} |
| 33 | +# PUSH_VERSION indicates whether to push version. |
| 34 | +PUSH_VERSION=${PUSH_VERSION:-false} |
| 35 | + |
| 36 | +release_tar=${BUILD_DIR}/${TARBALL} |
| 37 | +release_tar_checksum=${release_tar}.sha256 |
| 38 | +if [[ ! -e ${release_tar} || ! -e ${release_tar_checksum} ]]; then |
| 39 | + echo "Release tarball is not built" |
| 40 | + exit 1 |
| 41 | +fi |
| 42 | + |
| 43 | +if ! gsutil ls "gs://${DEPLOY_BUCKET}" > /dev/null; then |
| 44 | + create_ttl_bucket ${DEPLOY_BUCKET} |
| 45 | +fi |
| 46 | + |
| 47 | +if [ -z "${DEPLOY_DIR}" ]; then |
| 48 | + DEPLOY_PATH="${DEPLOY_BUCKET}" |
| 49 | +else |
| 50 | + DEPLOY_PATH="${DEPLOY_BUCKET}/${DEPLOY_DIR}" |
| 51 | +fi |
| 52 | + |
| 53 | +gsutil cp ${release_tar} "gs://${DEPLOY_PATH}/" |
| 54 | +gsutil cp ${release_tar_checksum} "gs://${DEPLOY_PATH}/" |
| 55 | +echo "Release tarball is uploaded to: |
| 56 | + https://storage.googleapis.com/${DEPLOY_PATH}/${TARBALL}" |
| 57 | + |
| 58 | +if ${PUSH_VERSION}; then |
| 59 | + if [[ -z "${VERSION}" ]]; then |
| 60 | + echo "VERSION is not set" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | + echo ${VERSION} | gsutil cp - "gs://${DEPLOY_PATH}/${LATEST}" |
| 64 | + echo "Latest version is uploaded to: |
| 65 | + https://storage.googleapis.com/${DEPLOY_PATH}/${LATEST}" |
| 66 | +fi |
0 commit comments