Files
aego/tools/release/upload.sh
T
sanspie a6822156cd
ci-platforms / windows amd64 smoke (push) Skipped
ci / release (push) Successful in 8m58s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci / checks (push) Successful in 4m46s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 13m28s
Finish Stage 12 editor fixes and refreshed platformer
2026-11-05 17:36:42 +03:00

22 lines
909 B
Bash
Executable File

#!/bin/sh
# Attaches builds made elsewhere (e.g. the macOS .dmg) to a Gitea release; requires GITEA_TOKEN and GITEA_API (https://host/api/v1/repos/owner/name).
set -eu
tag=${1:?usage: upload.sh <tag> <file>...}
shift
: "${GITEA_TOKEN:?GITEA_TOKEN is not set}"
: "${GITEA_API:?GITEA_API is not set}"
api() {
method=$1
shift
curl -fsS -m 1800 -X "$method" -H "Authorization: token $GITEA_TOKEN" "$@"
}
id=$(api GET "$GITEA_API/releases/tags/$tag" | sed -n 's/^{"id":\([0-9]*\),.*/\1/p')
[ -n "$id" ] || { echo "upload: no release $tag" >&2; exit 1; }
for f in "$@"; do
n=$(basename "$f")
old=$(api GET "$GITEA_API/releases/$id/assets" | tr '{' '\n' | sed -n "s/^\"id\":\([0-9]*\),\"name\":\"$n\".*/\1/p")
[ -n "$old" ] && api DELETE "$GITEA_API/releases/$id/assets/$old" >/dev/null
api POST "$GITEA_API/releases/$id/assets?name=$n" -F "attachment=@$f" >/dev/null
echo "upload: attached $n to $tag"
done