@@ -34,6 +34,9 @@ GITHUB_USER="codeperfectplus"
3434GITHUB_REPO=" $APP_NAME "
3535GITHUB_URL=" https://github.com/$GITHUB_USER /$GITHUB_REPO "
3636ISSUE_TRACKER_URL=" $GITHUB_URL /issues"
37+ NUM_OF_RELEASES=5
38+
39+ NUM_OF_RETRIES=5
3740
3841# Environment variables
3942CONDA_ENV_NAME=" $APP_NAME_LOWER "
@@ -258,7 +261,6 @@ change_ownership() {
258261# check if conda is installed or not
259262check_conda () {
260263 local CONDA_PATHS=(" $USER_HOME /miniconda3" " $USER_HOME /anaconda3" " $1 " ) # Allow custom path as argument
261- echo $CONDA_PATHS
262264 local CONDA_FOUND=false
263265
264266 # Find Conda installation
@@ -595,9 +597,46 @@ install_from_git() {
595597 log " Installation complete. $APP_NAME is ready to use."
596598}
597599
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+
598636# install the latest version of APP from the release
599637install_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:"
601640 read -r VERSION
602641
603642 [ " $VERSION " == " latest" ] && fetch_latest_version
@@ -967,7 +1006,6 @@ show_help() {
9671006 echo " Shows information about all available options and how to use them."
9681007}
9691008
970-
9711009# Parse command-line options
9721010for arg in " $@ " ; do
9731011 case $arg in
@@ -986,6 +1024,7 @@ for arg in "$@"; do
9861024 --check-conda) check_conda; exit 0 ;;
9871025 --install-latest) ACTION=" install_latest" ;;
9881026 --open-app) open_browser; exit 0 ;;
1027+ --fetch-github-releases) fetch_github_releases; exit 0 ;;
9891028 --help) show_help; exit 0 ;;
9901029 * ) echo " Unknown option: $arg " ; show_help; exit 1 ;;
9911030 esac
@@ -1008,5 +1047,6 @@ case $ACTION in
10081047 install_latest) install_latest ;;
10091048 update_dependencies) update_dependencies ;;
10101049 open_browser) open_browser ;;
1050+ fetch_github_releases) fetch_github_releases ;;
10111051 * ) echo " No action specified. Use --help for usage information." ;;
10121052esac
0 commit comments