|
| 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 AlloyDB auth proxy to their |
| 17 | +# different channels. |
| 18 | + |
| 19 | +set -e # exit immediatly if any step fails |
| 20 | + |
| 21 | +PROJ_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. >/dev/null 2>&1 && pwd )" |
| 22 | +cd $PROJ_ROOT |
| 23 | + |
| 24 | +# get the current version |
| 25 | +export VERSION=$(cat cmd/version.txt) |
| 26 | +if [ -z "$VERSION" ]; then |
| 27 | + echo "error: No version.txt found in $PROJ_ROOT" |
| 28 | + exit 1 |
| 29 | +fi |
| 30 | + |
| 31 | + |
| 32 | +read -p "This will release new AlloyDB auth proxy artifacts for \"$VERSION\", even if they already exist. Are you sure (y/Y)? " -n 1 -r |
| 33 | +echo |
| 34 | +if [[ ! $REPLY =~ ^[Yy]$ ]] |
| 35 | +then |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +# Build and push the container images |
| 40 | +gcloud builds submit --async --config .build/default.yaml --substitutions _VERSION=$VERSION |
| 41 | +gcloud builds submit --async --config .build/buster.yaml --substitutions _VERSION=$VERSION |
| 42 | +gcloud builds submit --async --config .build/alpine.yaml --substitutions _VERSION=$VERSION |
| 43 | + |
| 44 | +# Build the binarys and upload to GCS |
| 45 | +gcloud builds submit --config .build/gcs_upload.yaml --substitutions _VERSION=$VERSION |
| 46 | +# cleam up any artifacts.json left by previous builds |
| 47 | +gsutil rm -f gs://alloydb-auth-proxy/v$VERSION/*.json 2> /dev/null || true |
| 48 | + |
| 49 | +# Generate sha256 hashes for authentication |
| 50 | +echo -e "Add the following table to the release notes on GitHub: \n\n" |
| 51 | +echo "| filename | sha256 hash |" |
| 52 | +echo "|----------|-------------|" |
| 53 | +for f in $(gsutil ls "gs://alloydb-auth-proxy/v$VERSION/alloydb-auth-proxy*"); do |
| 54 | + file=$(basename $f) |
| 55 | + sha=$(gsutil cat $f | sha256sum --binary | head -c 64) |
| 56 | + echo "| [$file](https://storage.googleapis.com/alloydb-auth-proxy/v$VERSION/$file) | $sha |" |
| 57 | +done |
0 commit comments