actions-rs / meta

🦀 GitHub Actions for Rust - recipes, discussions, questions and ideas
https://github.com/actions-rs
Creative Commons Zero v1.0 Universal
353 stars 15 forks source link

How to release artifacts builds on several operating systems? #14

Closed dmerejkowsky closed 4 years ago

dmerejkowsky commented 4 years ago

Hello there,

I'm trying to port CI of TankerHQ/dmenv from travis to GitHub actions, but I'm stuck at the publishing workflow :/

When a tag is pushed, I want to:

Here's what I've tried

jobs:
  release:
   runs-on: ${{ matrix.os }}
    strategy:
       matrix:
          os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
     - name: "Create GitHub Release"
        id: "create_release"
        uses: actions/create-release@v1.0.0
        # ...

   - name: Build
     # ...

   - name: Upload release assets for linux
      if: matrix.os == 'ubuntu-latest'
      uses: actions/upload-release-asset@v1.0.1
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        asset_path: target/release/dmenv
        asset_name: dmenv-linux

   - name: Upload release assets for macos
      if: matrix.os == 'macos-latest'
      uses: actions/upload-release-asset@v1.0.1
       # similar to upload assets for linux

   - name: Upload release assets for windows
      if: matrix.os == 'windows-latest'
      uses: actions/upload-release-asset@v1.0.1
      # ditto

The problem is that upload-assets needs an upload-url and that create-release can only be run once.

If I skip it, there's no upload_url and the artifact cannot be upload. If I don't skip it, there's an error and only one over 3 artifacts gets uploaded.

I've also tried to run create-release is a separate job, but then I don't know how to access the upload_url in the second job.

Any ideas?

dmerejkowsky commented 4 years ago

Update I think I could create an artifact containing the upload URL in the first job and then use it in the second job, but it seems like a hack ...

matchai commented 4 years ago

I'd suggest taking a look at https://github.com/softprops/action-gh-release. We currently use it for the release process on Starship. No upload_url needed. Just provide the build artifact and it does the rest.

dmerejkowsky commented 4 years ago

Exactly what I was looking for :) Thanks!

dmerejkowsky commented 4 years ago

Let's close this