language: cpp
os:
  - linux
  - osx
sudo: required
dist: trusty
osx_image: xcode8
git:
  submodules: false
addons:
  ssh_known_hosts:
    - github.com
  apt:
    packages:
      - libfreetype6-dev
      - libevent-dev
      - libsqlite3-dev
      - libirrlicht-dev
      - liblua5.2-dev
      - libgl1-mesa-dev
      - libglu-dev
before_install:
  - openssl aes-256-cbc -K $encrypted_c268b785a48e_key -iv $encrypted_c268b785a48e_iv -in ssh-key.enc -out $HOME/.ssh/id_ecdsa -d
  - chmod 600 $HOME/.ssh/id_ecdsa
  - git submodule update --init --recursive
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew install freetype libevent sqlite irrlicht lua dylibbundler; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha9/premake-5.0.0-alpha9-macosx.tar.gz | tar zfx -; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget -O - https://github.com/premake/premake-core/releases/download/v5.0.0-alpha9/premake-5.0.0-alpha9-linux.tar.gz | tar zfx -; fi
script:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./premake5 gmake; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./premake5 gmake --cc=clang; fi 
  - cd build
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sed -i 's/-llua/-llua5.2/g' ygopro.make; fi
  - make config=release ygopro
  - cd ..
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv bin/release/ygopro ./; strip ygopro; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mkdir -p ygopro.app/Contents/MacOS; mv bin/release/ygopro ygopro.app/Contents/MacOS; dylibbundler -od -b -x ./ygopro.app/Contents/MacOS/ygopro -d ./ygopro.app/Contents/libs/; strip ygopro.app/Contents/MacOS/ygopro; fi
before_deploy:
  - wget https://mycard.moe/ygopro/cards.cdb
  - XZ_OPT=-9e tar -Jcf ygopro-lite-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.xz ygopro* LICENSE README.md lflist.conf script strings.conf system.conf textures cards.cdb
  - mkdir -p pics
  - wget -O - https://github.com/mycard/deprecated-ygopro-images/archive/zh-CN.tar.gz | tar --strip-components=1 -C pics -zxf -
  - wget -O - https://github.com/mycard/ygopro-images-field/archive/master.tar.gz | tar --strip-components=1 -C pics -zxf - ygopro-images-field-master/field
  - XZ_OPT=-9e tar -Jcf ygopro-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.xz ygopro* LICENSE README.md lflist.conf script strings.conf system.conf textures cards.cdb pics 
deploy:
  provider: releases
  file:
    - ygopro-lite-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.xz
    - ygopro-$TRAVIS_TAG-$TRAVIS_OS_NAME.tar.xz
  api_key:
    secure: "Js+zijIaucVvTm/knFOKLQ0KTdn93g/xgka8J4EQymgqM7JizL15sHSlVKPhqIFfMQYi/AUjNs7ikzYRO4QCe09GbYniSnFQhHPyGd7bb1tzJ5a7s8MdbP6rGFZ/v/SEbuTqDCsxtGGCfy9F/WMJ1J7o6dmuFfrAXEDzTtXrQrs="
  skip_cleanup: true
  on:
    tags: true
branches:
  only:
    - master
    - /\d+\..+/
