fix(tools): use codeload directly for tags with special chars (@/)
Skip failed github.com attempt entirely for scoped tags like @papra/docker@26.0.0
This commit is contained in:
parent
fe9c5d2285
commit
fc8433ad8b
@ -1768,26 +1768,30 @@ function fetch_and_deploy_gh_release() {
|
||||
|
||||
### Tarball Mode ###
|
||||
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
|
||||
# GitHub API's tarball_url/zipball_url can return HTTP 300 Multiple Choices
|
||||
# when a branch and tag share the same name. Use explicit refs/tags/ URL instead.
|
||||
# URL-encode special characters in tag names (@ and /)
|
||||
local encoded_tag_name="${tag_name//@/%40}"
|
||||
encoded_tag_name="${encoded_tag_name//\//%2F}"
|
||||
local direct_tarball_url="https://github.com/$repo/archive/refs/tags/$encoded_tag_name.tar.gz"
|
||||
filename="${app_lc}-${version}.tar.gz"
|
||||
local download_success=false
|
||||
|
||||
# Try primary URL first, fallback to codeload.github.com for complex tag names
|
||||
if ! curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" 2>/dev/null; then
|
||||
# Remove partial/corrupt file from failed attempt before retry
|
||||
rm -f "$tmpdir/$filename"
|
||||
# Fallback: codeload.github.com - only encode @ not / in tag names
|
||||
# For tags with special characters (@, /), use codeload.github.com directly
|
||||
# as github.com/archive/refs/tags/ doesn't handle them well
|
||||
if [[ "$tag_name" =~ [@/] ]]; then
|
||||
# codeload.github.com - only encode @ not / in tag names
|
||||
local codeload_encoded="${tag_name//@/%40}"
|
||||
local codeload_url="https://codeload.github.com/$repo/tar.gz/refs/tags/$codeload_encoded"
|
||||
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$codeload_url" || {
|
||||
msg_error "Download failed: $direct_tarball_url (and fallback $codeload_url)"
|
||||
rm -rf "$tmpdir"
|
||||
return 1
|
||||
}
|
||||
if curl $download_timeout -fsSL -o "$tmpdir/$filename" "$codeload_url"; then
|
||||
download_success=true
|
||||
fi
|
||||
else
|
||||
# Standard tags: use github.com/archive/refs/tags/
|
||||
local direct_tarball_url="https://github.com/$repo/archive/refs/tags/${tag_name}.tar.gz"
|
||||
if curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url"; then
|
||||
download_success=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$download_success" != "true" ]]; then
|
||||
msg_error "Download failed for $app ($tag_name)"
|
||||
rm -rf "$tmpdir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$target"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user