fix release
Release / release (push) Successful in 9s

This commit is contained in:
2026-09-09 10:40:59 +02:00
parent 04e80929f0
commit 0378edf5f8
2 changed files with 183 additions and 1 deletions
+23 -1
View File
@@ -51,12 +51,34 @@ jobs:
api="${GITEA_SERVER_URL%/}/api/v1/repos/${GITEA_REPOSITORY}/releases"
payload=$(jq -n --arg tag "$GITEA_TAG" --arg commit "$GITEA_COMMIT" \
'{tag_name: $tag, name: $tag, target_commitish: $commit, draft: true}')
release=$(curl --fail-with-body --silent --show-error \
response=$(mktemp)
trap 'rm -f "$response"' EXIT
status=$(curl --silent --show-error --output "$response" --write-out '%{http_code}' \
-H "Authorization: token $GITEA_TOKEN" \
-H 'Content-Type: application/json' \
--data "$payload" "$api")
case "$status" in
201) release=$(cat "$response") ;;
409)
tag=$(jq -rn --arg tag "$GITEA_TAG" '$tag | @uri')
if ! release=$(curl --fail-with-body --silent --show-error \
-H "Authorization: token $GITEA_TOKEN" "$api/tags/$tag"); then
printf '%s\n' "$release" >&2
exit 1
fi
;;
*)
cat "$response" >&2
exit 1
;;
esac
id=$(jq -er '.id | select(type == "number" and . > 0)' <<< "$release")
for asset in stanp-opencode.tgz stanp-opencode.tgz.sha256; do
asset_ids=$(jq -r --arg name "$asset" '.assets[]? | select(.name == $name) | .id' <<< "$release")
for asset_id in $asset_ids; do
curl --fail-with-body --silent --show-error --request DELETE \
-H "Authorization: token $GITEA_TOKEN" "$api/$id/assets/$asset_id"
done
curl --fail-with-body --silent --show-error \
-H "Authorization: token $GITEA_TOKEN" \
--form "attachment=@$asset" "$api/$id/assets"