language: c

matrix:
  include:
    - os: linux
      compiler: gcc
      addons:
        apt:
          sources:
            - george-edison55-precise-backports
            - ubuntu-toolchain-r-test
          packages:
            - cmake
            - cmake-data
            - gcc-6
            - g++-6
      env:
        - BUILD_ARCH=x86_64
        - BUILD_PLATFORM=linux

    - os: osx
      osx_image: xcode8.2
      compiler: clang
      env:
        - BUILD_ARCH=x86_64
        - BUILD_PLATFORM=darwin
      before_install:
        - brew upgrade
        - brew install cmake

script:
  - if [ "$CC" = "gcc" ]; then export CC="gcc-6" CXX="g++-6"; fi
  - mkdir build
  - cd build
  - cmake -DCMAKE_BUILD_TYPE=RELEASE ..
  - make

before_deploy:
- BUILD_ARTIFACT=redream.$BUILD_ARCH-$BUILD_PLATFORM-HEAD.tar.gz
- GIT_TAG=travis-ci-latest
- tar -cvzf $BUILD_ARTIFACT redream
- git config --global user.email "builds@travis-ci.com"
- git config --global user.name "Travis CI"
- git tag $GIT_TAG -f
- git push --quiet --force https://$GITHUB_KEY@github.com/inolen/redream $GIT_TAG > /dev/null 2>&1

deploy:
  provider: releases
  skip_cleanup: true
  prerelease: true
  api_key: $GITHUB_KEY
  file: $BUILD_ARTIFACT
  overwrite: true
