action-gh-release
action-gh-release copied to clipboard
How to upload a file to an existing draft release?
I would like to use this action to replace https://github.com/actions/create-release and https://github.com/actions/upload-release-asset, as shown in this example: https://github.com/eregon/publish-release#readme And then publish the release with that action, so the latest release of a repository is always valid and has files from all platforms.
Unfortunately, it doesn't seem possible to add an asset to an existing draft release with this action.
Probably I would need to pass the upload_url
or the release id
so the action could do it, but there seems to be no such input.
I tried several things:
steps:
- name: Create Release
uses: softprops/action-gh-release@v1
id: create_release
with:
tag_name: testtag
draft: true
prerelease: false
body: body
- run: 'echo hello > foo.txt'
- name: Upload Asset
uses: softprops/action-gh-release@v1
with:
tag_name: testtag
files: foo.txt
That creates both a draft release and a non-draft release, which is quite confusing. The output is https://github.com/eregon/setup-ruby-test/actions/runs/4136747251/jobs/7151030394.
steps:
- uses: actions/checkout@v3
- name: Create Release
uses: softprops/action-gh-release@v1
id: create_release
with:
tag_name: testtag3
draft: true
prerelease: false
body: body3
- run: 'echo hello > foo.txt'
- name: Upload Asset
uses: softprops/action-gh-release@v1
with:
tag_name: testtag3
draft: true
files: foo.txt
That creates two draft releases, which is not what is wanted. The output is https://github.com/eregon/setup-ruby-test/actions/runs/4136799053
Could you consider adding this feature?
How do people upload assets built on different platforms? Using https://github.com/actions/upload-artifact maybe? But that's quite verbose and basically uploads things twice (+ extra download), instead of uploading to the release directly.
Hi, I got the same problem while removing the deprecation warnings from my workflows. And my solution was using Github CLI.
You can uplaod files to the release like this.
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload testtag test_archive.zip
I'll put some documents for the details. Using GitHub CLI in workflows - GitHub Docs Manual | GitHub CLI gh release upload | GitHub CLI
Yes, I used the same workaround, to use gh
in https://github.com/ruby/truffleruby-dev-builder/blob/master/.github/workflows/build.yml
It needs some extra things like setting GH_TOKEN/GITHUB_TOKEN and GH_REPO, otherwise it only works with a checkout of the current repo.
It feels less clean than using an action, but it works and hopefully keeps working without much changes needed.