version: build{build}

image: Visual Studio 2017

environment:
  access_token:
    secure: 0uxsfE7N2HTcPQtM48XlcCDG1Lxf/xELs0S5GvnoGSDZWOkAJxukffyOOcuj1LGM
  matrix:
    - QT_PATH : C:\Qt\5.12\msvc2017_64\bin
      PLATFORM : amd64
      PLATFORM_ALT_NAME: x64
      OUTPUT_BIN_DIR : bin64
    - QT_PATH : C:\Qt\5.12\msvc2017\bin
      PLATFORM : x86
      PLATFORM_ALT_NAME: x86
      OUTPUT_BIN_DIR : bin32

clone_folder: c:\dev\labrador
clone_depth: 1
configuration: Release

skip_tags: true

branches:
  only:
    - master

init:
  - set PATH=%QT_PATH%;%PATH%
  - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM%

before_build:
  - cd c:\dev\labrador\Desktop_Interface 

build_script:
  - ps: $env:GIT_HASH_SHORT=$(git rev-parse --short HEAD)
  - qmake CONFIG+=release DEFINES+=GIT_HASH_SHORT=%GIT_HASH_SHORT%
  - nmake

after_build:
  - windeployqt bin\Labrador.exe
  - xcopy /i /s /y build_win\fftw\%PLATFORM_ALT_NAME%\libfftw3-3.dll bin
  - del bin\vcredist*.exe
  - del bin\*.pdb

artifacts:
  - path: Desktop_Interface\bin
    name: Labrador_%PLATFORM%
    type: zip
    
on_success:
  - cd C:\dev
  - git clone --depth 1 https://github.com/EspoTek/Labrador-win-builder
  - cd Labrador-win-builder
  - git config --global credential.helper store
  - ps: Add-Content "$HOME\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
  - git config --global user.email "admin@espotek.com"
  - git config --global user.name "Chris Esposito"
  - git checkout master
  - xcopy /i /s /y c:\dev\labrador\Desktop_Interface\bin %OUTPUT_BIN_DIR%
  - git add %OUTPUT_BIN_DIR%
  - git commit -a -m "Automatic update from main Labrador repository"
  - git push
    
matrix:
  fast_finish: true
