ci(release): authenticate Forgejo API with HTTP Basic

Bearer is rejected on this instance (403/1010). Use sirius + token, matching
the dispatch path that actually works.
This commit is contained in:
agent 2026-09-13 15:27:57 -04:00
commit dc52df2366
No known key found for this signature in database
3 changed files with 11 additions and 11 deletions

View file

@ -124,7 +124,7 @@ jobs:
join=0 join=0
if [ -n "${FORGEJO_TOKEN:-}" ]; then if [ -n "${FORGEJO_TOKEN:-}" ]; then
http=$(curl -sS --http1.1 -o /tmp/latest-rel.json -w '%{http_code}' \ http=$(curl -sS --http1.1 -o /tmp/latest-rel.json -w '%{http_code}' \
-H "Authorization: Bearer $FORGEJO_TOKEN" \ -u "sirius:${FORGEJO_TOKEN}" \
"$REPO_API/releases/tags/$latest" || true) "$REPO_API/releases/tags/$latest" || true)
if [ "$http" != "200" ]; then if [ "$http" != "200" ]; then
join=1 join=1
@ -427,7 +427,7 @@ jobs:
i=0 i=0
while [ "$i" -lt 6 ]; do while [ "$i" -lt 6 ]; do
code=$(curl -sS --http1.1 -o /tmp/tag.json -w '%{http_code}' \ code=$(curl -sS --http1.1 -o /tmp/tag.json -w '%{http_code}' \
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -u "sirius:${FORGEJO_TOKEN}" \
"$REPO_API/tags/$TAG" || true) "$REPO_API/tags/$TAG" || true)
if [ "$code" = "200" ]; then if [ "$code" = "200" ]; then
tag_exists=1 tag_exists=1

View file

@ -86,7 +86,7 @@ jobs:
api_curl() { api_curl() {
curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \ curl -sS --http1.1 --retry 5 --retry-all-errors --retry-delay 3 \
--connect-timeout 20 --max-time 60 \ --connect-timeout 20 --max-time 60 \
-H "Authorization: Bearer $FORGEJO_TOKEN" "$@" -u "sirius:${FORGEJO_TOKEN}" "$@" | sed 's/\r$//'
} }
input_tag="${INPUT_TAG:-}" input_tag="${INPUT_TAG:-}"
@ -430,19 +430,19 @@ jobs:
FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n') FORGEJO_TOKEN=$(printf '%s' "$FORGEJO_TOKEN" | tr -d '\r\n')
echo "fail-closed: removing tag $TAG created by this run" echo "fail-closed: removing tag $TAG created by this run"
code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \ code=$(curl -sS --http1.1 -o /tmp/rel.json -w '%{http_code}' \
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -u "sirius:${FORGEJO_TOKEN}" \
"$REPO_API/releases/tags/$TAG") "$REPO_API/releases/tags/$TAG")
if [ "$code" = "200" ]; then if [ "$code" = "200" ]; then
rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])") rid=$(python3 -c "import json; print(json.load(open('/tmp/rel.json'))['id'])")
echo "deleting incomplete release id $rid" echo "deleting incomplete release id $rid"
curl -sS --http1.1 -X DELETE \ curl -sS --http1.1 -X DELETE \
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -u "sirius:${FORGEJO_TOKEN}" \
"$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n" "$REPO_API/releases/$rid" -o /dev/null -w "DELETE release HTTP %{http_code}\n"
else else
echo "no release for $TAG (HTTP $code)" echo "no release for $TAG (HTTP $code)"
fi fi
del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \ del=$(curl -sS --http1.1 -o /tmp/tag-del.json -w '%{http_code}' -X DELETE \
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -u "sirius:${FORGEJO_TOKEN}" \
"$REPO_API/tags/$TAG") "$REPO_API/tags/$TAG")
echo "DELETE tag HTTP $del" echo "DELETE tag HTTP $del"
if [ "$del" != "204" ] && [ "$del" != "404" ]; then if [ "$del" != "204" ] && [ "$del" != "404" ]; then

View file

@ -21,7 +21,7 @@ api_curl() {
} }
auth_json() { auth_json() {
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" -H "Content-Type: application/json" "$@" api_curl -u "sirius:${FORGEJO_TOKEN}" -H "Content-Type: application/json" "$@"
} }
tag="${1:?usage: publish-release.sh <tag> <name> <body-file> <asset>...}" tag="${1:?usage: publish-release.sh <tag> <name> <body-file> <asset>...}"
@ -109,7 +109,7 @@ for f in "$@"; do
fi fi
asset=$(basename "$f") asset=$(basename "$f")
echo "publish: asset $asset is $bytes bytes on disk" echo "publish: asset $asset is $bytes bytes on disk"
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \ api_curl -u "sirius:${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \
| python3 -c " | python3 -c "
import json,sys import json,sys
for a in json.load(sys.stdin): for a in json.load(sys.stdin):
@ -118,7 +118,7 @@ for a in json.load(sys.stdin):
if [ "$aname" = "$asset" ]; then if [ "$aname" = "$asset" ]; then
echo "publish: deleting stale asset $aname ($aid)" echo "publish: deleting stale asset $aname ($aid)"
del=$(api_curl -o /tmp/release-adel.json -w '%{http_code}' \ del=$(api_curl -o /tmp/release-adel.json -w '%{http_code}' \
-X DELETE -H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -X DELETE -u "sirius:${FORGEJO_TOKEN}" \
"$api/releases/$rid/assets/$aid") "$api/releases/$rid/assets/$aid")
if [ "$del" != "204" ] && [ "$del" != "404" ]; then if [ "$del" != "204" ] && [ "$del" != "404" ]; then
die_http "DELETE asset $aid" "$del" /tmp/release-adel.json die_http "DELETE asset $aid" "$del" /tmp/release-adel.json
@ -127,7 +127,7 @@ for a in json.load(sys.stdin):
done done
up=$(api_curl -o /tmp/release-asset.json -w '%{http_code}' \ up=$(api_curl -o /tmp/release-asset.json -w '%{http_code}' \
-X POST "$api/releases/$rid/assets?name=$asset" \ -X POST "$api/releases/$rid/assets?name=$asset" \
-H "Authorization: Bearer ${FORGEJO_TOKEN}" \ -u "sirius:${FORGEJO_TOKEN}" \
-F "attachment=@$f") -F "attachment=@$f")
if [ "$up" != "201" ]; then if [ "$up" != "201" ]; then
die_http "upload $asset" "$up" /tmp/release-asset.json die_http "upload $asset" "$up" /tmp/release-asset.json
@ -142,7 +142,7 @@ if not size:
" "
done done
api_curl -H "Authorization: Bearer ${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \ api_curl -u "sirius:${FORGEJO_TOKEN}" "$api/releases/$rid/assets" \
| python3 -c " | python3 -c "
import json,sys import json,sys
for a in json.load(sys.stdin): for a in json.load(sys.stdin):