From d57156ec228b712ccd429367482771179e3fa050 Mon Sep 17 00:00:00 2001
From: Mark Fine <mark.fine@gmail.com>
Date: Fri, 27 Jan 2023 17:17:38 -0800
Subject: [PATCH] chore: fix install.sh to point at releases API (#3510)

---
 install.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
 mode change 100644 => 100755 install.sh

diff --git a/install.sh b/install.sh
old mode 100644
new mode 100755
index 291c47ac..68bd5380
--- a/install.sh
+++ b/install.sh
@@ -317,11 +317,14 @@ http_copy() {
 github_release() {
   owner_repo=$1
   version=$2
-  test -z "$version" && version="latest"
-  giturl="https://github.com/${owner_repo}/releases/${version}"
+  if [ -z "$version" ]; then
+      giturl="https://api.github.com/repos/${owner_repo}/releases/latest"
+  else
+      giturl="https://api.github.com/repos/${owner_repo}/releases/tags/${version}"
+  fi
   json=$(http_copy "$giturl" "Accept:application/json")
   test -z "$json" && return 1
-  version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name":"//' | sed 's/".*//')
+  version=$(echo "$json" | tr -s '\n' ' ' | sed 's/.*"tag_name": "//' | sed 's/".*//')
   test -z "$version" && return 1
   echo "$version"
 }