Skip to content

Commit e7f5f1f

Browse files
committed
fix-release-asset-name-verification
1 parent d5ddbe2 commit e7f5f1f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,14 @@ jobs:
175175
# has already gone through.
176176
while IFS= read -r -d '' f; do
177177
name=$(basename "$f")
178+
# GitHub normalizes spaces in uploaded asset names to periods.
179+
# Query and delete by the server-side name while continuing to
180+
# upload the original local path.
181+
remote_name=${name// /.}
178182
local_size=$(stat -c%s "$f")
179183
uploaded=0
180184
for attempt in 1 2 3 4; do
181-
remote_size=$(remote_size_of "$name")
185+
remote_size=$(remote_size_of "$remote_name")
182186
if [ -n "$remote_size" ] && [ "$remote_size" = "$local_size" ]; then
183187
echo "Asset '$name' already present with the correct size ($local_size bytes)."
184188
uploaded=1
@@ -191,12 +195,12 @@ jobs:
191195
# Only clean up a ghost/partial entry once we know one exists —
192196
# never delete-then-fail-to-replace on the very first attempt.
193197
if [ -n "$remote_size" ]; then
194-
gh release delete-asset "${{ github.ref_name }}" "$name" --repo "${{ github.repository }}" --yes 2>/dev/null || true
198+
gh release delete-asset "${{ github.ref_name }}" "$remote_name" --repo "${{ github.repository }}" --yes 2>/dev/null || true
195199
fi
196200
fi
197201
gh release upload "${{ github.ref_name }}" "$f" --repo "${{ github.repository }}" --clobber || true
198202
done
199-
remote_size=$(remote_size_of "$name")
203+
remote_size=$(remote_size_of "$remote_name")
200204
if [ -z "$remote_size" ] || [ "$remote_size" != "$local_size" ]; then
201205
echo "::error::Asset '$name' still missing or wrong size after 4 attempts (local: ${local_size}, remote: ${remote_size:-none})."
202206
overall_missing=1

0 commit comments

Comments
 (0)