Skip to content

Commit 58fa4b7

Browse files
authored
Add assets action output (softprops#185)
1 parent b260a9f commit 58fa4b7

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- Add `asset` output as a JSON array containing information about the uploaded assets
2+
13
## 0.1.14
24

35
- provides an new workflow input option `generate_release_notes` which when set to true will automatically generate release notes for you based on GitHub activity [#179](https://github.com/softprops/action-gh-release/pull/179). Please see the [GitHub docs for this feature](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes) for more information

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ The following outputs can be accessed via `${{ steps.<step-id>.outputs }}` from
197197
| `url` | String | Github.com URL for the release |
198198
| `id` | String | Release ID |
199199
| `upload_url` | String | URL for uploading assets to the release |
200+
| `assets` | String | JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/reference/repos#upload-a-release-asset--code-samples) (minus the `uploader` field) |
201+
202+
As an example, you can use `${{ fromJSON(steps.<step-id>.outputs.assets)[0].browser_download_url }}` to get the download URL of the first asset.
200203

201204
#### environment variables
202205

action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ outputs:
5252
description: "Release ID"
5353
upload_url:
5454
description: "URL for uploading assets to the release"
55+
assets:
56+
description: "JSON array containing information about each uploaded asset, in the format given [here](https://docs.github.com/en/rest/reference/repos#upload-a-release-asset--code-samples) (minus the `uploader` field)"
5557
runs:
5658
using: "node12"
5759
main: "dist/index.js"

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,23 @@ async function run() {
6565
if (files.length == 0) {
6666
console.warn(`🤔 ${config.input_files} not include valid file.`);
6767
}
68-
const currentAsserts = rel.assets;
69-
await Promise.all(
68+
const currentAssets = rel.assets;
69+
const assets = await Promise.all(
7070
files.map(async path => {
71-
await upload(
71+
const json = await upload(
7272
config,
7373
gh,
7474
uploadUrl(rel.upload_url),
7575
path,
76-
currentAsserts
76+
currentAssets
7777
);
78+
delete json.uploader;
79+
return json;
7880
})
7981
).catch(error => {
8082
throw error;
8183
});
84+
setOutput("assets", assets);
8285
}
8386
console.log(`🎉 Release ready at ${rel.html_url}`);
8487
setOutput("url", rel.html_url);

0 commit comments

Comments
 (0)