fix: resolve the utils logic

This commit is contained in:
2026-01-17 13:03:35 +07:00
parent 0e85707946
commit 3becfad4f7
+3 -10
View File
@@ -100,20 +100,13 @@ get_rv_prebuilts() {
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
tag_name=$(jq -r '.tag_name' <<<"$resp")
# Filter assets by extension and handle multiple matches
# Use jq array syntax to get first match as a complete JSON object
if [ "$ver" = "dev" ]; then
# For dev version, prefer the one with "dev" in the name
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\") and contains(\"dev\"))" <<<"$resp" | head -1)
# If no dev asset found, take any matching asset
if [ -z "$asset" ]; then
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp" | head -1) || return 1
fi
asset=$(jq -e -r "[.assets[] | select(.name | endswith(\"$ext\") and contains(\"dev\"))][0] // [.assets[] | select(.name | endswith(\"$ext\"))][0]" <<<"$resp") || return 1
else
# For non-dev versions, exclude dev builds and take the first match
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\") and (contains(\"dev\") | not))" <<<"$resp" | head -1)
# If no non-dev asset found, take any matching asset
if [ -z "$asset" ]; then
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp" | head -1) || return 1
fi
asset=$(jq -e -r "[.assets[] | select(.name | endswith(\"$ext\") and (contains(\"dev\") | not))][0] // [.assets[] | select(.name | endswith(\"$ext\"))][0]" <<<"$resp") || return 1
fi
url=$(jq -r .url <<<"$asset")
name=$(jq -r .name <<<"$asset")