1
- # SOURCE: https://github.com/Schniz/fnm/blob/master/.ci/install.sh
2
-
3
1
#! /bin/bash
4
2
3
+ # SOURCE: https://github.com/Schniz/fnm/blob/master/.ci/install.sh
4
+
5
5
set -e
6
6
7
7
INSTALL_DIR=" $HOME /.snm"
8
- RELEASE=" latest"
9
8
OS=" $( uname -s) "
10
9
11
10
# Parse Flags
@@ -27,7 +26,7 @@ parse_args() {
27
26
# echo "\`--force-install\`: I hope you know what you're doing." >&2
28
27
# FORCE_INSTALL="true"
29
28
# shift
30
- ;;
29
+ # ;;
31
30
-r | --release)
32
31
RELEASE=" $2 "
33
32
shift # past release argument
@@ -41,24 +40,29 @@ parse_args() {
41
40
done
42
41
}
43
42
43
+ # Resources: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c
44
+ get_latest_release () {
45
+ RELEASE=$( curl --silent " https://api.github.com/repos/numToStr/snm/releases/latest" | grep -Po ' "tag_name": "\K.*?(?=")' & )
46
+ }
47
+
44
48
set_filename () {
45
49
if [ " $OS " == " Linux" ]; then
46
50
# Based on https://stackoverflow.com/a/45125525
47
51
case " $( uname -m) " in
48
52
arm | armv7* )
49
- FILENAME=" snm-armv7-unknown-linux-gnueabihf"
53
+ FILENAME=" snm-$RELEASE - armv7-unknown-linux-gnueabihf"
50
54
;;
51
55
aarch* | armv8* )
52
- FILENAME=" snm-aarch64-unknown-linux-gnu"
56
+ FILENAME=" snm-$RELEASE - aarch64-unknown-linux-gnu"
53
57
;;
54
58
* )
55
- FILENAME=" snm-x86_64-unknown-linux-gnu"
59
+ FILENAME=" snm-$RELEASE - x86_64-unknown-linux-gnu"
56
60
esac
57
61
# elif [ "$OS" == "Darwin" ] && [ "$FORCE_INSTALL" == "true" ]; then
58
62
elif [ " $OS " == " Darwin" ]; then
59
- FILENAME=" snm-x86_64-apple-darwin"
63
+ FILENAME=" snm-$RELEASE - x86_64-apple-darwin"
60
64
# USE_HOMEBREW="false"
61
- echo " Downloading the latest snm binary from GitHub..."
65
+ echo " Downloading snm $VERSION binary from GitHub..."
62
66
# echo " Pro tip: it's eaiser to use Homebrew for managing snm in MacOS."
63
67
# echo " Remove the \`--force-no-brew\` so it will be easy to upgrade."
64
68
# elif [ "$OS" == "Darwin" ]; then
@@ -75,12 +79,7 @@ download_snm() {
75
79
# if [ "$USE_HOMEBREW" == "true" ]; then
76
80
# brew install snm
77
81
# else
78
- if [ " $RELEASE " == " latest" ]; then
79
- URL=" https://github.com/numToStr/snm/releases/latest/download/$FILENAME .tar.gz"
80
- else
81
- URL=" https://github.com/numToStr/snm/releases/download/$RELEASE /$FILENAME .tar.gz"
82
- fi
83
-
82
+ URL=" https://github.com/numToStr/snm/releases/download/$RELEASE /$FILENAME .tar.gz"
84
83
DOWNLOAD_DIR=$( mktemp -d)
85
84
86
85
echo " Downloading $URL ..."
@@ -209,6 +208,7 @@ setup_shell() {
209
208
}
210
209
211
210
parse_args " $@ "
211
+ get_latest_release
212
212
set_filename
213
213
check_dependencies
214
214
download_snm
0 commit comments