name: Windows-win64

on: [push, pull_request]

jobs:
  build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2
    - name: cache dependencies
      id: cache-dependencies
      uses: actions/cache@v2
      with:
        #path: ${VCPKG_INSTALLATION_ROOT}\installed
        path: c:\vcpkg\installed
        key: ${{ runner.os }}-dependencies
    - name: dependencies
      if: steps.cache-dependencies.outputs.cache-hit != 'true'
      run: vcpkg.exe install libflac libvorbis soxr opus boost-asio --triplet x64-windows
    - name: cmake build
      run: |
        echo vcpkg installation root: ${env:VCPKG_INSTALLATION_ROOT}
        cmake -S . -B build -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="x64-windows" -DCMAKE_BUILD_TYPE="Release" -DWERROR=ON
    - name: cmake make
      run: cmake --build build --config Release --parallel 3 --verbose
    - name: installer
      run: |
        copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\FLAC.dll bin\Release\
        copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\ogg.dll bin\Release\
        copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\opus.dll bin\Release\
        copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\vorbis.dll bin\Release\
        copy ${env:VCPKG_INSTALLATION_ROOT}\installed\x64-windows\bin\soxr.dll bin\Release\
        copy "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Redist\MSVC\v142\vc_redist.x64.exe" bin\Release\
    - name: Archive artifacts
      uses: actions/upload-artifact@v2
      with:
        name: develop_snapshot_win64-${{github.sha}}
        path: |
          bin\Release\snapclient.exe
          bin\Release\FLAC.dll
          bin\Release\ogg.dll
          bin\Release\opus.dll
          bin\Release\vorbis.dll
          bin\Release\soxr.dll
          bin\Release\vc_redist.x64.exe
 
 
