Skip to content

Commit 431a647

Browse files
mozesl-nokiaCopilot
andcommitted
Apply suggestions from code review
Signed-off-by: mozesl-nokia <laszlo.mozes@nokia.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 02eb3a5 commit 431a647

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

scripts/manual-patch-release.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ for fn in "${functions[@]}"; do
111111
git tag -l "functions/go/${fn}/v*" |
112112
grep -E -- '/v[0-9]+\.[0-9]+\.[0-9]+$' |
113113
sort -V |
114-
tail -n 1
114+
tail -n 1 || true
115115
)"
116116

117117
if [[ -z "${prev_long}" ]]; then
@@ -136,13 +136,20 @@ for fn in "${functions[@]}"; do
136136
continue
137137
fi
138138

139-
# Multi-arch push (see go-function-release.sh / docker.sh).
140-
(cd functions/go && make func-push TAG="${next_ver}" CURRENT_FUNCTION="${fn}" DEFAULT_CR="ghcr.io/${repo}")
139+
# Fail fast before pushing images, to avoid overwriting an existing release.
140+
short_tag="${fn}/${next_ver}"
141141

142142
if git rev-parse "$long_tag" >/dev/null 2>&1; then
143143
echo "::error::Tag ${long_tag} already exists locally" >&2
144144
exit 1
145145
fi
146+
if git rev-parse "$short_tag" >/dev/null 2>&1; then
147+
echo "::error::Tag ${short_tag} already exists locally" >&2
148+
exit 1
149+
fi
150+
151+
# Multi-arch push (see go-function-release.sh / docker.sh).
152+
(cd functions/go && make func-push TAG="${next_ver}" CURRENT_FUNCTION="${fn}" DEFAULT_CR="ghcr.io/${repo}")
146153

147154
# Long tag (full path) then short tag (<fn>/v…) to match release.yaml behavior.
148155
git tag "$long_tag" "$sha"
@@ -151,8 +158,8 @@ for fn in "${functions[@]}"; do
151158
git fetch origin "refs/tags/${long_tag}"
152159
oid="$(git rev-parse FETCH_HEAD^{})"
153160
short_tag="${fn}/${next_ver}"
154-
git tag -f "$short_tag" "$oid"
155-
git push -f origin "refs/tags/${short_tag}"
161+
git tag "$short_tag" "$oid"
162+
git push origin "refs/tags/${short_tag}"
156163

157164
# Same registry path as make func-push (DEFAULT_CR + function name).
158165
image_ref="ghcr.io/${repo}/${fn}:${next_ver}"

0 commit comments

Comments
 (0)