ref: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
#!/bin/bash
get_latest_version(){
curl "https://api.github.com/repos/$1/releases" -s \
| jq -r ".[].tag_name" \
| sort -nr \
| head -n 1
}
get_latest_link () {
curl -s "https://github.com/$1/releases" \
| grep -m1 -Eo "archive/refs/tags/[^/]+\.tar\.gz" \
| xargs printf "https://github.com/$1/%s"
}
get_latest_version restic/restic
get_latest_link restic/restic