# environment variables
environment:
  node_pre_gyp_accessKeyId:
    secure: /v/gQoDu7Y5ossb9oEt20y+2OWe4X9EW+sloFOANvQo=
  node_pre_gyp_secretAccessKey:
    secure: l7+hDEKs1otLl8hVxYKdAtF7VsulJ+JN6yZDeq37IP00ncVa4S7dPSq7SIBB2L/m
  nodejs_version: "4.2.0"

platform:
- x64

# scripts that run after cloning repository
install:
  - cmd: ECHO "INSTALL:"
  - cmd: ECHO "APPVEYOR_REPO_COMMIT_MESSAGE ->"
  - cmd: ECHO %APPVEYOR_REPO_COMMIT_MESSAGE%
  - cmd: SET COMMIT_MSG="%APPVEYOR_REPO_COMMIT_MESSAGE%"
  - cmd: SET NODIST_PREFIX=C:\nodist
  - cmd: SET PATH=C:\nodist\bin;%PATH%
  # Check to verify the branch is the same than latest tag, if so
  # then we publish the binaries if everything else is successful.
  - cmd: git describe --tags --always HEAD > _git_tag.tmp
  - cmd: SET /p GIT_TAG=<_git_tag.tmp
  - cmd: ECHO "LATEST LOCAL TAG:"
  - cmd: ECHO %GIT_TAG%
  - cmd: ECHO "APPVEYOR REPO BRANCH/TAG:"
  - cmd: ECHO %APPVEYOR_REPO_BRANCH%
  - cmd: DEL _git_tag.tmp
  - cmd: git clone https://github.com/marcelklehr/nodist.git c:\nodist 2>&1
  - cmd: SET NODIST_X64=0
  - cmd: nodist update
  - cmd: nodist %nodejs_version%
  - cmd: npm install -g node-gyp

# to run your custom scripts instead of automatic MSBuild
build_script:
  - cmd: ECHO "INSTALLING x64 node.js:"
  # We add newest MSBuild so we can use the correct libs for the x64 version
  - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH%
  - cmd: SET PATH=C:\python27;%PATH%
  - cmd: set NODIST_X64=1
  - cmd: nodist update
  - cmd: nodist %nodejs_version%
  - cmd: npm install -g node-gyp  
  - cmd: ECHO "BUILDING x64 version:"
  - cmd: git submodule update --init
  - cmd: npm install --build-from-source --msvs_version=2013
  - cmd: ECHO "PUBLISH package:"
  - cmd: npm install aws-sdk
  - cmd: node-pre-gyp package publish 2>&1
  - cmd: node-pre-gyp clean
  - cmd: node-gyp clean
