upload-release-asset icon indicating copy to clipboard operation
upload-release-asset copied to clipboard

Support matrix build

Open smorimoto opened this issue 4 years ago • 14 comments

smorimoto avatar Nov 21 '19 22:11 smorimoto

@imbsky did you mean to open this? I’ll close it but happy to re-open if you edit your original comment body 👍

IAmHughes avatar Nov 22 '19 00:11 IAmHughes

Oh, when I hit return, it seemed to be opened...

smorimoto avatar Nov 22 '19 01:11 smorimoto

@IAmHughes Currently a validation error occurs when uploading assets from multiple OSs to release in a matrix build. It should be fixed.

smorimoto avatar Nov 22 '19 01:11 smorimoto

In other words, we can't upload software-name-here-x86_64-macOS-latest.tar.gz and software-name-here-x86_64-ubuntu-latest.tar.gz to latest release.

smorimoto avatar Nov 22 '19 01:11 smorimoto

and I can't re-open this issue, there is no button to re-open.

smorimoto avatar Nov 22 '19 01:11 smorimoto

I reopened it for you @imbsky, because the original issue was blank I wasn’t sure. Thanks!

IAmHughes avatar Nov 22 '19 02:11 IAmHughes

Thanks for quick response!

smorimoto avatar Nov 22 '19 02:11 smorimoto

Running into this. Trying to have a build with the following job structure:

build(mac)       build(linux)        build(win)
    │                  │                 │
    └──────────────────┼─────────────────┘
                       │
                create_release()
                       │
    ┌──────────────────┼─────────────────┐
    │                  │                 │
upload(mac)       upload(linux)      upload(win)

This is split into 3 jobs, 2 of which use matrices. It is not possible to run create-release (https://github.com/actions/create-release). Because it is impossible to get outputs from previous jobs (even ones that it "needs"), and because create-release cannot be run per-matrix this setup is impossible. The build job uses upload-artifact, and the upload job uses download-artifact.

Seems to be a problem of the workflow system. To me, jobs that "need" one-another should be able to access each-others' outputs.

arlyon avatar Dec 03 '19 16:12 arlyon

This supports matrix build. I don't know because I haven't read the code at all, but can't we support it with the same approach? https://github.com/softprops/action-gh-release

smorimoto avatar Dec 03 '19 16:12 smorimoto

Hey @arlyon that looks like a good solution but one thing I can't figure out is how to get the upload_url from the create_release job to the upload jobs. Thanks!

justin1121 avatar Jan 23 '20 17:01 justin1121

Same issue here. Trying to upload to a release 3 assets for 3 different platforms and failing on 'create_release' when the job for the second platform is running.

Run actions/create-release@v1
##[error]Validation Failed

Any ideas?

Viladoman avatar Mar 05 '20 02:03 Viladoman

I got around this by having a seperate job do release creation. Files needed for release can be uploaded/downloaded via artifacts.

Margen67 avatar Mar 26 '20 18:03 Margen67

I have the same problem, I've tried ${{ needs.create-release.outputs.upload_url }} but it doesn't work

vovapyc avatar Jul 17 '20 12:07 vovapyc

I have a workaround for this which creates the release first, before going into matrix mode:

jobs:
  create_release:
    name: Create release
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
    steps:
      - name: Create release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}

  build_release:
    name: Build release
    needs: create_release
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        include:
          - os: ubuntu-latest
            zip_name: plugin-linux
            generator: Unix Makefiles
          - os: macos-latest
            zip_name: plugin-mac
            generator: Xcode
          - os: windows-latest
            zip_name: plugin-win
            generator: Visual Studio 16 2019
    steps:

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install Linux dependencies
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get update && sudo apt-get install cmake gcc

      - name: Install macOS dependencies
        if: matrix.os == 'macOS-latest'
        run: brew install cmake

      - name: Install Windows dependencies
        if: matrix.os == 'windows-latest'
        run: |
          choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
          choco install zip

      - name: Build
        shell: bash
        run: cmake --build ./build --config Release

      - name: Compress
        shell: bash
        run: |
          cd ./build/VST3/Release
          zip -r ../${{ matrix.zip_name }}.zip *

      - name: Upload
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create_release.outputs.upload_url }}
          asset_path: ./build/VST3/${{ matrix.zip_name }}.zip
          asset_name: ${{ matrix.zip_name }}.zip
          asset_content_type: application/zip

You can also use the if statement if inside the matrix:

- name: Upload metadata
        if: matrix.os == 'ubuntu-latest'
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ needs.create_release.outputs.upload_url }}
          asset_path: ./build/VST3/Release/plugin.json
          asset_name: plugin.json
          asset_content_type: application/json

Full source code is here: https://github.com/studiorack/studiorack-plugin/blob/master/.github/workflows/release.yml

kmturley avatar Jul 22 '20 01:07 kmturley