#!/usr/bin/env bash repo="noborus/ov" 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 ov | head -n1 | awk '{print substr($3,1,length($3))}') all_suffix=('amd64.deb' 'arm64.deb' 'arm.deb') if [ "$current" != "$new" ]; then for suffix in "${all_suffix[@]}"; do 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 OV version $current -> $new for $suffix" path="/tmp/ov.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 done fi