language: node_js
cache: yarn
node_js:
  - "7"
  - "8"

# run install twice. flaky npm behavior
# https://github.com/GitbookIO/gitbook/issues/1834
script: yarn test

jobs:
  include:
    - stage: npm
      node_js: "8"
      if: tag =~ ^v\d.*
      deploy:
          provider: npm
          script: yarn build
          email: "jondotan@gmail.com"
          api_key:
            secure: fGqPo4don8YwuxgM/QR68RvnSD38prYHqjWyXfdYTFi5xcVvUllIO/REtbQb0X1scbCP4WlvDVYQ7iCH/eh7uXM40RO0B+KSrHOUgngKtLKF104IRLZ48U4qkrJqB+VBxXHpqe2dlQyyOU4Z0RdcSI838EN7WSP802tWC4R/Vsg3B+E/gILnzjGX4dGFdHIqTOpMpcgchQRcfXIkHpFfQWF2Ww6NFwQ5aZzhmXPOxAt9AaaIwrNoNcndh+AqshDVgZzy2+S4NtPLEaEz7YdqqogkFoG1ma+oj4ZM/MhfESYowZYLqo7iqtGFN6RGxoivTUBWwakMz9/2ELrstKD7rtT3U7Et5HSt05sRnHXgNPTSYylnZJXbgprgT/gP9rhdQAMVZS2x6fX/WG4+ifIUG78ZWLLFfMMDn6OhRzbiJsHNMrXkxgg0vuMMU6gMriNHwNsA5Tva2wvuklrqr0nBA3+7YchczQspS+akKHIDI3fXxgBTJNXlqRuz1lWfN26hNxVOzBdmxPIsfwnYC703pc46iPPrpWp5wREjKJfxy85BSvCPO8K1/T7O4CnpIlgcVIGBtVopnhoKXQNVEbiEyiU3I2vyTthgK2ieJtacsu6EeQ2zCgAC73n/9W+nexu9zXvBK7lZSIHgoDByHCKuqBY0LIwrsLg7WRA46wn/VIk=
          on:
            tags: true
            skip_cleanup: true
    - stage: docs
      script: yarn docs:prepare && yarn docs:build
      node_js: "8"
      deploy:
        provider: pages
        local-dir: hygen.io/public
        skip-cleanup: true
        github-token: $GITHUB_TOKEN  # Set in travis-ci.org dashboard, marked secure
        keep-history: true
    - stage: binary releases
      script: yarn standalone
      if: tag =~ ^v\d.*
      node_js: "8"
      deploy:
        provider: releases
        api_key: $GITHUB_TOKEN
        file_glob: true
        file: standalone/*
        skip_cleanup: true
        on:
          tags: true
