From 1d3c3ef56ac1b54d41027ace39fe8d469b5ffbab Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Mon, 26 Aug 2024 10:10:32 +0200 Subject: [PATCH] Preserve upload order --- src/main.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index 34b2d69..3c3cf21 100644 --- a/src/main.ts +++ b/src/main.ts @@ -74,21 +74,28 @@ async function run() { } } const currentAssets = rel.assets; - const assets = await Promise.all( - files.map(async (path) => { - const json = await upload( - config, - gh, - uploadUrl(rel.upload_url), - path, - currentAssets, - ); - delete json.uploader; - return json; - }), - ).catch((error) => { - throw error; - }); + + const uploadFile = async (path) => { + const json = await upload( + config, + gh, + uploadUrl(rel.upload_url), + path, + currentAssets, + ); + delete json.uploader; + return json; + }; + + let assets; + if (config.preserve_order) { + assets = await Promise.all(files.map(uploadFile)); + } else { + assets = []; + for (const path of files) { + assets.push(await uploadFile(path)); + } + } setOutput("assets", assets); } console.log(`🎉 Release ready at ${rel.html_url}`);