Skip to content

Instantly share code, notes, and snippets.

@alirezabonab
Last active January 3, 2021 20:05
Show Gist options
  • Save alirezabonab/1e5a8510bada401c5e9896f83163fff5 to your computer and use it in GitHub Desktop.
Save alirezabonab/1e5a8510bada401c5e9896f83163fff5 to your computer and use it in GitHub Desktop.
version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:14.15.3
jobs:
test:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: npm install
- run:
name: Run tests
command: npm test
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- persist_to_workspace:
root: ~/repo
paths:
- .
build:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run: npm run build
- persist_to_workspace:
root: ~/repo
paths:
- .
release:
<<: *defaults
steps:
- attach_workspace:
at: ~/repo
- run:
name: Add github.com to known hosts
command: mkdir ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
- run:
name: Versioning
command: npm version patch -m "version %s [skip ci]"
- run:
name: Push tag & changes to github.com
command: git push
- run:
name: Authenticate with registry
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
- run:
name: Publish the package
command: npm publish
workflows:
version: 2
test-deploy:
jobs:
- test
- build:
requires:
- test
- release:
filters:
branches:
only: master
requires:
- build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment