Skip to content

Commit 92ca1a3

Browse files
committed
tag detection and gcs upload
1 parent bf7c3e1 commit 92ca1a3

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

tools/publish_release.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
if [[ $# -eq 2 ]]; then
24+
RELEASE_NAME="$1"
25+
RELEASE_TAG="$2"
26+
27+
elif [[ $# -eq 0 ]]; then
28+
echo "Fetching latest tags from origin..."
29+
30+
if ! git fetch origin --tags; then
31+
echo "ERROR: Failed to fetch tags from remote repository." >&2
32+
exit 1
33+
fi
34+
35+
RELEASE_TAG="$(git tag --sort=-v:refname | head -n 1)"
36+
RELEASE_NAME="${RELEASE_TAG}"
37+
38+
else
39+
echo "ERROR: Invalid number of arguments." >&2
40+
echo "Usage: $0 [<release_name> <release_tag>]" >&2
41+
exit 1
42+
fi
43+
44+
if [[ -z "${RELEASE_TAG}" || -z "${RELEASE_NAME}" ]]; then
45+
echo "ERROR: Release tag and name cannot be empty." >&2
46+
exit 1
47+
fi
48+
49+
echo "Latest cluster-toolkit version detected:"
50+
echo "Release Name : ${RELEASE_NAME}"
51+
echo "Release Tag : ${RELEASE_TAG}"
52+
53+
TMP_FILE="$(mktemp)"
54+
trap 'rm -f "${TMP_FILE}"' EXIT
55+
56+
cat >"${TMP_FILE}" <<EOF
57+
{
58+
"publish_all": true,
59+
"registry_config": {
60+
"github_releases": {
61+
"name": "${RELEASE_NAME}",
62+
"tag": "${RELEASE_TAG}"
63+
}
64+
}
65+
}
66+
EOF
67+
68+
echo "Uploading release manifest to GCS..."
69+
70+
if ! gcloud storage cp "${TMP_FILE}" "${BUCKET_PATH}"; then
71+
echo "ERROR: Failed to upload release manifest to bucket."
72+
exit 1
73+
fi
74+
75+
echo "Release publish process finished successfully."

0 commit comments

Comments
 (0)