language: node_js
matrix:
  fast_finish: true
node_js:
- '8'
branches:
  only:
  - master
  # tags
  - /^\d+\.\d+\.\d+(\-beta.\d+)?$/
env:
  global:
  # GITHUB_TOKEN for yarn deploy script
  # to generate yours : travis encrypt GITHUB_TOKEN=<your_GITHUB_TOKEN> -r hsubtil/llle --org
  # REGISTRY_TOKEN for yarn cozyPublish script
  # to generate yours : travis encrypt REGISTRY_TOKEN=<your_REGISTRY_TOKEN> -r hsubtil/llle --org
  # N.B.: the --org option is needed only for public repositories
cache:
  yarn: true
  directories:
  - node_modules
before_install:
- curl -fsSL https://bootstrap.pypa.io/get-pip.py | python - --user
- travis_retry pip install --user transifex-client==0.12.5
- install -m0644 .transifexrc.tpl ~/.transifexrc
- echo "password = $TX_PASSWD" >> ~/.transifexrc
stages:
  - prebuild
  - build
jobs:
  include:
    - name: 'Lint'
      stage: 'prebuild'
      script: yarn lint
    - name: 'Tests'
      stage: 'prebuild'
      script: yarn test
    - name: 'Build app'
      stage: 'build'
      before_install:
        - curl -fsSL https://bootstrap.pypa.io/get-pip.py | python - --user
        - travis_retry pip install --user transifex-client==0.12.5
        - install -m0644 .transifexrc.tpl ~/.transifexrc
        - echo "password = $TX_PASSWD" >> ~/.transifexrc
      script: yarn build
      deploy:
        - provider: script
          repo: hsubtil/llle
          skip-cleanup: true
          # deploy the build on a build branch and publish to the Cozy registry
          script: DEPLOY_BRANCH=build && yarn deploy && yarn cozyPublish
          on:
            branch: master
        - provider: script
          repo: hsubtil/llle
          skip-cleanup: true
          # publish stable or beta versions using Github Releases (git tag)
          script: DEPLOY_BRANCH=build && yarn cozyPublish
          on:
            tags: true
