fix: the release script checks its token on the repository
All checks were successful
CI / check (push) Successful in 9m36s
CI / deploy (push) Successful in 15s

It asked Forgejo for the token's user, which needs the scope read:user;
the token the script asks for only has write:repository, so the check
would have refused a token that works. It now reads the repository
itself, which that scope covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-05 21:47:03 +02:00
commit b60752feff
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -196,8 +196,9 @@ forgejo_api() {
curl --fail-with-body --silent --show-error \
--config <(printf 'header = "Authorization: token %s"\n' "$token") "$@"
}
forgejo_api --output /dev/null "$forgejo/api/v1/user" ||
fail "$forgejo doesn't take the token."
# The token's scope, write:repository, covers the repository, not the account.
forgejo_api --output /dev/null "$forgejo/api/v1/repos/$repository" ||
fail "$forgejo doesn't take the token for $repository."
[ "$(forgejo_api --output /dev/null --write-out '%{http_code}' \
"$forgejo/api/v1/repos/$repository/releases/tags/$tag" 2>/dev/null || true)" = 404 ] ||
fail "A release of $tag exists already on $forgejo. If only publishing it in the" \