language: cpp

compiler:
  - gcc

jobs:
  include:
    - os: linux
      dist: xenial
    - os: osx
      osx_image: xcode11.6

addons:
  homebrew:
    packages:
    - qt
    - boost

  apt:
    sources:
      - sourceline: 'ppa:beineri/opt-qt-5.12.8-xenial'
    packages:
    - qt512base
    - qt512svg
    - libboost-math-dev
    - libgl-dev

install:
  - |
    if [ $TRAVIS_OS_NAME == "linux" ]; then 
      source /opt/qt*/bin/qt*-env.sh
    fi
  - |
    if [ $TRAVIS_OS_NAME == "osx" ]; then
      export PATH=$PATH:/usr/local/opt/qt/bin
      export CPATH=$CPATH:/usr/local/include/
    fi

script:
  - |
    if [ $TRAVIS_OS_NAME == "linux" ]; then
      qmake CONFIG+=release PREFIX=/usr
      make -j$(nproc)
      make INSTALL_ROOT=appdir -j$(nproc) install ; find appdir/
      wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
      chmod a+x linuxdeploy-x86_64.AppImage

      wget -c -nv "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
      chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage

      unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
      ./linuxdeploy-x86_64.AppImage --list-plugins
      ./linuxdeploy-x86_64.AppImage --appdir appdir --plugin qt --output appimage
    fi
  - |
    if [ $TRAVIS_OS_NAME == "osx" ]; then
      qmake -config release
      make -j$(nproc)
      macdeployqt ZeGrapher.app -dmg
    fi

after_success:
  - |
    if [ $TRAVIS_OS_NAME == "linux" ]; then
      wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
      bash upload.sh ZeGrapher*.AppImage*
    fi
  - |
    if [ $TRAVIS_OS_NAME == "osx" ]; then
      wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
      export UPLOADTOOL_SUFFIX="osx"
      bash upload.sh ZeGrapher.dmg
    fi
  
branches:
  except:
    - # Do not build tags that we create when we upload to GitHub Releases
    - /^(?i:continuous)/
