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

Artifacts are uploaded after the GH Release published event is triggered #501

Open
carlosperate opened this issue Feb 19, 2025 · 3 comments

Comments

@carlosperate
Copy link

carlosperate commented Feb 19, 2025

When creating a GH Release with files to upload as artifacts, the GH Release is published before the file uploads are done.

This means that any workflow triggered from a GH Release being "published", will start running before all the artifacts are availble in the release.

on:
  release:
    types: published

jobs:
  download-release-artifacts:
    runs-on: ubuntu-latest
    steps:
      - name: Set the GH Release tag to step output
        id: get_tag
        shell: bash
        run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
      # At this point the GH release artifacts might not have been completely uploaded by ncipollo/release-action
      - name: Download GH Release artifacts
        shell: bash
        run: gh release download ${{ steps.get_tag.outputs.tag }} --repo ${{ github.server_url }}/${{ github.repository }}
        env:
          GH_TOKEN: ${{ github.token }}
@ncipollo
Copy link
Owner

The release need to exist before you can upload assets to it. See https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset

You can maybe try creating a draft release (not sure if that triggers the publish event or not, if it does you could maybe filter out draft releases).

@carlosperate
Copy link
Author

For a workaround I'll likely just add a hacky wait/delay in my project.
Would it make sense for this action to create first a draft release, to be able to add the artifacts, and then publish it?
I guess there might be more events fired at that point, so not sure if that's better or worse for the default behaviour.

@ncipollo
Copy link
Owner

Yeah I'd be worried that would generate more events, and is even less atomic than it is now (if something breaks in the middle of that users would be left with a seemingly random draft release).

I think you can achieve something similar though by chaining two release actions together, the first is a draft with artifacts, the second updates it to non-draft.

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