Support dynamic resource selection

This commit is contained in:
Ohad Livne 2026-01-29 23:15:28 +02:00
parent c16e517a9c
commit 040f83561c
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D
6 changed files with 29 additions and 11 deletions

View file

@ -9,7 +9,7 @@ mkdir --parents "${STATE_DIR}"
github_update() {
package="$1"
repo="$2"
resource="$3"
resource_selector="$3"
post_fetch="$4"
response=$(curl --silent "https://api.github.com/repos/${repo}/releases/latest")
@ -31,6 +31,9 @@ github_update() {
fi
if [ "${install}" = "true" ]; then
echo "\"${latest_version}\""
resource=$(${resource_selector} "${latest_version}")
echo "\"${resource}\""
asset=$(printf '%s' "${response}" | jq --raw-output ".assets[] | select(.name == \"${resource}\").browser_download_url")
curl --location "${asset}" | "${post_fetch}" && \
echo "${latest_version}" > "${VERSION_FILE}" && \