language: cpp
env:
  global:
    secure: "fJgWlCFbde96OSQNGKUmowGX+ERPeqP+n1EOMf1+FJzOU4DdkTLRAlV5+5qnEX9jB/3mWN6iPpmG1qEz/SdDG3KHxJYs4ZU/Lu485O24zZ/+GdYBNsrvhPD9ckPGEMLDa1foEVTDnW0Dlkz3BCFcszjhtXGUJv7v6Pj6LRk1Mg8="
  matrix:
    - BUILD_TYPE=PSP
    - BUILD_TYPE=Android
    - BUILD_TYPE=Qt

branches:
  except:
    - latest-master

before_install:
  - sudo apt-get update -qq
# Building for PSP here
  - if [ "$BUILD_TYPE" == "PSP" ]; then
      export PSPDEV="$TRAVIS_BUILD_DIR/opt/pspsdk" &&
      export PSPSDK="$PSPDEV/psp/sdk" &&
      export PATH="$PATH:$PSPDEV/bin:$PSPSDK/bin" &&
      wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download;
    fi
# Building for Android here
  - if [ "$BUILD_TYPE" == "Android" ]; then
      export ANDROID="android-sdk-linux/tools/android" &&
      if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq; fi &&
      wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv &&
      wget http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz -nv;
    fi
# Building for Qt here
  - if [ "$BUILD_TYPE" == "Qt" ]; then
      sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa &&
      sudo apt-get update -qq &&
      sudo apt-get install -qq qt5-qmake qtbase5-dev qtdeclarative5-dev qttools5-dev qtmultimedia5-dev pulseaudio libpulse-dev &&
      export QMAKE="qmake -qt=qt5";
    fi

install:
# Building for PSP here
  - if [ "$BUILD_TYPE" == "PSP" ]; then
      tar -x --xz -f sdk.lzma;
    fi
  - if [ "$BUILD_TYPE" == "Android" ]; then
      tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2 &&
      tar -zxf android-sdk_r23.0.2-linux.tgz &&
      $ANDROID list sdk --extended -a &&
      echo yes | $ANDROID update sdk --filter tools,platform-tools,build-tools-21.1.1,android-10 --no-ui --force --no-https;
    fi
  - sudo pip install pyjavaproperties
  - sudo pip install github3.py
script: ./travis-script.sh

matrix:
  fast_finish: true

deploy:
  provider: releases
  api-key:
    secure: "gzfDEihpfTmoO6CSjTNpHSlLTPtQUZUqTlmD91CQby6+znDsOy4xsqj10MNXe+l/3KYny1DtM48nxNKeVjsyeYg66TTzKsrgMVzt6Ah5CBhSXO99/TiaMJmSXmMO7GGfKDct190Dqej1gbR7AMd38DOYe2vpR0LX+Lf3gzDVLoU="
  file:
    - ${TRAVIS_BUILD_DIR}/core.zip
    - ${TRAVIS_BUILD_DIR}/projects/mtg/Android/bin/Wagic-debug.apk
    - ${TRAVIS_BUILD_DIR}/projects/mtg/psprelease.zip
  skip_cleanup: true
  on:
    repo: WagicProject/wagic
    tags: false
    branch: auto_releases
