18 lines
553 B
Bash
18 lines
553 B
Bash
# shellcheck shell=bash
|
|
|
|
github_latest() {
|
|
repo="$1"
|
|
tag="${2:-latest}"
|
|
if [ "$tag" = "--no-latest-tag" ]; then
|
|
curl -sfSL "https://github.com/$repo/tags" \
|
|
| perl -ne 'm,a href="/'"$repo"'/releases/tag/v(\d\.\d(?:.\d)?)", && print "$1\n"' \
|
|
| sort -V \
|
|
| tail -n1 || echo "[github error]"
|
|
else
|
|
curl -sfSI "https://github.com/$repo/releases/$tag" \
|
|
| grep '^location' \
|
|
| awk -F/ '{print $NF}' \
|
|
| sed 's/\s\+$//' || echo "[github error]"
|
|
fi
|
|
}
|
|
|