Support dynamic resource selection

This commit is contained in:
Ohad Livne 2026-01-29 23:15:28 +02:00
parent 4cc2af055d
commit 0e61f5f32f
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}" && \

View file

@ -5,11 +5,14 @@ IFS=$'\n\t'
package=dolt
repo=dolthub/dolt
resource=dolt-linux-amd64.tar.gz
dolt_resource() {
echo "dolt-linux-amd64.tar.gz"
}
install_dolt() {
tar xz --directory="$(systemd-path user-binaries)" --strip-components=2 dolt-linux-amd64/bin/dolt
chmod 550 "$(systemd-path user-binaries)"/dolt
}
github_update "${package}" "${repo}" "${resource}" install_dolt
github_update "${package}" "${repo}" dolt_resource install_dolt

View file

@ -5,11 +5,14 @@ IFS=$'\n\t'
package=kingfisher
repo=mongodb/kingfisher
resource=kingfisher-linux-x64.tgz
kingfisher_resource() {
echo "kingfisher-linux-x64.tgz"
}
install_kingfisher() {
tar xz --directory="$(systemd-path user-binaries)" kingfisher
chmod 550 "$(systemd-path user-binaries)"/kingfisher
}
github_update "${package}" "${repo}" "${resource}" install_kingfisher
github_update "${package}" "${repo}" kingfisher_resource install_kingfisher

View file

@ -5,7 +5,10 @@ IFS=$'\n\t'
package=minikube
repo=kubernetes/minikube
resource=minikube-linux-amd64
minikube_resource() {
echo "minikube-linux-amd64"
}
install_minikube() {
tempfile="$(mktemp)"
@ -14,4 +17,4 @@ install_minikube() {
mv "${tempfile}" "$(systemd-path user-binaries)"/minikube
}
github_update "${package}" "${repo}" "${resource}" install_minikube
github_update "${package}" "${repo}" minikube_resource install_minikube

View file

@ -5,7 +5,10 @@ IFS=$'\n\t'
package=rust-analyzer
repo=rust-lang/rust-analyzer
resource=rust-analyzer-x86_64-unknown-linux-gnu.gz
rust_analyzer_resource() {
echo "rust-analyzer-x86_64-unknown-linux-gnu.gz"
}
install_rust_analyzer() {
tempfile="$(mktemp)"
@ -14,4 +17,4 @@ install_rust_analyzer() {
mv "${tempfile}" "$(systemd-path user-binaries)"/rust-analyzer
}
github_update "${package}" "${repo}" "${resource}" install_rust_analyzer
github_update "${package}" "${repo}" rust_analyzer_resource install_rust_analyzer

View file

@ -5,7 +5,10 @@ IFS=$'\n\t'
package=uv
repo=astral-sh/uv
resource=uv-x86_64-unknown-linux-gnu.tar.gz
uv_resource() {
echo "uv-x86_64-unknown-linux-gnu.tar.gz"
}
install_uv() {
tempdir="$(mktemp --directory)"
@ -14,4 +17,4 @@ install_uv() {
mv --force "${tempdir}"/uv "${tempdir}"/uvx "$(systemd-path user-binaries)"
}
github_update "${package}" "${repo}" "${resource}" install_uv
github_update "${package}" "${repo}" uv_resource install_uv