summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-05-11 00:35:06 -0700
committerCaleb Bassi <calebjbassi@gmail.com>2018-05-11 00:35:06 -0700
commitd658207fb3fb7a11b0246155a3d8146a4905e537 (patch)
tree240b1cbac04c4fc3a426265f9e5c8d7434086693 /scripts
parent3bcfe5fd6375a219eb8ea5c96f95cceae8be73cd (diff)
Auto fetch latest release in download.sh
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/download.sh15
1 files changed, 12 insertions, 3 deletions
diff --git a/scripts/download.sh b/scripts/download.sh
index 831c482..3e48f01 100755
--- a/scripts/download.sh
+++ b/scripts/download.sh
@@ -1,15 +1,24 @@
#!/usr/bin/env bash
-VERSION=1.2.15
+
+get_latest_release_version() {
+ curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
+ grep '"tag_name":' | # Get tag line
+ sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
+}
+
download() {
- archive=gotop_${VERSION}_${1}.tgz
- curl -LO https://github.com/cjbassi/gotop/releases/download/$VERSION/$archive
+ archive=gotop_${version}_${1}.tgz
+ curl -LO https://github.com/cjbassi/gotop/releases/download/$version/$archive
tar xf $archive
rm $archive
}
+
arch=$(uname -sm)
+version=$(get_latest_release_version 'cjbassi/gotop')
+
case "$arch" in
# order matters
Linux\ armv5*) download linux_arm5 ;;