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 ###
|
### Tarball Mode ###
|
||||||
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
|
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"
|
filename="${app_lc}-${version}.tar.gz"
|
||||||
|
local download_success=false
|
||||||
|
|
||||||
# Try primary URL first, fallback to codeload.github.com for complex tag names
|
# For tags with special characters (@, /), use codeload.github.com directly
|
||||||
if ! curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" 2>/dev/null; then
|
# as github.com/archive/refs/tags/ doesn't handle them well
|
||||||
# Remove partial/corrupt file from failed attempt before retry
|
if [[ "$tag_name" =~ [@/] ]]; then
|
||||||
rm -f "$tmpdir/$filename"
|
# codeload.github.com - only encode @ not / in tag names
|
||||||
# Fallback: codeload.github.com - only encode @ not / in tag names
|
|
||||||
local codeload_encoded="${tag_name//@/%40}"
|
local codeload_encoded="${tag_name//@/%40}"
|
||||||
local codeload_url="https://codeload.github.com/$repo/tar.gz/refs/tags/$codeload_encoded"
|
local codeload_url="https://codeload.github.com/$repo/tar.gz/refs/tags/$codeload_encoded"
|
||||||
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$codeload_url" || {
|
if curl $download_timeout -fsSL -o "$tmpdir/$filename" "$codeload_url"; then
|
||||||
msg_error "Download failed: $direct_tarball_url (and fallback $codeload_url)"
|
download_success=true
|
||||||
rm -rf "$tmpdir"
|
fi
|
||||||
return 1
|
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
|
fi
|
||||||
|
|
||||||
mkdir -p "$target"
|
mkdir -p "$target"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user