Skip to content

Commit 1cb154d

Browse files
committed
fix: 恢复 wrangler 上传 R2,跳过超过 290MB 的文件
Cloudflare REST API 也有请求体大小限制 (413)。 改为用 wrangler 上传 <290MB 的文件,超大文件跳过(已在 GitHub Release 中)。 上传失败不中断整个步骤。
1 parent 0887831 commit 1cb154d

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -355,44 +355,52 @@ jobs:
355355
-exec cp {} upload/ \;
356356
ls -lh upload/
357357
358+
- name: Setup Node.js for wrangler
359+
uses: actions/setup-node@v4
360+
with:
361+
node-version: '22'
362+
363+
- name: Install wrangler
364+
run: npm install -g wrangler
365+
358366
- name: Upload files to R2
359367
env:
360368
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
361369
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
362370
run: |
363371
VERSION="${{ needs.resolve-version.outputs.version }}"
364372
PREFIX="openclaw-standalone/${VERSION}"
365-
R2_API="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/r2/buckets/clawpanel-releases/objects"
373+
FAILED=0
366374
for file in upload/*; do
367375
FILENAME=$(basename "$file")
368-
SIZE=$(du -h "$file" | cut -f1)
369-
echo "Uploading $FILENAME ($SIZE) ..."
370-
curl --fail --silent --show-error \
371-
-X PUT "${R2_API}/${PREFIX}/${FILENAME}" \
372-
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
373-
-H "Content-Type: application/octet-stream" \
374-
--data-binary @"$file"
375-
echo " ✓ $FILENAME uploaded"
376+
SIZE_MB=$(( $(stat --format=%s "$file") / 1048576 ))
377+
echo "Uploading $FILENAME (${SIZE_MB}MB) ..."
378+
if [ "$SIZE_MB" -gt 290 ]; then
379+
echo "⚠ Skipping $FILENAME (${SIZE_MB}MB > 290MB wrangler limit, available in GitHub Release)"
380+
continue
381+
fi
382+
if wrangler r2 object put "clawpanel-releases/${PREFIX}/${FILENAME}" --file "$file" --remote; then
383+
echo "✓ $FILENAME uploaded"
384+
else
385+
echo "⚠ Failed to upload $FILENAME, continuing..."
386+
FAILED=$((FAILED + 1))
387+
fi
376388
done
377-
echo "All files uploaded to R2: ${PREFIX}/"
389+
echo "Upload complete (skipped/failed: $FAILED)"
378390
379391
- name: Upload latest.json to R2
380392
env:
381393
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
382394
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
383395
run: |
384396
VERSION="${{ needs.resolve-version.outputs.version }}"
385-
R2_API="https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/r2/buckets/clawpanel-releases/objects"
386397
cat > /tmp/latest.json <<EOF
387398
{
388399
"version": "$VERSION",
389400
"date": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
390401
"base_url": "https://dl.qrj.ai/openclaw-standalone/$VERSION"
391402
}
392403
EOF
393-
curl --fail --silent --show-error \
394-
-X PUT "${R2_API}/openclaw-standalone/latest.json" \
395-
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \
396-
-H "Content-Type: application/json" \
397-
--data-binary @/tmp/latest.json
404+
wrangler r2 object put "clawpanel-releases/openclaw-standalone/latest.json" \
405+
--file /tmp/latest.json --content-type application/json --remote
398406
echo "latest.json updated to version $VERSION"

0 commit comments

Comments
 (0)