fix: alternative route of getting latest Gitea version

Use a code.forgejo.org mirror instead of the GitHub API to not be
subject to rate limiting.
This commit is contained in:
Earl Warren 2025-03-21 23:50:30 +01:00
parent 8464d5cdef
commit 53375283d4
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 44 additions and 2 deletions

View file

@ -141,13 +141,15 @@ function download_forgejo() {
fi
}
: ${GITEA_AUTHORIZATION_HEADER:=}
function download_gitea() {
local version=$1
if ! test -f $DIR_BINARIES/gitea-$version; then
mkdir -p $DIR_BINARIES
if [[ $version =~ ^[0-9]+\.[0-9]+$ ]]; then
full_version=$(curl -sS "https://api.github.com/repos/go-gitea/gitea/releases?per_page=100" | jq -r '.[] | .tag_name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1)
full_version=$(curl -sS -H "$GITEA_AUTHORIZATION_HEADER" "https://code.forgejo.org/api/v1/repos/gitea/gitea/tags" | jq -r '.[] | .name | select(startswith("v'$version'"))' | grep -v -e '-rc' | sort --reverse --version-sort | head -1)
full_version=${full_version#v}
else
full_version=$version