Support dynamic resource selection
This commit is contained in:
parent
4cc2af055d
commit
0e61f5f32f
6 changed files with 29 additions and 11 deletions
|
|
@ -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}" && \
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue