environment:
  npm_version: latest
  gyp_version: latest
  pre_gyp_version: latest
  github_release_token:
    secure: en/UnoFHA3RsSAHM5c6zb3RAMa4V01lC3pYG1YrHSeOPFu78SUA/0lOjNe3pp8RG
  matrix:
    - nodejs_version: 0.10
      npm_version: 4.0.3
      gyp_version: 3.5.0
      pre_gyp_version: 0.6.36
    - nodejs_version: 0.12
      npm_version: 4.0.3
      gyp_version: 3.5.0
      pre_gyp_version: 0.6.36
    - nodejs_version: 4
    - nodejs_version: 5
    - nodejs_version: 6
    - nodejs_version: 7
    - nodejs_version: 8

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-gyp@%gyp_version%
  - npm install -g node-pre-gyp@%pre_gyp_version%

  # 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
