Checking for latest release programatically?

Well it does appear that the the version.json has been updated to 1.25.0.

My script, for what it’s worth is included below. It’s definitely not perfect, but it’s good enough for me to run regularly by cron. Not how I’d do this if I was being paid for it, but I’m not, so hopefullyy this can help someone else.

#!/bin/bash
set -e
#LATEST=$(/usr/bin/curl -s https://dl.gitea.io/gitea/ | /bin/grep 'href="/gitea' | /bin/grep -oP "[\d]+\.[\d]+\.[\d]+" | /usr/bin/sort -V | /usr/bin/tail -n1)
#LATEST=$(/usr/bin/curl -s https://dl.gitea.io/gitea/ | /bin/grep 'Current Release' | /bin/grep -oP "[\d]+\.[\d]+\.[\d]+" | /usr/bin/sort -V | /usr/bin/tail -n1)
LATEST=$(/usr/bin/curl -s https://dl.gitea.com/gitea/version.json | /usr/bin/jq .latest.version -Mr)
#LATEST=1.25.0
CURRENT=$(/usr/local/bin/gitea -v | /usr/bin/awk '{print $3}')

if [[ $LATEST != $CURRENT ]]
then
        /usr/bin/wget -O /usr/local/bin/gitea-new https://dl.gitea.io/gitea/$LATEST/gitea-$LATEST-linux-amd64 --quiet --prefer-family=IPv4
        /bin/chmod +x /usr/local/bin/gitea-new
        /usr/sbin/service gitea stop
        /bin/mv /usr/local/bin/gitea /usr/local/bin/gitea-old
        /bin/mv /usr/local/bin/gitea-new /usr/local/bin/gitea
        /usr/sbin/service gitea start
        /bin/rm -f /usr/local/bin/gitea-old
        exit 0
else
        exit 0
fi