From 5d64161e579934fc2e2acbf07d70732a4536a829 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:38:33 +0200 Subject: [PATCH] Update install.func --- misc/install.func | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/misc/install.func b/misc/install.func index 072a85c..e85fa55 100644 --- a/misc/install.func +++ b/misc/install.func @@ -282,23 +282,24 @@ get_gh_release() { local header=() local attempt=0 local max_attempts=3 - local api_response tag http_code + local tag + local tmpfile http_code echo "🔍 Checking latest release for: $repo" - [[ -n "${GITHUB_TOKEN:-}" ]] && header=(-H "Authorization: token $GITHUB_TOKEN") + tmpfile=$(mktemp) + until [[ $attempt -ge $max_attempts ]]; do ((attempt++)) || true $STD msg_info "[$attempt/$max_attempts] Fetching GitHub release for $repo...\n" - # Hole HTTP-Status explizit - api_response=$(curl -fsSL -w "%{http_code}" -o /tmp/gh_resp.json "${header[@]}" "$api_url") - http_code="${api_response:(-3)}" + http_code=$(curl -sSL -w "%{http_code}" -o "$tmpfile" "${header[@]}" "$api_url") if [[ "$http_code" == "404" ]]; then + rm -f "$tmpfile" msg_error "Repository $repo has no Release candidate (404)" - return 1 + exit 1 fi if [[ "$http_code" != "200" ]]; then @@ -307,19 +308,19 @@ get_gh_release() { continue fi - api_response=$(/dev/null; then + if jq -e '.message == "Not Found"' "$tmpfile" &>/dev/null; then + rm -f "$tmpfile" msg_error "Repository not found: $repo" - return 1 + exit 1 fi - tag=$(echo "$api_response" | jq -r '.tag_name // .name // empty') + tag=$(jq -r '.tag_name // .name // empty' "$tmpfile") [[ "$tag" =~ ^v[0-9] ]] && tag="${tag:1}" if [[ -z "$tag" ]]; then @@ -328,10 +329,13 @@ get_gh_release() { continue fi + rm -f "$tmpfile" $STD msg_ok "Found release: $tag for $repo" + echo "$tag" return 0 done + rm -f "$tmpfile" msg_error "Failed to fetch release for $repo after $max_attempts attempts." exit 1 }