jerecom commited on
Commit
aa45718
·
verified ·
1 Parent(s): 9fe1893

Dynamic: fetch latest release from badman99dev/opencode-1

Browse files
Files changed (1) hide show
  1. install.sh +12 -5
install.sh CHANGED
@@ -181,19 +181,26 @@ else
181
  fi
182
 
183
  if [ -z "$requested_version" ]; then
184
- url="https://github.com/badman99dev/opencode-1/releases/download/v1.0.1/opencode-linux-x64.tar.gz"
185
- specific_version="1.0.1"
 
 
 
 
 
 
 
186
  else
187
  # Strip leading 'v' if present
188
  requested_version="${requested_version#v}"
189
- url="https://github.com/anomalyco/opencode/releases/download/v${requested_version}/$filename"
190
  specific_version=$requested_version
191
 
192
  # Verify the release exists before downloading
193
- http_status=$(curl -sI -o /dev/null -w "%{http_code}" "https://github.com/anomalyco/opencode/releases/tag/v${requested_version}")
194
  if [ "$http_status" = "404" ]; then
195
  echo -e "${RED}Error: Release v${requested_version} not found${NC}"
196
- echo -e "${MUTED}Available releases: https://github.com/anomalyco/opencode/releases${NC}"
197
  exit 1
198
  fi
199
  fi
 
181
  fi
182
 
183
  if [ -z "$requested_version" ]; then
184
+ # Fetch latest release version from badman99dev/opencode-1
185
+ specific_version=$(curl -s https://api.github.com/repos/badman99dev/opencode-1/releases/latest | sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p')
186
+
187
+ if [[ $? -ne 0 || -z "$specific_version" ]]; then
188
+ echo -e "${RED}Failed to fetch latest version from badman99dev/opencode-1${NC}"
189
+ exit 1
190
+ fi
191
+
192
+ url="https://github.com/badman99dev/opencode-1/releases/download/v${specific_version}/opencode-linux-x64.tar.gz"
193
  else
194
  # Strip leading 'v' if present
195
  requested_version="${requested_version#v}"
196
+ url="https://github.com/badman99dev/opencode-1/releases/download/v${requested_version}/opencode-linux-x64.tar.gz"
197
  specific_version=$requested_version
198
 
199
  # Verify the release exists before downloading
200
+ http_status=$(curl -sI -o /dev/null -w "%{http_code}" "https://github.com/badman99dev/opencode-1/releases/tag/v${requested_version}")
201
  if [ "$http_status" = "404" ]; then
202
  echo -e "${RED}Error: Release v${requested_version} not found${NC}"
203
+ echo -e "${MUTED}Available releases: https://github.com/badman99dev/opencode-1/releases${NC}"
204
  exit 1
205
  fi
206
  fi