#!/usr/bin/env bash repo="cinnyapp/cinny-desktop" 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 cinny-desktop | 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 CINNY-DESKTOP version $current -> $new" path="/tmp/cinny-desktop.deb" wget -q "$deb_url" -O "$path" # TEMPORARY FIX FOR CONTROL FILE MISSING STARTDIR="/tmp/cinny-desktop" DESTDIR="$STARTDIR/pkg" OUTDIR="$STARTDIR/deb" rm -rf "$STARTDIR" mkdir "$STARTDIR" mkdir -p "$DESTDIR/DEBIAN" dpkg-deb -x $path $DESTDIR cat >"$DESTDIR/DEBIAN/control"< Description: Yet another matrix client for desktop Homepage: https://github.com/cinnyapp/cinny-desktop Bugs: https://github.com/cinnyapp/cinny-desktop/issues EOL cat >"$STARTDIR/changelog"< $(date -R) EOL install -Dm 644 "$STARTDIR/changelog" "$DESTDIR/usr/share/doc/cinny-desktop/changelog.Debian" gzip "$DESTDIR/usr/share/doc/cinny-desktop/changelog.Debian" rm -rf "$OUTDIR" mkdir "$OUTDIR" dpkg-deb --build "$DESTDIR" "$OUTDIR" reprepro -b /var/www/repos/apt/debian includedeb stable "$OUTDIR"/*.deb reprepro -b /var/www/repos/apt/debian includedeb oldstable "$OUTDIR"/*.deb rm $path fi