Fix release asset updates
This commit is contained in:
@@ -78,7 +78,26 @@ jobs:
|
||||
REPOSITORY: ${{ gitea.repository }}
|
||||
run: |
|
||||
set -eu
|
||||
upload_url="${SERVER_URL%/}/api/v1/repos/$REPOSITORY/releases/$RELEASE_ID/assets"
|
||||
release_url="${SERVER_URL%/}/api/v1/repos/$REPOSITORY/releases/$RELEASE_ID"
|
||||
upload_url="$release_url/assets"
|
||||
release_json="$(curl -fsS -H "Authorization: token $GITEA_TOKEN" "$release_url")"
|
||||
|
||||
delete_asset_if_exists() {
|
||||
asset_name="$1"
|
||||
asset_id="$(printf '%s' "$release_json" \
|
||||
| tr '{' '\n' \
|
||||
| grep "\"name\":\"$asset_name\"" \
|
||||
| sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' \
|
||||
| head -n 1)"
|
||||
if [ -n "$asset_id" ]; then
|
||||
curl -fsS -X DELETE "$upload_url/$asset_id" \
|
||||
-H "Authorization: token $GITEA_TOKEN"
|
||||
fi
|
||||
}
|
||||
|
||||
delete_asset_if_exists "$RELEASE_ARCHIVE"
|
||||
delete_asset_if_exists "$RELEASE_SHA256"
|
||||
|
||||
curl -fsS -X POST "$upload_url?name=$RELEASE_ARCHIVE" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
-F "attachment=@$RELEASE_ARCHIVE"
|
||||
|
||||
Reference in New Issue
Block a user