name: node-gyp

on: [push]

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:
  darwin:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '14.17.1'
    - uses: maxim-lobanov/setup-xcode@v1
      with:
        xcode-version: latest-stable
    # Build x64
    - run: npm install --verbose
    - run: npx just fetch-wrapper --target_platform=darwin --target_arch=x64
    - run: npx just build --runtime=electron --target=9.4.4 --target_platform=darwin --target_arch=x64
    - run: npx just build --runtime=electron --target=11.4.5 --target_platform=darwin --target_arch=x64
    - run: npx just build --runtime=electron --target=12.0.11 --target_platform=darwin --target_arch=x64
    # Upload artifacts
    - uses: actions/upload-artifact@v2
      with:
        path: ${{ github.workspace }}/packages/*.tar.gz

  win32:
    runs-on: windows-2016
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '14.17.1'
        architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default

    - name: Add MSBuild to PATH
      uses: microsoft/setup-msbuild@v1.0.2

    # Build ia32
    - run: npm install --verbose
    - run: npx just fetch-wrapper --target_platform=win32 --target_arch=ia32
    - run: npx just build --runtime=electron --target=9.4.4 --target_platform=win32 --target_arch=ia32
    - run: npx just build --runtime=electron --target=11.4.5 --target_platform=win32 --target_arch=ia32
    - run: npx just build --runtime=electron --target=12.0.11 --target_platform=win32 --target_arch=ia32
    # Build x64
    - run: npx just fetch-wrapper --target_platform=win32 --target_arch=x64
    - run: npx just build --runtime=electron --target=9.4.4 --target_platform=win32 --target_arch=x64
    - run: npx just build --runtime=electron --target=11.4.5 --target_platform=win32 --target_arch=x64
    - run: npx just build --runtime=electron --target=12.0.11 --target_platform=win32 --target_arch=x64
    # Upload artifacts
    - uses: actions/upload-artifact@v2
      with:
        path: ${{ github.workspace }}/packages/*.tar.gz
