Skip to content

Instantly share code, notes, and snippets.

@ahgraber
Last active May 19, 2022 13:17
Show Gist options
  • Save ahgraber/51daf05ad8e8642dcc9a13b61fee4e3c to your computer and use it in GitHub Desktop.
Save ahgraber/51daf05ad8e8642dcc9a13b61fee4e3c to your computer and use it in GitHub Desktop.
Latest github release

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment