actions / upload-release-asset

An Action to upload a release asset via the GitHub Release API
MIT License
683 stars 187 forks source link

##[error]Input required and not supplied: upload_url But I have supplied the option #46

Closed aaronliu0130 closed 4 years ago

aaronliu0130 commented 4 years ago

I am new to github actions, and I have tried uploading a release asset after successful release creation. However, it fails. Here is an excerpt from my actions file:

jobs:
  release:
    name: Create release
    runs-on: ubuntu-latest

    steps:
      - name: Create release
        id: create_release
        uses: actions/create-release@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ join('Release v0.1.0 Last Alpha Commit ',github.sha) }}
          body: |
            We have made some features! A new step to being complete.
          draft: false
          prerelease: true
  buildm:
    name: Build on macOS
    runs-on: macos-latest

    steps:
      - uses: actions/checkout@v2
      - name: build
        run: echo "blablbahb" #Building shenanigans
      - name: upload asset
        id: upload-release-asset
        uses: actions/upload-release-asset@latest
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          asset_path: ./RichmanMA
          asset_name: Richman-For-macOS
          upload_url: ${{ steps.create_release.outputs.upload_url }} #NOTE THIS LINE!

I have tried moving the upload url to top of the with stanza, and it still fails with this log:

Run actions/upload-release-asset@latest
  with:
    asset_path: ./RichmanMA
    asset_name: Richman-For-ubuntu
  env:
    GITHUB_TOKEN: ***
##[error]Input required and not supplied: upload_url

image The entire log is over here if you wish.

kevinlul commented 4 years ago

You can't use job outputs between jobs, only between steps in the same job.

aaronliu0130 commented 4 years ago

I want to upload multiple files from different OSs built in the same job to the same release. How do I do that?

jgstew commented 4 years ago

I'm trying to do the same thing. I was wondering if it was possible to get the upload_url when triggering on this:

on:
  release:
    types: created

Basically, create the release either manually, or in a different action, then have a subsequent action trigger to add files for MacOS, then have a different action trigger to add files for Linux.

or does it somehow need to happen all in one job in one action?

UPDATE: does seem like it is possible, here: https://github.com/actions/upload-release-asset/issues/34#issuecomment-597499295

nonodev96 commented 4 years ago

You can use the outputs of jobs

https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs

Define the outputs:

jobs:
  Make_GitHub_Release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.step_version.outputs.version }}
      upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
      - id: step_version
        run: echo "::set-output name=version::${{ steps.package_version.outputs.version }}"

      - id: step_upload_url
        run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}"

Use the outputs in other jobs with needs.<job_id>.outputs

          upload_url: ${{ needs.Make_GitHub_Release.outputs.upload_url }}
          asset_path: "./release/${{ matrix.artifact_name }}"
          asset_name: "${{ matrix.asset_name }}"
          asset_content_type: ${{ matrix.asset_content_type }}
aaronliu0130 commented 4 years ago

You can use the outputs of jobs

https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjobs_idoutputs

Define the outputs:

jobs:
  Make_GitHub_Release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.step_version.outputs.version }}
      upload_url: ${{ steps.step_upload_url.outputs.upload_url }}
      - id: step_version
        run: echo "::set-output name=version::${{ steps.package_version.outputs.version }}"

      - id: step_upload_url
        run: echo "::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }}"

Use the outputs in other jobs with needs.<job_id>.outputs

          upload_url: ${{ needs.Make_GitHub_Release.outputs.upload_url }}
          asset_path: "./release/${{ matrix.artifact_name }}"
          asset_name: "${{ matrix.asset_name }}"
          asset_content_type: ${{ matrix.asset_content_type }}

Neat!