Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add utility functions for processing Github releases #330

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions misc/install.func
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,23 @@ EOF
echo "bash -c \"\$(wget -qLO - https://github.com/community-scripts/ProxmoxVE/raw/main/ct/${app}.sh)\"" >/usr/bin/update
chmod +x /usr/bin/update
}

# This function downloads the latest release of a GitHub repository
github_download_latest_release() {
local user="$1"
local repo="$2"
local output_file="$3"
local tarball_url=$($STD wget -qLO - "https://api.github.com/repos/$user/$repo/releases/latest" | grep '"tarball_url":' | cut -d '"' -f 4)
$STD wget -qLO "$output_file" "$tarball_url"
}

# This function extracts a GitHub release tarball into a target directory
github_extract_latest_release() {
local user="$1"
local repo="$2"
local output_directory="$3"
mkdir -p "$output_directory"
github_download_latest_release "$user" "$repo" "/tmp/$repo.tar.gz"
tar -xzf "/tmp/$repo.tar.gz" -C "$output_directory" --strip-components 1
rm "/tmp/$repo.tar.gz"
}