#!/usr/bin/env bash # stable repo="muesli/duf" 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 stable duf | head -n1| awk '{print $3}') all_suffix=('linux_386.deb' 'linux_amd64.deb' 'linux_armv7.deb') path="/tmp/duf.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 duf version $current -> $new" echo $deb_url 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