File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,24 @@ initDownloadTool() {
6767 echo " Using $DOWNLOAD_TOOL as download tool"
6868}
6969
70+ checkLatestVersion () {
71+ # Use the GitHub releases webpage to find the latest version for this project
72+ # so we don't get rate-limited.
73+ local tag
74+ local regex=" [0-9][A-Za-z0-9\.-]*"
75+ local latest_url=" https://github.com/arduino/arduino-cli/releases/latest"
76+ if [ " $DOWNLOAD_TOOL " = " curl" ]; then
77+ tag=$( curl -SsL $latest_url | grep -o " Release $regex · arduino/arduino-cli" | grep -o " $regex " )
78+ elif [ " $DOWNLOAD_TOOL " = " wget" ]; then
79+ tag=$( wget -q -O - $latest_url | grep -o " Release $regex · arduino/arduino-cli" | grep -o " $regex " )
80+ fi
81+ if [ " x$tag " == " x" ]; then
82+ echo " Cannot determine latest tag."
83+ exit 1
84+ fi
85+ eval " $1 ='$tag '"
86+ }
87+
7088get () {
7189 local url=" $2 "
7290 local body
@@ -101,8 +119,7 @@ getFile() {
101119}
102120
103121downloadFile () {
104- get TAG_JSON https://api.github.com/repos/arduino/arduino-cli/releases/latest
105- TAG=$( echo $TAG_JSON | python -c ' import json,sys;obj=json.load(sys.stdin, strict=False);sys.stdout.write(obj["tag_name"])' )
122+ checkLatestVersion TAG
106123 echo " TAG=$TAG "
107124 # arduino-cli_0.4.0-rc1_Linux_64bit.[tar.gz, zip]
108125 if [ " $OS " == " Windows" ]; then
You can’t perform that action at this time.
0 commit comments