image: node:latest

stages:
  - build
  - test
  - deploy

cache:
  paths:
    - node_modules/

install_dependencies:
  stage: build
  script:
    - npm install
  artifacts:
    paths:
      - node_modules/

test_with_lab:
  stage: test
  script: npm test

publish:
  stage: deploy
  only:
    - tags
    - triggers
  script:
    - npm run build
    - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc
    - npm publish
