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

Cannot upload assets for release which is being undefined #6

Open
liudonghua123 opened this issue Mar 17, 2020 · 10 comments
Open

Cannot upload assets for release which is being undefined #6

liudonghua123 opened this issue Mar 17, 2020 · 10 comments

Comments

@liudonghua123
Copy link

I have a step like this:

      - uses: AButler/upload-release-assets@v2.0
        with:
          files: '/home/runner/work/github_actions/github_actions/dart-sdk-linux.tar.gz;/home/runner/work/github_actions/github_actions/depot_tools.tar.gz'
          repo-token: ${{ secrets.GITHUB_TOKEN }}

But I got the following error.

 Run AButler/upload-release-assets@v2.01s
##[warning]Cannot upload assets for release which is being undefined
Run AButler/upload-release-assets@v2.0
  with:
    files: /home/runner/work/github_actions/github_actions/dart-sdk-linux.tar.gz;/home/runner/work/github_actions/github_actions/depot_tools.tar.gz
    repo-token: ***
##[warning]Cannot upload assets for release which is being undefined

I can confirm that I pushed a tag instead of a master commit.

@AButler
Copy link
Owner

AButler commented Mar 26, 2020

The action is mainly set up for creating a GitHub release (which creates a tag) rather than on tag creation. Are you creating a GitHub release in a previous step?

@liudonghua123
Copy link
Author

@AButler I did not create release in previous step.

@AButler
Copy link
Owner

AButler commented Mar 26, 2020

Ah ok, thanks for the clarification. Currently this action only uploads assets to a release that already exists. I'll take a look at whether it makes sense to create a release if one does not exist already.

@mristin
Copy link

mristin commented Aug 14, 2020

Hi @AButler ,
I'd like to confirm that I observe the same warning / error message (please see https://github.com/admin-shell-io/aasx-package-explorer/runs/986244151?check_suite_focus=true).

The release already exists and the action is triggered afterwards:

on:
  push:
    tags:
      - 'v*'

According to the documentation, the action should be there in github.context.payload:
https://developer.github.com/webhooks/event-payloads/#webhook-payload-object-common-properties

Maybe you can output the whole github.context.payload in case github.context.payload is null or undefined to facilitate bug reports?

@icemarkom
Copy link

Similar to @mristin, I just hit this in the workflow that had a release created from a tag. At the time this step was running, release existed.

@Ogerets
Copy link

Ogerets commented Jul 26, 2022

same issue here

@D4VOS
Copy link

D4VOS commented Aug 26, 2022

same issue in my project

@davidrunger
Copy link

davidrunger commented Nov 5, 2022

I'm chiming in here in case it helps others. I was getting this error and then fixed it by using the release-tag option.

Here's how I am using this GitHub Action:

  1. create a release manually through the GitHub web app; choose in the GitHub web app when doing so to have GitHub create a git tag for the release.
  2. then, one of my Actions workflows is triggered by the creation of the release tag. That workflow builds release assets, which are uploaded using this action to the release that I just manually created.

I initially was getting this error

 Warning: Cannot upload assets for release which is being undefined

I fixed the error by adding the release-tag option for this GitHub Action:

- name: Release
  uses: AButler/upload-release-assets@v2.0
  with:
    files: skedjewel-${{  github.ref_name }}-linux
    repo-token: ${{ secrets.GITHUB_TOKEN }}
    release-tag: ${{  github.ref_name }}

The value of ${{ github.ref_name }} there is apparently the release tag. That might only be because of how the action is triggered; I'm not sure. Here's how the action is triggered:

on:
  push:
    tags:
      - "v*.*.*"

Now my release assets are uploading successfully. 👍

For reference, click here to see my full GitHub Action workflow

Link: https://github.com/davidrunger/skedjewel/blob/v0.0.6/.github/workflows/release.yml

name: Release

on:
  push:
    tags:
      - "v*.*.*"

jobs:
  build_and_upload_linux_binary:
    runs-on: ubuntu-latest
    container:
      image: crystallang/crystal:latest-alpine
    steps:
      - uses: actions/checkout@v3
      - name: Build
        run: shards build --production --release --no-debug --static
      - name: Check version matches tag
        run: "[[ \"v$(bin/skedjewel --version)\" == ${{  github.ref_name }} ]] || exit 1"
      - name: Move and rename
        run: mv bin/skedjewel ./skedjewel-${{  github.ref_name }}-linux
      - name: Release
        uses: AButler/upload-release-assets@v2.0
        with:
          files: skedjewel-${{  github.ref_name }}-linux
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          release-tag: ${{  github.ref_name }}

  build_and_upload_macos_binary:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install Crystal
        uses: crystal-lang/install-crystal@v1
      - name: Build
        run: shards build --production --release --no-debug
      - name: Check version matches tag
        run: "[[ \"v$(bin/skedjewel --version)\" == ${{  github.ref_name }} ]] || exit 1"
      - name: Move and rename
        run: mv bin/skedjewel ./skedjewel-${{  github.ref_name }}-darwin
      - name: Release
        uses: AButler/upload-release-assets@v2.0
        with:
          files: skedjewel-${{  github.ref_name }}-darwin
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          release-tag: ${{  github.ref_name }}

@anzz1
Copy link

anzz1 commented Mar 19, 2023

I'm having the same problem, is there any action available which would work just like the original upload-release-asset action where you can specify an upload_url instead of tag. Basically an action which allows for multiple files and does not remove any other functionality. I've found many so far but none that actually works like the original.

@anzz1
Copy link

anzz1 commented Mar 19, 2023

Thanks to this comment
I've found a working solution:

    - name: Create release
      id: create_release
      uses: zendesk/action-create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_schema: semantic
        prerelease: true
        auto_increment_type: prerelease

    - name: Upload release
      id: upload_release
      uses: actions/github-script@v3
      with:
        github-token: ${{secrets.GITHUB_TOKEN}}
        script: |
          const path = require('path');
          const fs = require('fs');
          const release_id = '${{ steps.create_release.outputs.id }}';
          for (let file of await fs.readdirSync('./')) {
           if (path.extname(file) === '.zip') {
              console.log('uploadReleaseAsset', file);
              await github.repos.uploadReleaseAsset({
                owner: context.repo.owner,
                repo: context.repo.repo,
                release_id: release_id,
                name: file,
                data: await fs.readFileSync(`./${file}`)
              });
            }
          }

It's not perfect as you still need to write a script and still can't use upload_url but at least you can use release_id so it works with prereleases and everything.

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

8 participants