Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: preserve upload order #500

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The following are optional as `step.with` keys
| `body_path` | String | Path to load text communicating notable changes in this release |
| `draft` | Boolean | Indicator of whether or not this release is a draft |
| `prerelease` | Boolean | Indicator of whether or not is a prerelease |
| `preserve_order` | Boolean | Indicator of whether order of files should be preserved when uploading assets |
| `files` | String | Newline-delimited globs of paths to assets to upload for release |
| `name` | String | Name of the release. defaults to tag name |
| `tag_name` | String | Name of a tag. defaults to `github.ref` |
Expand Down
37 changes: 22 additions & 15 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down
Loading