fix(release): refuse to publish 0-byte assets + log on-disk sizes
Some checks failed
ci / test (push) Has been cancelled
Some checks failed
ci / test (push) Has been cancelled
Run 309 reported success but uploaded 0 bytes for both aarch64 assets (a 0.85s 'upload' of an 18MB file). The Pack step had just listed 18258736 bytes and sha256sum -c'd OK, so the failure is in the handoff, not the build. - publish-release.sh now fails loudly on a 0-byte asset instead of publishing a release that silently breaks every download - the workflow logs pwd, GITHUB_WORKSPACE, ls -l dist/ and the byte count of each dist file immediately before publishing Ruled out: the api_curl retry wrapper. Reproduced from inside a node:20-bullseye container (curl 7.74, same as CI) — wrapper and plain curl both uploaded 994 bytes correctly through Cloudflare.
This commit is contained in:
parent
c9d85d9ae5
commit
ef78be4035
2 changed files with 11 additions and 0 deletions
|
|
@ -98,6 +98,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd "${GITHUB_WORKSPACE}"
|
cd "${GITHUB_WORKSPACE}"
|
||||||
|
echo "pwd=$PWD workspace=$GITHUB_WORKSPACE"
|
||||||
|
ls -l dist/ 2>&1 || true
|
||||||
|
for f in dist/*; do printf 'on disk: %s %s bytes\n' "$f" "$(wc -c < "$f")"; done
|
||||||
tag="${INPUT_TAG:-$REF}"
|
tag="${INPUT_TAG:-$REF}"
|
||||||
# Only a tag push may create the tag; a re-publish must not move it.
|
# Only a tag push may create the tag; a re-publish must not move it.
|
||||||
if [ "$EVENT_NAME" = "push" ]; then export TARGET_COMMITISH="$EVENT_SHA"; fi
|
if [ "$EVENT_NAME" = "push" ]; then export TARGET_COMMITISH="$EVENT_SHA"; fi
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,15 @@ echo "publish: release id $rid ($tag)"
|
||||||
# Replace same-named assets so re-runs are clean.
|
# Replace same-named assets so re-runs are clean.
|
||||||
for f in "$@"; do
|
for f in "$@"; do
|
||||||
[ -f "$f" ] || { echo "publish: missing asset $f" >&2; exit 1; }
|
[ -f "$f" ] || { echo "publish: missing asset $f" >&2; exit 1; }
|
||||||
|
# Never publish an empty asset: a 0-byte binary/checksum looks like a
|
||||||
|
# successful release and silently breaks everyone who downloads it.
|
||||||
|
bytes=$(wc -c < "$f")
|
||||||
|
if [ "$bytes" -eq 0 ]; then
|
||||||
|
echo "publish: refusing to upload empty asset $f (0 bytes, cwd=$PWD)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
asset=$(basename "$f")
|
asset=$(basename "$f")
|
||||||
|
echo "publish: asset $asset is $bytes bytes on disk"
|
||||||
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
api_curl -s -H "Authorization: Bearer $FORGEJO_TOKEN" "$api/releases/$rid/assets" \
|
||||||
| python3 -c "
|
| python3 -c "
|
||||||
import json,sys
|
import json,sys
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue