...
1#! /bin/bash
2# Copyright 2020 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16# This script distributes the artifacts for the Cloud SQL proxy to their different channels.
17
18set -e # exit immediatly if any step fails
19
20PROJ_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )"
21cd $PROJ_ROOT
22
23# get the current version
24export VERSION=$(cat version.txt)
25if [ -z "$VERSION" ]; then
26 echo "error: No version.txt found in $PROJ_ROOT"
27 exit 1
28fi
29
30
31read -p "This will release new Cloud SQL proxy artifacts for \"$VERSION\", even if they already exist. Are you sure (y/Y)? " -n 1 -r
32echo
33if [[ ! $REPLY =~ ^[Yy]$ ]]
34then
35 exit 1
36fi
37
38# Build and push the container images
39gcloud builds submit --async --config .build/default.yaml --substitutions _VERSION=$VERSION
40gcloud builds submit --async --config .build/buster.yaml --substitutions _VERSION=$VERSION
41gcloud builds submit --async --config .build/alpine.yaml --substitutions _VERSION=$VERSION
42
43# Build the binarys and upload to GCS
44gcloud builds submit --config .build/gcs_upload.yaml --substitutions _VERSION=$VERSION
45# cleam up any artifacts.json left by previous builds
46gsutil rm -f gs://cloudsql-proxy/v$VERSION/*.json 2> /dev/null || true
47
48# Generate sha256 hashes for authentication
49echo -e "Add the following table to the release notes on GitHub: \n\n"
50echo "| filename | sha256 hash |"
51echo "|----------|-------------|"
52for f in $(gsutil ls "gs://cloudsql-proxy/v$VERSION/cloud_sql_proxy*"); do
53 file=$(basename $f)
54 sha=$(gsutil cat $f | sha256sum --binary | head -c 64)
55 echo "| [$file](https://storage.googleapis.com/cloudsql-proxy/v$VERSION/$file) | $sha |"
56done
View as plain text