Skip to content

Commit dd5993d

Browse files
authored
fix(tools.func): handle GitHub 300 Multiple Choices in tarball mode (#9697)
1 parent 0c2521c commit dd5993d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

misc/tools.func

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,12 +1735,13 @@ function fetch_and_deploy_gh_release() {
17351735

17361736
### Tarball Mode ###
17371737
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
1738-
url=$(echo "$json" | jq -r '.tarball_url // empty')
1739-
[[ -z "$url" ]] && url="https://github.com/$repo/archive/refs/tags/v$version.tar.gz"
1738+
# GitHub API's tarball_url/zipball_url can return HTTP 300 Multiple Choices
1739+
# when a branch and tag share the same name. Use explicit refs/tags/ URL instead.
1740+
local direct_tarball_url="https://github.com/$repo/archive/refs/tags/$tag_name.tar.gz"
17401741
filename="${app_lc}-${version}.tar.gz"
17411742

1742-
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url" || {
1743-
msg_error "Download failed: $url"
1743+
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" || {
1744+
msg_error "Download failed: $direct_tarball_url"
17441745
rm -rf "$tmpdir"
17451746
return 1
17461747
}

0 commit comments

Comments
 (0)