.circleci/config.yml
version: 2
jobs:
test:
docker:
- image: circleci/node
steps:
- checkout
- restore_cache:
name: Restore dependencies
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Install dependencies
command: yarn install
- save_cache:
name: Save dependencies
key: yarn-packages-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules/
- run:
name: Run linter
command: yarn lint
- run:
name: Run tests
command: yarn test
environment:
MOCHA_FILE: reports/junit.xml
- store_test_results:
path: ./reports
- store_artifacts:
path: ./reports
publish:
docker:
- image: circleci/node
steps:
- checkout
- run:
name: Set NPM token
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- run:
name: Publish to NPM
command: npm publish --access=public
workflows:
version: 2
test_and_publish:
jobs:
- test:
filters:
tags:
only: /.*/
- publish:
context: NPM
requires:
- test
filters:
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$/
branches:
ignore: /.*/