###############################################################################
#
# HOW TO USE
#  
# Push any commit to build_windows_dependencies branch, create it if needed
# This will trigger execution of the following workflow
# Generated artifacts can be used to update the dependency package
#
###############################################################################

name: Windows Dependencies

on:
  push:
    branches:
    - build_windows_dependencies
  pull_request:
    branches:
    - build_windows_dependencies

jobs:
  build:
    name: ${{ matrix.config.name }}
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
        - {
            name: "Visual Studio 64-bit",
            os: windows-latest,
            triplet: x64-windows
          }
        - {
            name: "Visual Studio 32-bit",
            os: windows-latest,
            triplet: x86-windows
          }

    steps:
    - uses: actions/checkout@v1

    - name: Configure
      id: vars
      shell: cmd
      run: |
        echo ::set-output name=common_options::sdl2-image sdl2-mixer[dynamic-load,libflac,libmodplug,libvorbis,mpg123,opusfile] sdl2-net libmad fluidsynth dumb portmidi --triplet ${{ matrix.config.triplet }}

    - name: Install
      shell: cmd
      run: |
        xcopy .github\workflows\dumb %VCPKG_INSTALLATION_ROOT%\ports\dumb\
        xcopy .github\workflows\portmidi %VCPKG_INSTALLATION_ROOT%\ports\portmidi\ /y
        vcpkg update
        vcpkg install ${{ steps.vars.outputs.common_options }}

    - name: Export
      shell: cmd
      run: |
        md artifact
        .github\workflows\copy_dependencies.cmd %VCPKG_INSTALLATION_ROOT%\installed\${{ matrix.config.triplet }} artifact

    - name: Upload
      uses: actions/upload-artifact@v1
      with:
        path: artifact
        name: ${{ matrix.config.triplet }}

