Skip to content

Commit 37a8e5e

Browse files
authored
Do not hit github api to get latest version from install script (arduino#347)
* do not hit github api to get latest version * don't use PCRE
1 parent dd6f633 commit 37a8e5e

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

install.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff 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+
7088
get() {
7189
local url="$2"
7290
local body
@@ -101,8 +119,7 @@ getFile() {
101119
}
102120

103121
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
106123
echo "TAG=$TAG"
107124
# arduino-cli_0.4.0-rc1_Linux_64bit.[tar.gz, zip]
108125
if [ "$OS" == "Windows" ]; then

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy