diff --git a/local/bin/x-gh-get-latest-release-targz b/local/bin/x-gh-get-latest-release-targz new file mode 100755 index 0000000..bf5d968 --- /dev/null +++ b/local/bin/x-gh-get-latest-release-targz @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +REPO=$1 + +if [ -z "$REPO" ]; then + echo "Usage: $0 (e.g. ivuorinen/dotfiles)" + exit 1 +fi + +LOCATION=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" \ + | sed -Ene '/^[[:blank:]]+"tarball_url":[[:blank:]]"(https:[^"]+)",/s//\1/p') + +echo "Downloading and extracting from: $LOCATION" + +curl --location --silent "$LOCATION" | tar --extract --gzip --file=- + +# vim: set ts=2 sw=2 ft=sh et: diff --git a/local/bin/x-gh-get-latest-version b/local/bin/x-gh-get-latest-version new file mode 100755 index 0000000..d1f2a18 --- /dev/null +++ b/local/bin/x-gh-get-latest-version @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +REPO=$1 + +if [ -z "$REPO" ]; then + echo "Usage: $0 (e.g. ivuorinen/dotfiles)" + exit 1 +fi + +VERSION=$( + curl -s "https://api.github.com/repos/${REPO}/releases/latest" \ + | grep "tag_name" \ + | awk '{print substr($2, 2, length($2)-3)}' +) + +echo "$VERSION" + +# vim: set ts=2 sw=2 ft=sh et: