.circleci/config.yml
version: 2.1
jobs:
build:
docker:
- image: circleci/node:12
steps:
- checkout
- run: npm ci
- persist_to_workspace:
root: /home/circleci/project
paths:
- '*'
# run tests!
- run:
command: npm run test-ci
environment:
TEST_REPORTER_DOWNLOAD_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
- run: npm audit
- run: npm publish --dry-run
publish:
docker:
- image: circleci/node:12
steps:
- attach_workspace:
at: /home/circleci/project
# run tests
- run: npm run check-version
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
- run: npm publish
workflows:
publish:
jobs:
- build:
filters: &release-tag
tags:
only: /^[0-9]+\.[0-9]+\.[0-9]+$/
- approve-publish:
type: approval
requires:
- build
filters: &release-tag-only
<<: *release-tag
branches:
ignore: /.*/
- publish:
requires:
- approve-publish
filters: *release-tag-only