Update github.func
This commit is contained in:
parent
7e1f84ae2a
commit
d856b73ab4
@ -1,9 +1,6 @@
|
|||||||
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||||
|
|
||||||
get_gh_release() {
|
get_gh_release() {
|
||||||
set -Eeuo pipefail
|
|
||||||
trap 'echo -e "\n❌ [get_gh_release] Error on line $LINENO: $BASH_COMMAND"' ERR
|
|
||||||
|
|
||||||
local repo="$1"
|
local repo="$1"
|
||||||
local app="${repo##*/}"
|
local app="${repo##*/}"
|
||||||
local api_url="https://api.github.com/repos/$repo/releases/latest"
|
local api_url="https://api.github.com/repos/$repo/releases/latest"
|
||||||
@ -18,10 +15,10 @@ get_gh_release() {
|
|||||||
|
|
||||||
until [[ $attempt -ge $max_attempts ]]; do
|
until [[ $attempt -ge $max_attempts ]]; do
|
||||||
((attempt++))
|
((attempt++))
|
||||||
msg_info "[$attempt/$max_attempts] Fetching GitHub release for $repo"
|
msg_info "[$attempt/$max_attempts] Fetching GitHub release for $repo...\n"
|
||||||
|
|
||||||
if ! api_response=$(curl -fsSL "${header[@]}" "$api_url"); then
|
if ! api_response=$(curl -fsSL "${header[@]}" "$api_url"); then
|
||||||
msg_warn "Request failed for $repo, retrying..."
|
msg_info "Request failed, retrying...\n"
|
||||||
sleep 2
|
sleep 2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -40,19 +37,12 @@ get_gh_release() {
|
|||||||
[[ "$tag" =~ ^v[0-9] ]] && tag="${tag:1}"
|
[[ "$tag" =~ ^v[0-9] ]] && tag="${tag:1}"
|
||||||
|
|
||||||
if [[ -z "$tag" ]]; then
|
if [[ -z "$tag" ]]; then
|
||||||
msg_error "Empty tag received, retrying..."
|
msg_info "Empty tag received, retrying...\n"
|
||||||
sleep 2
|
sleep 2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_ok "Found release: $tag for $repo"
|
msg_ok "Found release: $tag for $repo"
|
||||||
|
|
||||||
local version_file="/opt/${app}_version.txt"
|
|
||||||
if [[ ! -f "$version_file" ]]; then
|
|
||||||
echo "$tag" >"$version_file"
|
|
||||||
echo "📝 Saved version info to $version_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$tag"
|
echo "$tag"
|
||||||
return 0
|
return 0
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user