.circleci/config.yml
version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:12-browsers
jobs:
test:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
# - run:
# name: Audit packages
# command: npm audit
- run:
name: Run linting
command: npm run lint
- run:
name: Setup Code Climate test-reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter
- run:
name: Run tests
command: |
./tmp/cc-test-reporter before-build
npm run test
./tmp/cc-test-reporter format-coverage -t lcov -o tmp/coverage-materialize-angular.json coverage/materialize-angular/lcov.info
- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter upload-coverage -i tmp/coverage-materialize-angular.json
- run:
name: Build library
command: npm run build
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- persist_to_workspace:
root: ~/repo
paths: .
deploy:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Build library
command: npm run build
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$npm_TOKEN" > ~/repo/dist/materialize-angular/.npmrc
- run:
name: Publish package
command: cd ~/repo/dist/materialize-angular && npm publish
workflows:
version: 2
test-deploy:
jobs:
- test:
filters:
tags:
only: /^v.*/
- deploy:
requires:
- test
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/