How to configure deployment of different artifacts from different workers?

I use matrix to build my application on linux and osx:

matrix:
  include:
    - os: osx
      osx_image: xcode10.1
      compiler: clang
      addons:
        homebrew:
          packages:
          - qt5
          update: true
      if: tag IS blank
    - os: linux
      dist: focal
      compiler: gcc
      if: tag IS blank

And I had a deployment step for osx. These bits work just fine:

deploy:
      provider: releases
      edge: true
      overwrite: true
      token: $GITHUB_TOKEN
      file: FileCommander.dmg
      prerelease: true
      on:
        tags: true
        all_branches: true
        condition: $TRAVIS_OS_NAME = osx

But now I want to also deploy a build artifact from the Linux job, and I can’t think of any way to specify this (I also tried googling to no avail). I tried adding a second deploy clause, but it seems that it is ignored altogether (or, more precisely, the first one is ignored):

deploy:
  provider: releases
  edge: true
  overwrite: true
  token: $GITHUB_TOKEN
  file: FileCommander.AppImage
  prerelease: true
  on:
    tags: true
    all_branches: true
    condition: $TRAVIS_OS_NAME = linux

I also now tried it this way, to no avail as well (still only one of the two artifacts deployed):

deploy:
  provider: releases
  edge: true
  overwrite: true
  token: $GITHUB_TOKEN
  file: FileCommander.dmg
  prerelease: true
  on:
    tags: true
    all_branches: true
    condition: $TRAVIS_OS_NAME = osx

  provider: releases
  edge: true
  overwrite: true
  token: $GITHUB_TOKEN
  file: FileCommander.AppImage
  prerelease: true
  on:
    tags: true
    all_branches: true
    condition: $TRAVIS_OS_NAME = linux

General problem

That’s due to YAML specification. If you have clashing hash keys in YAML, the last one wins.

foo: bar
foo: baz

only specifies foo: baz.

Likewise,

This configuration

overwrites provider, edge, etc., values with the second one.

Possible solutions

Define deploy at the top level

What you need instead is an array, if you want to define 2 deployments for each of the jobs:

deploy:
  - provider: releases
    ⋮
  - provider: releases
    ⋮

This would run both of the deployments on each job, which may not be ideal in your use case. You’d want to add conditionals to ensure that they don’t step on each other’s foot.

Define deploy for each job

Alternatively, you can stick deploy inside each job:

jobs:
  include:
    - os: osx
      ⋮
      deploy:
        provider: releases
        ⋮
    - os: linux
      ⋮
      deploy:
        provider: releases
        ⋮
1 Like

Thank you, appreciate the help! So my latest solution was correct thinking (two provider clauses under a single deploy clause), but I needed dashes for it to work - looks like it was a problem with understanding YAML rather than understanding Travis. Works like charm!