sudo: required
dist: trusty
language: cpp

env:
  - QT_BASE=55
  - QT_BASE=56
  - QT_BASE=57
  - QT_BASE=58
  - QT_BASE=trusty
  - QT_BASE=xenial
  - QT_BASE=yakkety
  - QT_BASE=zesty
  - QT_BASE=appimage
  - QT_BASE=snap

service:
  - docker

before_install:
  - git fetch --unshallow
  - if [ "$QT_BASE" = "55" ]; then sudo add-apt-repository ppa:beineri/opt-qt551-trusty -y; fi
  - if [ "$QT_BASE" = "56" ]; then sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y; fi
  - if [ "$QT_BASE" = "57" ]; then sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y; fi
  - if [ "$QT_BASE" = "58" ]; then sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y; fi
  - if [ "$QT_BASE" = "xenial" ]; then docker pull theshadowx/qt5:default_qt5_xenial; fi
  - if [ "$QT_BASE" = "yakkety" ]; then docker pull theshadowx/qt5:default_qt5_yakkety; fi
  - if [ "$QT_BASE" = "zesty" ]; then docker pull theshadowx/qt5:default_qt5_zesty; fi
  - if [ "$QT_BASE" = "appimage" ]; then docker pull theshadowx/docker-snapcraft-qt:qt55; fi
  - sudo apt-get update -qq

install:
  - sudo apt-get -y install software-properties-common checkinstall xvfb dh-make fakeroot gpgv2 tree
  - if [ "$QT_BASE" == "55" ]; then sudo apt-get install -qq qt55base; source /opt/qt55/bin/qt55-env.sh; fi
  - if [ "$QT_BASE" == "56" ]; then sudo apt-get install -qq qt56base; source /opt/qt56/bin/qt56-env.sh; fi
  - if [ "$QT_BASE" == "57" ]; then sudo apt-get install -qq qt57base; source /opt/qt57/bin/qt57-env.sh; fi
  - if [ "$QT_BASE" == "58" ]; then sudo apt-get install -qq qt58base; source /opt/qt58/bin/qt58-env.sh; fi
  - if [ "$QT_BASE" == "trusty" ]; then sudo apt-get install -y qt5-default qtbase5-private-dev; fi

before_script:
    - echo "$QT_BASE:$TRAVIS_BRANCH----------------------------------------------------------------------------------------------"
    - if [ "$QT_BASE" == "55" ]; then qmake -v; fi
    - if [ "$QT_BASE" == "56" ]; then qmake -v; fi
    - if [ "$QT_BASE" == "57" ]; then qmake -v; fi
    - if [ "$QT_BASE" == "58" ]; then qmake -v; fi
    - if [ "$QT_BASE" == "trusty" ]; then qmake -v; fi
    - if [ "$QT_BASE" == "xenial" ]; then docker run --rm -it theshadowx/qt5:default_qt5_xenial qmake -v; fi
    - if [ "$QT_BASE" == "yakkety" ]; then docker run --rm -it theshadowx/qt5:default_qt5_yakkety qmake -v; fi
    - if [ "$QT_BASE" == "zesty" ]; then docker run --rm -it theshadowx/qt5:default_qt5_zesty qmake -v; fi
    - mkdir build;
    - cd build;

script:
    - if [ "$QT_BASE" == "xenial" ]; then
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial qmake ../src/;
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial make deb;
      elif [ "$QT_BASE" == "yakkety" ]; then
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_yakkety qmake ../src/;
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_yakkety make deb;
      elif [ "$QT_BASE" == "zesty" ]; then
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_zesty qmake ../src/;
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_zesty make deb;
      elif [ "$QT_BASE" == "snap" ]; then
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial qmake ../src/;
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial make snap;
      elif [ "$QT_BASE" == "appimage" ]; then
        docker run --rm -it -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial qmake ../src/;
        docker run --rm -it --privileged -v ${TRAVIS_BUILD_DIR}:/home/root/notes -w=/home/root/notes/build theshadowx/qt5:default_qt5_xenial make appimage;
      else
        qmake ../src;
        make -j4;
        echo "-----------------------------------------------";
        make deb;
      fi

after_success:

  - if [ "$TRAVIS_BRANCH" != "master" ]; then
        if [ "$QT_BASE" == "trusty" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64-$QT_BASE.deb ;
        elif [ "$QT_BASE" == "xenial" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64-$QT_BASE.deb ;
        elif [ "$QT_BASE" == "yakkety" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64-$QT_BASE.deb ;
        elif [ "$QT_BASE" == "zesty" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64-$QT_BASE.deb ;
        elif [ "$QT_BASE" == "appimage" ]; then
            curl --upload-file ./Notes-*.AppImage https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64.AppImage;
        elif [ "$QT_BASE" == "snap" ]; then
            curl --upload-file snap/notes*.snap https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')-git$(git rev-parse --short HEAD)_amd64-xenial.snap ;
        fi
    else
        if [ "$QT_BASE" == "trusty" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64-trusty.deb ;
        elif [ "$QT_BASE" == "xenial" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64-xenial.deb ;
        elif [ "$QT_BASE" == "yakkety" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64-yakkety.deb ;
        elif [ "$QT_BASE" == "zesty" ]; then
            curl --upload-file deb/notes*.deb https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64-zesty.deb ;
        elif [ "$QT_BASE" == "appimage" ]; then
            curl --upload-file ./Notes-*.AppImage https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64.AppImage;
        elif [ "$QT_BASE" == "snap" ]; then
            curl --upload-file snap/notes*.snap https://transfer.sh/notes_$(git describe --always --tags HEAD | cut -d- -f1 | sed 's/^v//')_amd64.snap ;
        fi
    fi

notifications:
  email: false

