From e86d563ce8608a39ee75fec5a2f2f2a0a523dcec Mon Sep 17 00:00:00 2001 From: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Thu, 11 May 2023 15:57:43 +0800 Subject: [PATCH] Fix: skip uploading empty assets --- src/github.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/github.ts b/src/github.ts index f4a0402..da23b18 100644 --- a/src/github.ts +++ b/src/github.ts @@ -148,6 +148,7 @@ export const upload = async ( const currentAsset = currentAssets.find( ({ name: currentName }) => currentName == name ); + // Delete old asset even if the size of currentAsset is 0 if (currentAsset) { console.log(`♻️ Deleting previously uploaded asset ${name}...`); await github.rest.repos.deleteReleaseAsset({ @@ -156,6 +157,10 @@ export const upload = async ( repo, }); } + if (size === 0) { + console.warn(`❌ Skip uploading release asset ${name} with 0 byte in size`); + return {}; // return empty JSON object for compatibility + } console.log(`⬆️ Uploading ${name}...`); const endpoint = new URL(url); endpoint.searchParams.append("name", name);