language: android

before_script:
  - mkdir deploy

matrix:
    fast_finish: true
    include:
      - os: linux
        env: TARGET=Linux
        dist: trusty
        language: c
        addons:
          apt:
            packages:
            - libsdl2-dev
            - libfltk1.3-dev
            - gzip
        script:
          - cd unix
          - make
          - gzip sdlpal
          - mv sdlpal.gz ../deploy/sdlpal-linux.gz
          - make clean
          - make check
          - cd ..

      - os: linux
        env: TARGET=MinGW32
        dist: trusty
        language: c
        addons:
          apt:
            packages:
            - binutils-mingw-w64-i686
            - gcc-mingw-w64-i686
            - g++-mingw-w64-i686
            - zip
        before_install:
          - cd win32
          - wget http://libsdl.org/release/SDL2-devel-2.0.5-mingw.tar.gz
          - tar xvf SDL2-devel-2.0.5-mingw.tar.gz
          - sed -i "s@/usr/local/cross-tools@$(pwd)/SDL2-2.0.5@g" SDL2-2.0.5/i686-w64-mingw32/bin/sdl2-config
          - export PATH=$(pwd)/SDL2-2.0.5/i686-w64-mingw32/bin:$PATH
          - cd ..
        script:
          - cd win32
          - make HOST=i686-w64-mingw32-
          - i686-w64-mingw32-strip sdlpal.exe
          - zip sdlpal-mingw32.zip sdlpal.exe
          - mv sdlpal-mingw32.zip ../deploy/
          - cd ..

      - os: linux
        env: TARGET=Android NDK_VERSION=r13b TERM=dumb
        android:
          components:
            - platform-tools
            - tools
            - build-tools-25.0.3
            - android-25
            - extra-android-m2repository
        jdk: oraclejdk8
        before_install:
          - wget http://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux-x86_64.zip
          - unzip android-ndk-$NDK_VERSION-linux-x86_64.zip > /dev/null
          - export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
          - export PATH=${PATH}:${ANDROID_NDK_HOME}
        script:
          - cd android
          - ./gradlew assembleRelease
          - cd ..
          - jarsigner -storetype pkcs12 -keystore winrt/SDLPal.UWP/SDLPal_TemporaryKey.pfx -sigalg SHA1withRSA -digestalg SHA1 -signedjar deploy/sdlpal-release.apk -storepass "" android/app/build/outputs/apk/app-release-unsigned.apk 5f85e55b-6e81-4b08-ac2d-c51f3dae22ae

      - os: osx
        osx_image: xcode8.3
        env: TARGET=iOS
        language: c
        script:
          - cd ios/SDLPal
          - pod install
          - xcodebuild -workspace SDLPal.xcworkspace -scheme SDLPal ONLY_ACTIVE_ARCH=NO CODE_SIGNING_ALLOWED=NO -configuration Release CONFIGURATION_BUILD_DIR=/tmp/sdlpal-build
          - mkdir -p Payload
          - mv /tmp/sdlpal-build/SDLPal.app Payload
          - zip ../../deploy/sdlpal-impactor.ipa -r Payload
          - cd ../..

      - os: osx
        osx_image: xcode8.3
        env: TARGET=macOS
        language: c
        script:
          - cd macos
          - xcodebuild -configuration Release
          - hdiutil create -srcfolder build/Release/Pal.app -volname "SDLPal" ../deploy/sdlpal-macos.dmg
          - #xcodebuild test -scheme PalTests #disabled since always fail in travis-ci
          - cd ..

deploy:
  provider: releases
  api_key:
    secure: FFV8UBcz6GkeSoGRbrL9tnTpVqXoFjFK2QtW0Ml8YvvqaHhxOaIWs2nAabOGsW1mJop/QlpuUNw1TfLl7TokcUDgOHrFRdC8hVY7K1uSWMnt7m4ZRPatVybIkzgrnItHlnMrL4uJK2xXb6Jc5+cSrU5jRMcmTZjaOKLTBwF97+6AgqpdmKUCVYZJzQYg0Jn9GfaL1EOGl7ISt/VEgi/tKFzJvJVxJBU3NuKyxXlfEwkTiSOFuGoD5qWDjCE+aGxTR6RQefsADPIDfeU3TJHTJE/ORGy9gl+Y41JgU0Bfgipcqg1RSwNclclmxgi8lo/XNUiZAMTyQrXjByBWcvYovk+H4h9mbvJlrVSjI8Wxb5ICcYkhDVkNxtEXX7AsIk4yHiNTi1MAW0qJJKinaFxLmK2U3LGEK3DudXl/0eVRoQATmRcXLdBQezISt2CWpTktCxlQmtz/GsoHv0PcWdkJYL4qbbRrBRFj9++VjlnCI124YZnbVjC3+jtWN1Zluxynj0GDBY3r7EdLWWKZo5XnygPOZ8+uaTMYfqmTvQWPc5GRRRdVJowQFQhb48hzKyWYqsf8eyS3VuZ9b/DwES3dutOaX7sIL9Vkg3DlQYOEz938MB4VbTGizUUrBbrIP4Kz/+WOZ9pxM9X+qsgMYkw8FvHqn2TvCWxPDCgqq3zUWig=
  file_glob: true
  file: deploy/*
  skip_cleanup: true
  overwrite: true
  on:
      all_branches: true
      tags: true

notifications:
  webhooks:
    urls:
      - https://webhooks.gitter.im/e/922838d6727e919df50e
    on_success: always  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: never     # options: [always|never|change] default: always
