github_latest_release.sh (883B)
1 #!/usr/bin/env bash 2 3 site="$1" 4 user_name="$2" 5 repo_name="$3" 6 7 if [[ "$site" == "github" ]] || [[ "$site" == "gh" ]]; then 8 latest_tag=$(curl -w "%{redirect_url}" https://github.com/${user_name}/${repo_name}/releases/latest/ | sed 's/.*\///g') 9 echo https://github.com/${user_name}/${repo_name}/archive/refs/tags/${latest_tag}.zip 10 elif [[ "$site" == "codeberg" ]] || [[ "$site" == "cb" ]]; then 11 latest_tag=$(curl -w "%{redirect_url}" https://codeberg.org/${user_name}/${repo_name}/releases/latest/ | sed -nE 's/.*tag\/([^"]*)">.*/\1/p') 12 echo https://codeberg.org/${user_name}/${repo_name}/archive/${latest_tag}.zip 13 elif [[ "$site" == "sourcehut" ]] || [[ "$site" == "srht" ]]; then 14 latest_tag=$(curl "https://git.sr.ht/${user_name}/${repo_name}" | grep "/refs/" | cut -d "/" -f 5 | cut -d "\"" -f 1) 15 echo "https://git.sr.ht/${user_name}/${repo_name}/archive/${latest_tag}.zip" 16 fi