name: Windows CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch:
    branches: [ master ]

# env:
  # Path to the solution file relative to the root of the project.
  #SOLUTION_FILE_PATH: .

  # Configuration type to build.
  # You can convert this to a build matrix if you need coverage of multiple configuration types.
  # https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
  # BUILD_CONFIGURATION: Release

jobs:
  build:
    runs-on: windows-latest

    steps:
    - name: Checkout tclcurl
      uses: actions/checkout@v2
      with:
        path: tclcurl

    - name: Checkout tcl
      uses: actions/checkout@v2
      with:
        repository: tcltk/tcl
        ref: core-8-6-11
        path: tcl

    # Note msvc defaults to 64-bit
    - name: Init MSVC
      uses: ilammy/msvc-dev-cmd@v1

    - name: Install zlib with vcpkg
      run: vcpkg install zlib:x64-windows-static

    - name: Install curl with vcpkg
      run: vcpkg install curl:x64-windows-static

    - name: Build Tcl
      working-directory: tcl/win
      shell: cmd
      run: |
        nmake /f makefile.vc INSTALLDIR=C:\tcl
        nmake /f makefile.vc INSTALLDIR=C:\tcl install

    - name: make
      working-directory: tclcurl/win
      shell: cmd
      run: nmake /f makefile.vc INSTALLDIR=C:\tcl CURLDIR=C:\vcpkg\packages\curl_x64-windows-static CURLDEPSDIR=C:\vcpkg\packages\zlib_x64-windows-static

    - name: install
      working-directory: tclcurl/win
      shell: cmd
      run:  nmake /f makefile.vc INSTALLDIR=C:\tcl CURLDIR=C:\vcpkg\packages\curl_x64-windows-static CURLDEPSDIR=C:\vcpkg\packages\zlib_x64-windows-static install

    - name: test
      working-directory: tclcurl/win
      shell: cmd
      run: nmake /f makefile.vc INSTALLDIR=C:\tcl CURLDIR=C:\vcpkg\packages\curl_x64-windows-static CURLDEPSDIR=C:\vcpkg\packages\zlib_x64-windows-static test


