mirror of
https://github.com/kaboomserver/server.git
synced 2025-04-22 17:33:39 -04:00
feat: github download source
This commit is contained in:
parent
be2d2943a2
commit
198f009cab
2 changed files with 22 additions and 0 deletions
scripts/_sources
20
scripts/_sources/_github.sh
Normal file
20
scripts/_sources/_github.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
_fetch_github_asset() {
|
||||
list_release_url="https://api.github.com/repos/$1/releases"
|
||||
debug "fetch: $list_release_url"
|
||||
|
||||
# We have to read the variables like this because POSIX read
|
||||
# doesn't support reading multiple variables at a time
|
||||
download_url="$(fetch -so- "$list_release_url" | \
|
||||
jq --raw-output --exit-status --arg filter "$2" \
|
||||
'.[0].assets[] | select(.name | test($filter)) | .browser_download_url')"
|
||||
}
|
||||
|
||||
_download_type_github() {
|
||||
read_args repo asset
|
||||
require_args repo asset
|
||||
|
||||
_fetch_github_asset "${arg_repo:?}" "${arg_asset:?}"
|
||||
download "$download_url" "$1"
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
# shellcheck disable=SC1091
|
||||
|
||||
. "$_SCRIPT_PATH"/_sources/_bibliothek.sh
|
||||
. "$_SCRIPT_PATH"/_sources/_github.sh
|
||||
. "$_SCRIPT_PATH"/_sources/_url.sh
|
||||
. "$_SCRIPT_PATH"/_sources/_zip.sh
|
||||
|
||||
|
@ -61,6 +62,7 @@ download_type() {
|
|||
# be propagated into the _download_type_... functions.
|
||||
case "$1" in
|
||||
"bibliothek") _download_type_bibliothek "$2";;
|
||||
"github") _download_type_github "$2";;
|
||||
"url") _download_type_url "$2";;
|
||||
"zip") _download_type_zip "$2";;
|
||||
*) echo Invalid download type "$1"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue