2022-02-03
This commit is contained in:
parent
f86b8496ec
commit
db393215ce
55 changed files with 1907 additions and 0 deletions
20
home/dot-local/lib/bash/github-api.sh
Normal file
20
home/dot-local/lib/bash/github-api.sh
Normal 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}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue