action-gh-release
action-gh-release copied to clipboard
Document how to upload-only to an already existing release
Hi,
I am trying to migrate from https://github.com/actions/upload-release-asset as I see it id discontinued and suggest to use this project instead.
But the github release is created by another tool (release-please), and I only need to upload assets.
Is that possible? May I upload assets for a release that is already created?
Have you tried experimenting with this yet. it might just work. this pull attempts to find a release for a ref, and create one off one doesn't exist so that you can rerun a release job if it fails.
I'm wondering if this this would just working given the other action is creating the releases.
I'm not sure about disabling release creation in this action since creating releases is its primary focus.
After some trial and errors I finally managed to make it work. Here is how to do:
action-gh-releasemust run on a different workflow reacting on tag push- If running in the same workflow that creates the release it fails with:
Error: ⚠️ GitHub Releases requires a tag
- If running in the same workflow that creates the release it fails with:
- the workflow that creates the tag must use a personal github token (not the
GITHUB_TOKENthat is available by default in secrets)- Otherwise github prevents the tag created by a workflow to trigger another workflow
So I guess it only needs to be documented?
Though It'd be nice if it could run in the same workflow that creates the github release.
I found a better way! If we have access to the tag of the existing release (release-please has a tag_name output), then we can simply give that as an input to action-gh-release, and it works perfectly fine.
Here's an (over-simplified) example:
name: release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create the release
uses: google-github-actions/[email protected]
id: release
with:
release-type: rust
- name: build artifacts
if: steps.release.outputs.release_created
run: cargo build --release
- name: upload artifacts
uses: softprops/action-gh-release@v1
if: steps.release.outputs.release_created
with:
tag_name: ${{ steps.release.outputs.tag_name }} # <-- The solution
files: target/release/my-app
I renamed this issue as a request for documentation
tag_name: ${{ github.ref_name }} should be enough, so that you can get rid of depending on google-github-actions/release-please-action.