From d9165c7f77dcfefef1c59489744a19da69e994b0 Mon Sep 17 00:00:00 2001 From: Aviv Date: Sun, 3 Oct 2021 13:07:40 +0300 Subject: [PATCH 1/3] Add option to use enviroment variable to increase rate limit --- download-latest.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/download-latest.sh b/download-latest.sh index 5565fb3f7..96cd3414a 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -67,10 +67,19 @@ semverLT() { return 1 } +# Get a token from https://github.com/settings/tokens to increasae rate limit (from 60 to 5000), make sure the token scope is set to 'public_repo' +# Create GITHUB_PAT enviroment variable once you aquired the token to start using it # Returns the tag of the latest stable release (in terms of semver and not of release date) get_latest() { temp_file='temp_file' # temp_file needed because the grep would start before the download is over - curl -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 + + if [[ -z "${GITHUB_PAT}" ]] + then + curl -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 + else + curl -H "Authorization: token ${GITHUB_PAT}" -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 + fi + releases=$(cat "$temp_file" | \ grep -E "tag_name|draft|prerelease" \ | tr -d ',"' | cut -d ':' -f2 | tr -d ' ') From 306a8cd059578e4ceadb8d710e9d8bbd282ef937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Sat, 16 Oct 2021 14:55:06 +0200 Subject: [PATCH 2/3] Update download-latest.sh --- download-latest.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/download-latest.sh b/download-latest.sh index 96cd3414a..301561c31 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -73,8 +73,7 @@ semverLT() { get_latest() { temp_file='temp_file' # temp_file needed because the grep would start before the download is over - if [[ -z "${GITHUB_PAT}" ]] - then + if [ -z "$GITHUB_PAT" ]; then curl -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 else curl -H "Authorization: token ${GITHUB_PAT}" -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 From ead1ec3396bf372ac65ea787d20b792f31fdba72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Sat, 16 Oct 2021 14:55:10 +0200 Subject: [PATCH 3/3] Update download-latest.sh --- download-latest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download-latest.sh b/download-latest.sh index 301561c31..a3030b176 100644 --- a/download-latest.sh +++ b/download-latest.sh @@ -76,7 +76,7 @@ get_latest() { if [ -z "$GITHUB_PAT" ]; then curl -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 else - curl -H "Authorization: token ${GITHUB_PAT}" -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 + curl -H "Authorization: token $GITHUB_PAT" -s 'https://api.github.com/repos/meilisearch/MeiliSearch/releases' > "$temp_file" || return 1 fi releases=$(cat "$temp_file" | \