|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2026 "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 | +# bash tools/publish_release.sh <release_name> <release_tag> |
| 17 | +# bash tools/publish_release.sh |
| 18 | + |
| 19 | +set -euo pipefail |
| 20 | + |
| 21 | +BUCKET_PATH="gs://oss-exit-gate-prod-projects-bucket/cluster-toolkit/githubreleases/manifests/rel.json" |
| 22 | + |
| 23 | +echo "Fetching latest tags from origin..." |
| 24 | + |
| 25 | +if ! git fetch origin --tags; then |
| 26 | + echo "ERROR: Failed to fetch tags from remote repository." |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +RELEASE_TAG="$(git tag --sort=-v:refname | head -n 1)" |
| 31 | + |
| 32 | +if [[ -z "${RELEASE_TAG}" ]]; then |
| 33 | + echo "ERROR: No tags found in repository." |
| 34 | + exit 1 |
| 35 | +fi |
| 36 | + |
| 37 | +RELEASE_NAME="${RELEASE_TAG}" |
| 38 | + |
| 39 | +echo "Latest cluster-toolkit version detected:" |
| 40 | +echo "Release Name : ${RELEASE_NAME}" |
| 41 | +echo "Release Tag : ${RELEASE_TAG}" |
| 42 | + |
| 43 | +TMP_FILE="$(mktemp)" |
| 44 | +trap 'rm -f "${TMP_FILE}"' EXIT |
| 45 | + |
| 46 | +cat >"${TMP_FILE}" <<EOF |
| 47 | +{ |
| 48 | + "publish_all": true, |
| 49 | + "registry_config": { |
| 50 | + "github_releases": { |
| 51 | + "name": "${RELEASE_NAME}", |
| 52 | + "tag": "${RELEASE_TAG}" |
| 53 | + } |
| 54 | + } |
| 55 | +} |
| 56 | +EOF |
| 57 | + |
| 58 | +echo "Uploading release manifest to GCS..." |
| 59 | + |
| 60 | +if ! gcloud storage cp "${TMP_FILE}" "${BUCKET_PATH}"; then |
| 61 | + echo "ERROR: Failed to upload release manifest to bucket." |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | + |
| 65 | +echo "Release publish process finished successfully." |
0 commit comments