From ccab9b0e84ed80e5c928a4272f7b4d39ae58408b Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:02:01 +0000 Subject: [PATCH] Remove stale assets --- .github/actions/github-release/main.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/actions/github-release/main.js b/.github/actions/github-release/main.js index d7548b95f03..5f756aed3ee 100644 --- a/.github/actions/github-release/main.js +++ b/.github/actions/github-release/main.js @@ -108,20 +108,20 @@ async function runOnce() { } console.log("found release: ", JSON.stringify(release.data, null, 2)); + // Delete all assets from a previous run + for (const asset of release.data.assets) { + console.log(`deleting prior asset ${asset.id}`); + await octokit.rest.repos.deleteReleaseAsset({ + owner, + repo, + asset_id: asset.id, + }); + } + // Upload all the relevant assets for this release as just general blobs. for (const file of glob.sync(files)) { const size = fs.statSync(file).size; const name = path.basename(file); - for (const asset of release.data.assets) { - if (asset.name !== name) - continue; - console.log(`deleting prior asset ${asset.id}`); - await octokit.rest.repos.deleteReleaseAsset({ - owner, - repo, - asset_id: asset.id, - }); - } core.info(`upload ${file}`); await octokit.rest.repos.uploadReleaseAsset({ data: fs.createReadStream(file),