Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Publish with CircleCI (#33)
Browse files Browse the repository at this point in the history
Add CircleCI support for publishing to NPM when there's a new version tag.
  • Loading branch information
morleyzhi authored Apr 18, 2019
1 parent e69e63b commit 26945ae
Showing 1 changed file with 78 additions and 9 deletions.
87 changes: 78 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,48 @@
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2

defaults: &defaults
docker:
# specify the version you desire here
- image: circleci/node:lts

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4

working_directory: ~/repo

jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:lts
test:
<<: *defaults
steps:
- checkout

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

working_directory: ~/repo
- run: yarn install

- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}

# run tests!
- run: yarn test:ci

- persist_to_workspace:
root: ~/repo
paths: .

build:
<<: *defaults
steps:
- checkout

Expand All @@ -35,3 +64,43 @@ jobs:

# run tests!
- run: yarn test:ci

# build
- run: yarn build

- 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
only_test:
jobs:
- test
test-deploy:
jobs:
- build:
filters:
tags:
only: /^v.*/
- deploy:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/

0 comments on commit 26945ae

Please sign in to comment.