@@ -84,6 +84,50 @@ fetch_last_updated() {
84
84
fi
85
85
}
86
86
87
+ download_and_extract_latest_release () {
88
+ local repo_url=" $1 "
89
+ if [[ $repo_url != * " github.com" * ]]; then
90
+ echo " Unsupported URL: $repo_url "
91
+ return
92
+ fi
93
+
94
+ local repo_name=$( echo " $repo_url " | awk -F' github.com/' ' {print $2}' )
95
+ local latest_release_urls=$( curl -s " https://api.github.com/repos/${repo_name} /releases/latest" | grep " browser_download_url" | cut -d ' "' -f 4)
96
+
97
+ if [ -z " $latest_release_urls " ]; then
98
+ echo " No releases found for $repo_name "
99
+ return 1
100
+ fi
101
+
102
+ rm -rf " ./tmp/${repo_name} "
103
+ local temp_dir=" ./tmp/${repo_name} "
104
+ mkdir -p " ${temp_dir} " || echo " "
105
+
106
+ for url in $latest_release_urls ; do
107
+ local temp_file=" ./tmp/$( basename " $url " ) "
108
+ local temp_unzip_dir=" $temp_dir "
109
+
110
+ if [[ " $temp_file " == * " windows" * ]]; then
111
+ temp_unzip_dir=" $temp_unzip_dir /windows"
112
+ elif [[ " $temp_file " == * " linux" * ]]; then
113
+ temp_unzip_dir=" $temp_unzip_dir /linux"
114
+ fi
115
+
116
+ if [ ! -f " $temp_file " ]; then
117
+ echo " Downloading latest release from $url ..."
118
+ curl -L -o " $temp_file " " $url "
119
+ fi
120
+
121
+ echo " Extracting $temp_file ..."
122
+ case " $temp_file " in
123
+ * .tar.gz) tar --overwrite -xzf " $temp_file " -C " $temp_unzip_dir " > /dev/null ;;
124
+ * .zip) unzip -o " $temp_file " -d " $temp_unzip_dir " > /dev/null ;;
125
+ * ) echo " Unsupported file format: $temp_file " ;;
126
+ esac
127
+ done
128
+ echo " Latest release downloaded and extracted to $temp_dir "
129
+ }
130
+
87
131
main () {
88
132
# Call extract_mods and read output into an array
89
133
IFS=$' \n ' read -rd ' ' -a modList < <( extract_mods)
@@ -105,6 +149,7 @@ main() {
105
149
echo -e " \033[0;32m✅ ${name} ${latest_release} \033[0m"
106
150
else
107
151
echo -e " \033[0;33m📦 ${name} update available ${version} > ${latest_release} ${url} \033[0m"
152
+ download_and_extract_latest_release " $url "
108
153
fi
109
154
elif [ -n " $last_updated " ]; then
110
155
echo -e " \033[1;30m🔍 ${name} ${version} - Last updated ${last_updated} ${url} \033[0m"
0 commit comments