3

I am trying to create a GitHub Action that is triggered when a release is published and will build my project and upload certain artefacts as release assets. The only examples I can find rely on using the create-release action, which fails as the release has already been created. My workflow file is like so:

name: Build for Release

on:
  release:
    types: [published]

jobs:
  build:

    runs-on: macos-latest

    steps:
    - uses: actions/checkout@v2
      
    - name: Build
      run: ...
      
    - name: Zip Asset
      run: ...

    - name: Upload Release Asset
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ ???? What Goes Here ???? }}
        asset_path: build/MyProject.zip
        asset_name: MyProject.zip
        asset_content_type: application/zip

My tags will be v0.1.0, v0.1.1, v0.2.0 etc and the release name matches these.

1 Answer 1

6

You can access it on the event data in the github context:

- name: Upload Release Asset
  uses: actions/upload-release-asset@v1
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    upload_url: ${{ github.event.release.upload_url }}

See also Example data for the release event.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.