environment:
  npm_version: latest
  github_release_token:
    secure: fNm9+m4cngLwXcaUAk0vTM7Dp3pwjzU0H6tTb9YA+6Yh5Xng4fpSHIl257+H8mHB
  matrix:
    - nodejs_version: 4
      npm_version: 4.0.3
    - nodejs_version: 5
      npm_version: 4.0.3
    - nodejs_version: 6
    - nodejs_version: 7
    - nodejs_version: 8
    - nodejs_version: 9
    - nodejs_version: 10

platform:
  - x86
  - x64

image: Visual Studio 2015

artifacts:
  - path: build\**\*.tar.gz
    name: libxml_binary

install:
  - ps: Install-Product node $env:nodejs_version $env:platform
  - npm --version
  - npm config set msvs_version 2015
  - npm config set python C:\Python27\python.exe
  - npm install -g npm@%npm_version%
  - npm --version
  - npm install -g node-pre-gyp@0.6.37 --production

  # work around an issue with node-gyp v3.3.1 and node 4x
  # https://github.com/nodejs/node-gyp/issues/921
  - npm config set -g cafile=package.json
  - npm config set -g strict-ssl=false
  - npm config set registry http://registry.npmjs.org/

build_script:
  - npm install --msvs_version=2015

test_script:
  - node --expose-gc node_modules/nodeunit/bin/nodeunit test

after_test:
  - node-pre-gyp package 2>&1

deploy:
  - provider: GitHub
    release: $(APPVEYOR_REPO_TAG_NAME)
    artifact: libxml_binary
    auth_token: $(github_release_token)
    draft: false
    prerelease: false
    on:
      appveyor_repo_tag: true

after_deploy:
  - npm config delete -g cafile
  - npm config delete -g strict-ssl
  - npm config delete registry
  - node-pre-gyp clean
  - npm install --fallback-to-build=false
  - node --expose-gc node_modules/nodeunit/bin/nodeunit test