#!/usr/bin/env bash repo="thelounge/thelounge-deb" api=$(curl --silent "https://api.github.com/repos/$repo/releases/latest") new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")') current=$(reprepro -b /var/www/repos/apt/debian list stable thelounge | head -n1 | awk '{print substr($3,1,length($3))}') if [ "$current" != "$new" ]; then SUFFIX="deb" deb_url=$(echo $api | python3 -c "import sys; from json import loads as l; x = l(sys.stdin.read()); print(''.join(s['browser_download_url'] for s in x['assets'] if s['name'].endswith('.$SUFFIX')))") echo "New thelounge STABLE version $current -> $new" path="/tmp/thelounge.deb" wget -q $deb_url -O $path reprepro -b /var/www/repos/apt/debian includedeb stable $path reprepro -b /var/www/repos/apt/debian includedeb oldstable $path rm $path fi ## thelounge beta repo="thelounge/thelounge-deb" api=$(curl -s https://api.github.com/repos/$repo/releases | jq ".[0]") new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")') current=$(reprepro -b /var/www/repos/apt/debian list testing thelounge | head -n1 | awk '{print substr($3,1,length($3))}') if [ "$current" != "${new/\-/\~}" ]; then SUFFIX="deb" deb_url=$(echo $api | python3 -c "import sys; from json import loads as l; x = l(sys.stdin.read()); print(''.join(s['browser_download_url'] for s in x['assets'] if s['name'].endswith('.$SUFFIX')))") echo "New thelounge BETA version $current -> $new" path="/tmp/thelounge.deb" wget -q $deb_url -O $path reprepro -b /var/www/repos/apt/debian includedeb sid $path rm $path fi