diff --git a/tools/publish_release.sh b/tools/publish_release.sh new file mode 100644 index 0000000000..c58646dd18 --- /dev/null +++ b/tools/publish_release.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# Copyright 2026 "Google LLC" +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# bash tools/publish_release.sh +# bash tools/publish_release.sh + +set -euo pipefail + +BUCKET_PATH="gs://oss-exit-gate-prod-projects-bucket/cluster-toolkit/githubreleases/manifests/rel.json" + +if [[ $# -eq 2 ]]; then + RELEASE_NAME="$1" + RELEASE_TAG="$2" + +elif [[ $# -eq 0 ]]; then + echo "Fetching latest tags from origin..." + + if ! git fetch origin --tags; then + echo "ERROR: Failed to fetch tags from remote repository." >&2 + exit 1 + fi + + RELEASE_TAG="$(git tag --sort=-v:refname | head -n 1)" + RELEASE_NAME="${RELEASE_TAG}" + +else + echo "ERROR: Invalid number of arguments." >&2 + echo "Usage: $0 [ ]" >&2 + exit 1 +fi + +if [[ -z "${RELEASE_TAG}" || -z "${RELEASE_NAME}" ]]; then + echo "ERROR: Release tag and name cannot be empty." >&2 + exit 1 +fi + +echo "Latest cluster-toolkit version detected:" +echo "Release Name : ${RELEASE_NAME}" +echo "Release Tag : ${RELEASE_TAG}" + +TMP_FILE="$(mktemp)" +trap 'rm -f "${TMP_FILE}"' EXIT + +cat >"${TMP_FILE}" <