File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,24 @@ initDownloadTool() {
67
67
echo " Using $DOWNLOAD_TOOL as download tool"
68
68
}
69
69
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
+
70
88
get () {
71
89
local url=" $2 "
72
90
local body
@@ -101,8 +119,7 @@ getFile() {
101
119
}
102
120
103
121
downloadFile () {
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
106
123
echo " TAG=$TAG "
107
124
# arduino-cli_0.4.0-rc1_Linux_64bit.[tar.gz, zip]
108
125
if [ " $OS " == " Windows" ]; then
You can’t perform that action at this time.
0 commit comments