From a3c39a2069c648891f0e8a838bd2f4a910828186 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Mar 2026 05:53:57 -0700 Subject: [PATCH] Fix release upload: use streaming upload and handle spaces in filenames - Use curl -T (streaming) instead of --data-binary (loads into memory) to handle large .deb/.AppImage files - URL-encode spaces in filenames for the Gitea API - Use IFS= read -r to handle filenames with spaces - Add HTTP status code logging for upload debugging Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/build-linux.yml | 17 ++++++++++++----- .gitea/workflows/build-macos.yml | 12 +++++++----- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/build-linux.yml b/.gitea/workflows/build-linux.yml index b5506bd..3d2a0ba 100644 --- a/.gitea/workflows/build-linux.yml +++ b/.gitea/workflows/build-linux.yml @@ -135,9 +135,11 @@ jobs: fi # Upload artifacts (delete existing ones with same name first) - find artifacts/ -type f \( -name "*.deb" -o -name "*.AppImage" \) | while read file; do + find artifacts/ -type f \( -name "*.deb" -o -name "*.AppImage" \) | while IFS= read -r file; do filename=$(basename "$file") - echo "Uploading ${filename}..." + # URL-encode spaces in filename for the API + encoded_name=$(echo "$filename" | sed 's/ /%20/g') + echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..." # Delete existing asset with same name ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ @@ -147,9 +149,14 @@ jobs: "${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}" fi - curl -s -X POST \ + # Upload using -T for streaming (avoids loading entire file into memory) + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ -H "Authorization: token ${BUILD_TOKEN}" \ -H "Content-Type: application/octet-stream" \ - --data-binary "@${file}" \ - "${REPO_API}/releases/${RELEASE_ID}/assets?name=${filename}" + -T "$file" \ + "${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}") + echo "Upload response: HTTP ${HTTP_CODE}" + if [ "$HTTP_CODE" -ge 400 ]; then + echo "WARNING: Upload failed for ${filename}" + fi done diff --git a/.gitea/workflows/build-macos.yml b/.gitea/workflows/build-macos.yml index 328fdf2..d1b0d8e 100644 --- a/.gitea/workflows/build-macos.yml +++ b/.gitea/workflows/build-macos.yml @@ -128,9 +128,10 @@ jobs: exit 1 fi - find artifacts/ -type f -name "*.dmg" | while read file; do + find artifacts/ -type f -name "*.dmg" | while IFS= read -r file; do filename=$(basename "$file") - echo "Uploading ${filename}..." + encoded_name=$(echo "$filename" | sed 's/ /%20/g') + echo "Uploading ${filename} ($(du -h "$file" | cut -f1))..." ASSET_ID=$(curl -s -H "Authorization: token ${BUILD_TOKEN}" \ "${REPO_API}/releases/${RELEASE_ID}/assets" | jq -r ".[] | select(.name == \"${filename}\") | .id // empty") @@ -139,9 +140,10 @@ jobs: "${REPO_API}/releases/${RELEASE_ID}/assets/${ASSET_ID}" fi - curl -s -X POST \ + HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST \ -H "Authorization: token ${BUILD_TOKEN}" \ -H "Content-Type: application/octet-stream" \ - --data-binary "@${file}" \ - "${REPO_API}/releases/${RELEASE_ID}/assets?name=${filename}" + -T "$file" \ + "${REPO_API}/releases/${RELEASE_ID}/assets?name=${encoded_name}") + echo "Upload response: HTTP ${HTTP_CODE}" done