travis-cigithub-release

How to publish Travis CI artifacts to GitHub Release from several jobs


I have three Travis CI jobs to build my application for different operating systems.
Each operating system has a separate job: OS X for osx-x64, Linux for linux-x64 and Windows for win-x64.

After the build, I get one file of my application, it is located on the path ImagePoster4DTF/ImagePoster4DTF/bin/Release/netcoreapp3.1/{win-x64,linux-x64,osx-x64}/publish/ImagePoster4DTF{.exe,}.

How can I upload three files from different jobs to a single GitHub release?

My current .travis.yml file that does not work:

language: csharp
mono: none
dotnet: 3.1.301

git:
  depth: 2
  quiet: true
  symlinks: true

script:
  - dotnet restore

jobs:
  include:
    - os: linux
      script: dotnet publish -r linux-x64 --configuration Release -p:PublishSingleFile=true
    - os: osx
      script: dotnet publish -r osx-x64 --configuration Release -p:PublishSingleFile=true
    - os: windows
      script: dotnet publish -r win-x64 --configuration Release -p:PublishSingleFile=true
    - stage: Publish GitHub release
      before_deploy:
        # Set up git user name and tag this commit
        - git config --local user.name "Artoria Pendragon"
        - git config --local user.email "saber-nyan@ya.ru"
        - export TRAVIS_TAG=${TRAVIS_TAG:-$(date +'%Y%m%d%H%M%S')-$(git log --format=%h -1)}
        - git tag $TRAVIS_TAG
      deploy:
        provider: releases
        api_key:
          secure: SOME_ENCRYPTED_KEY
        file_glob: true
        file: "ImagePoster4DTF/bin/Release/netcoreapp3.1/**/publish/*"
        skip_cleanup: true


Solution

  • Seems like it worked with this config:

    language: csharp
    mono: none
    
    branches:
      except:
        - /^untagged/
        - /^nightly/
    
    git:
      depth: 2
      quiet: true
      symlinks: true
    
    jobs:
      include:
        - stage: "Compile for amd64 Windows"
          os: windows
          script:
            - choco install dotnetcore-sdk
            - dotnet --version
            - dotnet restore
            - dotnet publish -r win-x64 --configuration Release -p:PublishSingleFile=true
          deploy: &deploy_base
            provider: releases
            api_key:
              secure: SOME_ENCRYPTED_KEY
            file: "ImagePoster4DTF/bin/Release/netcoreapp3.1/win-x64/publish/ImagePoster4DTF.exe"
            draft: true
            tag_name: $TRAVIS_TAG
            target_commitish: $TRAVIS_COMMIT
            name: $TRAVIS_TAG
            overwrite: true
            skip_cleanup: true
        - stage: "Compile for amd64 macOS"
          os: osx
          osx_image: xcode11.5
          dotnet: 3.1.301
          script:
            - dotnet restore
            - dotnet publish -r osx-x64 --configuration Release -p:PublishSingleFile=true
            - "cp ./ImagePoster4DTF/bin/Release/netcoreapp3.1/osx-x64/publish/ImagePoster4DTF ./ImagePoster4DTF_macOS"
          deploy:
            <<: *deploy_base
            file: "ImagePoster4DTF_macOS"
        - stage: "Compile for amd64 GNU/Linux and deploy GitHub Release"
          os: linux
          dist: bionic
          dotnet: 3.1.301
          script:
            - dotnet restore
            - dotnet publish -r linux-x64 --configuration Release -p:PublishSingleFile=true
            - "cp ./ImagePoster4DTF/bin/Release/netcoreapp3.1/linux-x64/publish/ImagePoster4DTF ./ImagePoster4DTF_linux"
          deploy:
            <<: *deploy_base
            draft: false
            file: "ImagePoster4DTF_linux"
    
    before_deploy:
      - git config --local user.name "Artoria Pendragon"
      - git config --local user.email "saber-nyan@ya.ru"
      - export TRAVIS_TAG="nightly-$TRAVIS_BUILD_NUMBER"
      - echo "Tagging commit ${TRAVIS_COMMIT} with tag ${TRAVIS_TAG}"
      - git tag "$TRAVIS_TAG" "$TRAVIS_COMMIT"
    
    

    Success