-
Notifications
You must be signed in to change notification settings - Fork 190
How to upload multiple assets? #28
Comments
I have the same issue and came across this alternative action: https://github.com/softprops/action-gh-release |
For everybody struggling with this, just add multiple steps:
|
./builds/*.tar.gz would be the beez kneez. 🐝 |
We can easily upload multiple assets at once by using the name: Release
on:
push:
tags: ["v*"]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
set -x
assets=()
for asset in ./*.md; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
What is the hub command and where can I find documentation on it? |
I think that this action should have the possibility to upload multiple files. |
This is how I've solved it using |
@paradajz I don't get it, can you explain me it please? |
I create a new release manually, first, via GitHub releases page. There I list all the changes and general information about the release. The workflow I've linked is run only when there's a new release created. To upload assets to an existing release, I'm using hub cli. The syntax to upload a single asset to existing release is the following:
To add multiple assets to release, syntax would be the following:
The following line in my script will search for all the files matching the pattern I want (in my case, all files ending with .sysex extension) and will append "-a" before the path:
Hope this makes is clearer. |
Using a "custom" way to create a releasing with multiple artifacts following this issue: - actions/upload-release-asset#28 (comment) - https://github.com/hashicorp/terraform-provider-kubernetes-alpha/blob/6a94abdffa085bb3564fc3670979cd223045dd5b/.github/workflows/release_binaries.yaml
@paradajz thanks for the very informative answer. Is there a way to pass those information to the hub command inside a github workflow/action? |
edit: I setup a GITHUB_TOKEN and it worked like a charm. Thanks a billion paradajz. |
Another workaround solution using github-script: - name: Create Release
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const release = await github.repos.createRelease({
owner, repo,
tag_name: process.env.GITHUB_REF,
draft: true,
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('.')) {
// do whatever filtering you want here, I'm just uploading all the files
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./${file}`)
});
} |
Unclear why this is so difficult and why it's even a separate action from |
The solution appears to be to use a third party action: https://github.com/softprops/action-gh-release It's a shame Github Actions doesn't yet support such a basic feature to create (or update) a release and upload a directory of assets in one step. Travis CI has great support for this. |
@amacneil, meanwhile, you might want to write your own script/Action using e.g. PyGitHub. See https://github.com/eine/tip/blob/master/tip.py. |
Thanks for this solution! More information can be found here, these are useful to me particularly:
|
When I've to collect artifacts from different machines (Linux, Windows, Mac) how to archive this ? |
@hannesa2, use a last job which depends on the others, and download the artifacts (without a name arg, it will download all). For example: https://github.com/ghdl/ghdl/blob/master/.github/workflows/Test.yml#L327-L347 |
I have several build artifacts to upload together. What is the correct way to do so?
The text was updated successfully, but these errors were encountered: