@@ -34,6 +34,9 @@ GITHUB_USER="codeperfectplus"
34
34
GITHUB_REPO=" $APP_NAME "
35
35
GITHUB_URL=" https://github.com/$GITHUB_USER /$GITHUB_REPO "
36
36
ISSUE_TRACKER_URL=" $GITHUB_URL /issues"
37
+ NUM_OF_RELEASES=5
38
+
39
+ NUM_OF_RETRIES=5
37
40
38
41
# Environment variables
39
42
CONDA_ENV_NAME=" $APP_NAME_LOWER "
@@ -258,7 +261,6 @@ change_ownership() {
258
261
# check if conda is installed or not
259
262
check_conda () {
260
263
local CONDA_PATHS=(" $USER_HOME /miniconda3" " $USER_HOME /anaconda3" " $1 " ) # Allow custom path as argument
261
- echo $CONDA_PATHS
262
264
local CONDA_FOUND=false
263
265
264
266
# Find Conda installation
@@ -595,9 +597,46 @@ install_from_git() {
595
597
log " Installation complete. $APP_NAME is ready to use."
596
598
}
597
599
600
+ # Function to fetch and display GitHub releases
601
+ fetch_github_releases () {
602
+ local url=" https://api.github.com/repos/${GITHUB_USER} /${GITHUB_REPO} /releases"
603
+
604
+ # Check if jq is installed
605
+ if ! command -v jq & > /dev/null; then
606
+ echo " Error: jq is not installed. Please install jq to use this function."
607
+ return 1
608
+ fi
609
+
610
+ # Fetch releases
611
+ response=$( curl -s " $url " )
612
+
613
+ # Check if curl command was successful
614
+ if [ $? -ne 0 ]; then
615
+ echo " Error: Failed to fetch releases from GitHub."
616
+ return 1
617
+ fi
618
+
619
+ # Check if response contains a valid JSON
620
+ if ! echo " $response " | jq . > /dev/null 2>&1 ; then
621
+ echo " Error: Failed to parse JSON response from GitHub."
622
+ return 1
623
+ fi
624
+
625
+ # Display releases with newest first
626
+ # Display releases with newest first in tabular format
627
+ echo " --------------------------------------------"
628
+ echo " Latest releases for $APP_NAME :"
629
+ echo " --------------------------------------------"
630
+ echo " $response " | jq -r ' .[] | [.tag_name, .published_at] | @tsv' | sort -r -t $' \t ' -k2,2 | awk -F' \t' ' BEGIN { printf "%-15s %-20s\n", "Tag Name", "Published At" } { printf "%-15s %-20s\n", $1, $2 }' | head -n $NUM_OF_RELEASES
631
+ echo " --------------------------------------------"
632
+ # Exit with status code 0
633
+ return 0
634
+ }
635
+
598
636
# install the latest version of APP from the release
599
637
install_from_release () {
600
- echo " Enter the version of $APP_NAME to install (e.g., v1.0.0 or 'latest' for the latest version):"
638
+ fetch_github_releases
639
+ echo " Enter the tag name of the release to install (e.g., v1.0.3) or 'latest' for the latest release:"
601
640
read -r VERSION
602
641
603
642
[ " $VERSION " == " latest" ] && fetch_latest_version
@@ -967,7 +1006,6 @@ show_help() {
967
1006
echo " Shows information about all available options and how to use them."
968
1007
}
969
1008
970
-
971
1009
# Parse command-line options
972
1010
for arg in " $@ " ; do
973
1011
case $arg in
@@ -986,6 +1024,7 @@ for arg in "$@"; do
986
1024
--check-conda) check_conda; exit 0 ;;
987
1025
--install-latest) ACTION=" install_latest" ;;
988
1026
--open-app) open_browser; exit 0 ;;
1027
+ --fetch-github-releases) fetch_github_releases; exit 0 ;;
989
1028
--help) show_help; exit 0 ;;
990
1029
* ) echo " Unknown option: $arg " ; show_help; exit 1 ;;
991
1030
esac
@@ -1008,5 +1047,6 @@ case $ACTION in
1008
1047
install_latest) install_latest ;;
1009
1048
update_dependencies) update_dependencies ;;
1010
1049
open_browser) open_browser ;;
1050
+ fetch_github_releases) fetch_github_releases ;;
1011
1051
* ) echo " No action specified. Use --help for usage information." ;;
1012
1052
esac
0 commit comments