Browse Source

fix: retry gh install on failure

Baptiste Augrain 1 day ago
parent
commit
bfdcc2257b
3 changed files with 15 additions and 7 deletions
  1. 1 1
      build/linux/package_bin.sh
  2. 1 1
      build/windows/package.sh
  3. 13 5
      install_gh.sh

+ 1 - 1
build/linux/package_bin.sh

@@ -118,7 +118,7 @@ fi
 
 for i in {1..5}; do # try 5 times
   npm ci && break
-  if [[ $i -eq 3 ]]; then
+  if [[ $i == 3 ]]; then
     echo "Npm install failed too many times" >&2
     exit 1
   fi

+ 1 - 1
build/windows/package.sh

@@ -13,7 +13,7 @@ cd vscode || { echo "'vscode' dir not found"; exit 1; }
 
 for i in {1..5}; do # try 5 times
   npm ci && break
-  if [[ $i -eq 3 ]]; then
+  if [[ $i == 3 ]]; then
     echo "Npm install failed too many times" >&2
     exit 1
   fi

+ 13 - 5
install_gh.sh

@@ -4,12 +4,20 @@ set -ex
 
 GH_ARCH="amd64"
 
-TAG=$( curl --retry 12 --retry-delay 30 "https://api.github.com/repos/cli/cli/releases/latest" 2>/dev/null | jq --raw-output '.tag_name' )
+for i in {1..5}; do
+  TAG=$( curl --retry 12 --retry-delay 30 "https://api.github.com/repos/cli/cli/releases/latest" 2>/dev/null | jq --raw-output '.tag_name' )
 
-if [[ $? -ne 0 ]] || [[ "${TAG}" == "null" ]]; then
-  echo "Error: Failed to retrieve the latest tag from GitHub CLI releases."
-  exit 1
-fi
+  if [[ $? == 0 && "${TAG}" != "null" ]]; then
+    break
+  fi
+
+  if [[ $i == 3 ]]; then
+    echo "GH install failed too many times" >&2
+    exit 1
+  fi
+
+  echo "GH install failed $i, trying again..."
+done
 
 VERSION="${TAG#v}"