Created
March 17, 2019 19:08
-
-
Save brpaz/042e4c8649219f055baf5072148f6777 to your computer and use it in GitHub Desktop.
Sample config.yml for publishing to NPM from CircleCI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Javascript Node CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | |
# | |
version: 2.1 | |
defaults: &defaults | |
working_directory: ~/repo | |
docker: | |
- image: circleci/node | |
jobs: | |
test: | |
<<: *defaults | |
steps: | |
- checkout | |
- restore_cache: | |
name: Restore Yarn Package Cache | |
keys: | |
- yarn-packages-{{ checksum "yarn.lock" }} | |
- run: | |
name: Install Dependencies | |
command: yarn install --frozen-lockfile | |
- save_cache: | |
name: Save Yarn Package Cache | |
key: yarn-packages-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.cache/yarn | |
- run: | |
name: Lint | |
command: yarn lint | |
- run: | |
name: Run tests | |
command: yarn test | |
- 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: Authenticate with registry | |
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc | |
- run: | |
name: Publish package | |
command: npm publish | |
workflows: | |
version: 2 | |
test-deploy: | |
jobs: | |
- test: | |
filters: | |
tags: | |
only: /^v.*/ | |
- deploy: | |
requires: | |
- test | |
filters: | |
tags: | |
only: /^v.*/ | |
branches: | |
ignore: /.*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment