2022-02-03

This commit is contained in:
Louis Seubert 2022-02-03 19:33:04 +01:00
commit db393215ce
Signed by: louis9902
GPG key ID: 4B9DB28F826553BD
55 changed files with 1907 additions and 0 deletions

View file

@ -0,0 +1,20 @@
# -*- mode: bash -*-
[[ ! "${LIB_SHELL_GITHUB}" ]] && LIB_SHELL_GITHUB="Y" || return
has_software 'jq' 'curl'
function github_api() {
curl -L --silent -H "Accept: application/vnd.github.v3.raw+json" \
${TOKEN:+ -H "Authorization: Token ${TOKEN}"} "$@"
}
github_get_latest_release() {
local user="${1:?'require name'}" repo="${2:-"$1"}"
github_api "https://api.github.com/repos/${user}/${repo}/releases/latest"
}
github_latest_release_assets() {
local name="\$doc.tag_name"
local link="(\$doc.assets[] | select(.name ${SUFFIX:+"| endswith(\"${SUFFIX}\")"}).browser_download_url)"
github_get_latest_release "$@" | jq -r ". as \$doc | ${name} + \" \" + ${link}"
}