mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-05-10 18:44:19 +00:00
feature: preserve upload order (#500)
* Preserve upload order * Update README.md * Fix typings and add a test * fmt code Signed-off-by: Rui Chen <rui@chenrui.dev> --------- Signed-off-by: Rui Chen <rui@chenrui.dev> Co-authored-by: Richard Davison <ridaviso@amazon.com> Co-authored-by: Rui Chen <rui@chenrui.dev>
This commit is contained in:
parent
98daca21d1
commit
d5f028c822
5 changed files with 43 additions and 15 deletions
37
src/main.ts
37
src/main.ts
|
@ -73,21 +73,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.input_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}`);
|
||||
|
|
|
@ -13,6 +13,7 @@ export interface Config {
|
|||
input_body_path?: string;
|
||||
input_files?: string[];
|
||||
input_draft?: boolean;
|
||||
input_preserve_order?: boolean;
|
||||
input_prerelease?: boolean;
|
||||
input_fail_on_unmatched_files?: boolean;
|
||||
input_target_commitish?: string;
|
||||
|
@ -62,6 +63,9 @@ export const parseConfig = (env: Env): Config => {
|
|||
input_body_path: env.INPUT_BODY_PATH,
|
||||
input_files: parseInputFiles(env.INPUT_FILES || ""),
|
||||
input_draft: env.INPUT_DRAFT ? env.INPUT_DRAFT === "true" : undefined,
|
||||
input_preserve_order: env.INPUT_PRESERVE_ORDER
|
||||
? env.INPUT_PRESERVE_ORDER == "true"
|
||||
: undefined,
|
||||
input_prerelease: env.INPUT_PRERELEASE
|
||||
? env.INPUT_PRERELEASE == "true"
|
||||
: undefined,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue