language: cpp
env:
  global: 
    - secure: "WEPiGQTAVh02Fc5Qxvj2VBZoWBgNjjB6w5MdNwg6NtzFKhbhxB1OqfaVE7EJV1Cw9mf1k5Qcg2fSy9bQEJllWNclRpbRGfEcC+Crx3CyjFOebSr6e6T7lAjIspIVSRf9+y6oPEY2zR8yXoX/HAEYyw3IQzJtKCHIbSJrrZsPomc="
    
matrix:
  include:
    - os: linux
      addons:
        apt:
          packages:
            - gfortran
    - os: osx 
      osx_image: xcode10
      env: OSX=10.13
      compiler: clang
    - os: osx 
      osx_image: xcode9.2
      env: OSX=10.12
      compiler: clang
    - os: osx
      osx_image: xcode8
      env: OSX=10.11
      compiler: clang
  allow_failures:
    - os: osx

before_script:
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then  export PLATFORM=osx$OSX-x86_64-clang`clang -dumpversion`; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install bash gcc; brew link --overwrite gcc; gfortran --version; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PLATFORM=linux-x86_64-gcc`gcc -dumpversion`; fi
  - git clone https://github.com/coin-or/COIN-OR-OptimizationSuite COIN
  - cd COIN
  - export PROJECT=`echo $TRAVIS_REPO_SLUG | cut -d "/" -f 2`
  - bash ./coin.install.sh fetch --no-prompt --main-proj=$PROJECT > /dev/null

script:
  - bash ./coin.install.sh build --no-prompt --main-proj=$PROJECT --verbosity=2 --test

after_script:
  - if [ $TRAVIS_BRANCH = "master" ]; then export VERSION=trunk; else export VERSION=`echo $TRAVIS_BRANCH | cut -d "/" -f 2`; fi
  - export TGZ_FILE=$PROJECT-$VERSION-$PLATFORM.tgz
  - echo $TGZ_FILE
  - tar -czvf $TGZ_FILE build/lib/* build/bin/* build/include/* build/share/* $PROJECT/README.md $PROJECT/INSTALL $PROJECT/LICENSE $PROJECT/$PROJECT/AUTHORS
  - curl -T $TGZ_FILE -utkralphs:$BINTRAY_API -H "X-Bintray-Publish:1" -H "X-Bintray-Override:1" https://api.bintray.com/content/coin-or/download/$PROJECT/$VERSION/$TGZ_FILE