dotfiles

regexghost dotfiles and scripts
git clone https://git.regexghost.com/dotfiles.git
Log | Files | Refs | README

github-latest-release.sh (936B)


      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 	# Sometimes this doesn't work due to browser checks
     15 	latest_tag=$(curl "https://git.sr.ht/${user_name}/${repo_name}" | grep "/refs/" | cut -d "/" -f 5 | cut -d "\"" -f 1)
     16 	echo "https://git.sr.ht/${user_name}/${repo_name}/archive/${latest_tag}.zip"
     17 fi