33# Exit as soon as any command fails
44set -e
55
6- BASE_URL= " https://storage.googleapis.com /flow-cli"
7- CLI_GIT_URL =" https://raw.githubusercontent. com/onflow/flow-cli/master/version.txt "
6+ REPO= " onflow /flow-cli"
7+ ASSETS_URL =" https://github. com/$REPO /releases/download/ "
88# The version to download, set by get_version (defaults to args[1])
99VERSION=" $1 "
1010# The architecture string, set by get_architecture
@@ -47,7 +47,7 @@ get_architecture() {
4747 return 1
4848 ;;
4949 esac
50- _arch=" ${_cputype } -${_ostype } "
50+ _arch=" ${_ostype } -${_cputype } "
5151 ARCH=" ${_arch} "
5252 TARGET_PATH=" ${_targetpath} "
5353}
@@ -56,7 +56,7 @@ get_architecture() {
5656get_version () {
5757 if [ -z " $VERSION " ]
5858 then
59- VERSION=$( curl -s " $CLI_GIT_URL " )
59+ VERSION=$( curl -s " https://api.github.com/repos/ $REPO /releases/latest " | grep -E ' tag_name ' | cut -d ' " ' -f 4 )
6060 fi
6161}
6262
@@ -71,21 +71,21 @@ main() {
7171 echo " Downloading version $VERSION ..."
7272
7373 tmpfile=$( mktemp 2> /dev/null || mktemp -t flow)
74-
75- url=" $BASE_URL /flow-$ARCH -$VERSION "
76- curl --progress-bar " $url " -o $tmpfile
74+ url=" $ASSETS_URL$VERSION /flow-cli-$VERSION -$ARCH .tar.gz"
75+ curl -L --progress-bar " $url " -o $tmpfile
7776
7877 # Ensure we don't receive a not found error as response.
79- if grep -q " The specified key does not exist " $tmpfile
78+ if grep -q " Not Found " $tmpfile
8079 then
8180 echo " Version $VERSION could not be found"
8281 exit 1
8382 fi
8483
85- chmod +x $tmpfile
86-
8784 [ -d $TARGET_PATH ] || mkdir -p $TARGET_PATH
88- mv $tmpfile $TARGET_PATH /flow
85+
86+ tar -xf $tmpfile -C $TARGET_PATH
87+ mv $TARGET_PATH /flow-cli $TARGET_PATH /flow
88+ chmod +x $TARGET_PATH /flow
8989
9090 echo " Successfully installed the Flow CLI to $TARGET_PATH ."
9191 echo " Make sure $TARGET_PATH is in your \$ PATH environment variable."
0 commit comments