Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How to upload a file to an existing draft release? #323

Open
eregon opened this issue Feb 9, 2023 · 2 comments
Open

How to upload a file to an existing draft release? #323

eregon opened this issue Feb 9, 2023 · 2 comments

Comments

@eregon
Copy link

eregon commented Feb 9, 2023

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.

@matyalatte
Copy link

matyalatte commented Feb 16, 2023

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

@eregon
Copy link
Author

eregon commented Feb 16, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants