Skip to content

Commit 8053ae6

Browse files
committed
Merge branch 'fix/deploy'
2 parents 03f6ac4 + bdd34ac commit 8053ae6

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

tools/config.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,29 +175,35 @@ function github_pr_exists(){ # github_pr_exists <repo-path> <branch-name>
175175
if [ ! "$pr_num" == "" ] && [ ! "$pr_num" == "null" ]; then echo 1; else echo 0; fi
176176
}
177177

178-
function github_release_id(){ # github_release_id <repo-path> <release-tag>
178+
function github_release_id() { # github_release_id <repo-path> <release-tag>
179179
local repo_path="$1"
180180
local release_tag="$2"
181181
local page=1
182182
local release_id=""
183183

184184
while [[ "$page" -le 3 ]]; do
185-
local response=`curl -s -k -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases?per_page=100&page=$page"`
186-
187-
if [[ -z "$response" || "$response" == "[]" ]]; then
188-
break
189-
fi
190-
191-
local release=`echo "$response" | jq --arg release_tag "$release_tag" -r '.[] | select(.tag_name == $release_tag) | .id'`
192-
if [ ! "$release" == "" ] && [ ! "$release" == "null" ]; then
193-
release_id=$release
194-
break
185+
local response
186+
response=$(curl -sf -H "Authorization: token $GITHUB_TOKEN" \
187+
-H "Accept: application/vnd.github.v3.raw+json" \
188+
"https://api.github.com/repos/$repo_path/releases?per_page=100&page=$page") || {
189+
echo "Failed to fetch releases from GitHub for $repo_path" >&2
190+
exit 1
191+
}
192+
193+
# stop if empty or no releases
194+
[[ -z "$response" || "$response" == "[]" ]] && break
195+
196+
release_id=$(echo "$response" | jq --arg tag "$release_tag" -r '.[] | select(.tag_name == $tag) | .id')
197+
if [[ -n "$release_id" && "$release_id" != "null" ]]; then
198+
echo "$release_id"
199+
return 0
195200
fi
196201

197202
page=$((page+1))
198203
done
199204

200-
echo "$release_id"
205+
echo "Release '$release_tag' not found in $repo_path" >&2
206+
exit 1
201207
}
202208

203209
function github_release_asset_id(){ # github_release_asset_id <repo-path> <release-id> <release-file>

0 commit comments

Comments
 (0)