branches:
  only:
    - master
    - /^v?[0-9]/

environment:
  GYP_MSVS_VERSION: 2013

  matrix:
    - node_version: '12'
    - node_version: '14'
    - node_version: '16'
    - node_version: '18'

install:
  - ps: Install-Product node $env:node_version $env:platform
  - cmd: npm install -g node-gyp node-pre-gyp-github
  - ps: if ($env:appveyor_repo_tag -match "true" -and $env:appveyor_repo_tag_name -match '^v?[0-9]') { $publish_binary=1; }

build_script:
  - ps: echo $publish_binary
  - ps: |
      $ErrorActionPreference = 'Continue'
      git submodule update --init 2>&1 | write-host
      npm install --build-from-source 2>&1 | write-host
      ./node_modules/.bin/node-pre-gyp package 2>&1 | write-host
      if ($publish_binary -Eq "1") {
        node-pre-gyp-github publish 2>&1 | write-host
        if (-Not ($?)) {
          throw "Failed publishing";
        }
      }
      echo "done."
platform:
  - x86
  - x64
