language: cpp
env:
  global:
  - secure: dNf+ddgmbhuzrGHsO6eWuEQ9rTZbIQjdBX47TDnGulwWpOS8LyEoZNFz3IAvf9HJBY2L/pM3F6BvSfXpumX+qX2BVZLUETX54lk07i8PnGWgq0O0ylW5sB3xM0bNGPALiH3sBJEHeimEoRIAkbg+bXafLWo4cDFtQ7IT4mg6fQxq+MGNyr5GnSBkTRK7TdXef1dOylF0R2OV/xXVTr0xEkCb4ONB32ljZ1YZrYw0RzeDWX+rp674S1DnqhC3cYuOjK0Yl3h0uDHEI/rdvJmTahii9C5AILA8eB8Lc4jBlQmXlXYHy7Rr10KIwK7qYNFal6WyS4SbyBLZ6t3bNFrXe3ayMnhllVs0RsreMgMaJ78nGuHmpdQ8FJWlOIEWOYEFO6j/WnQwN7d6U4cgmB0mWmQJoO59qGuw1FsRTMssTJNeOd5t8WVi3AyNSV+GE4n+ZE1Bh4KIhmmhWno+w5iHKIHpr0SocxhPB5jQ2mEm1GhG8ZvM+wAollabkXCfeF9brGCh5IbTib10UpAkDkoeLYSpHO4Blshu5Tkpu0OXe1zcTwfUewbrZ1NZIS6LWdau6ISiPLQSnL+BwgZcIMJ/ZqUEmCtaBE79gQ/h730/Ekxkmdfr9KuvqnF+UTqXtRJeru/uZ0n2LTj7xrjpct2eFHZzGJlp2sAfQWfLK7EWg5A=

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
  - cd ..
  - wget https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew
  - export PROJECT_URL=https://github.com/$TRAVIS_REPO_SLUG
  - export PROJECT=`echo $TRAVIS_REPO_SLUG | cut -d "/" -f 2`
  - bash ./coinbrew fetch $PROJECT_URL:$TRAVIS_BRANCH --no-prompt --skip-update > /dev/null

script:
  - bash ./coinbrew build $PROJECT --no-prompt --verbosity=2 --test

after_script:
  - if [ $TRAVIS_BRANCH = "master" ]; then export VERSION=master; else export VERSION=`echo $TRAVIS_BRANCH | cut -d "/" -f 2`; fi
  - export TGZ_FILE=$PROJECT-$VERSION-$PLATFORM.tgz
  - echo $TGZ_FILE
  - cp $PROJECT/README.md $PROJECT/LICENSE $PROJECT/$PROJECT/AUTHORS dist
  - cd dist
  - tar -czvf $TGZ_FILE lib/* bin/* include/* share/* README.md LICENSE 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
