UNPKG

2.77 kBYAMLView Raw
1version: 2
2
3defaults: &defaults
4 working_directory: ~/project
5 docker:
6 - image: circleci/node:10
7
8jobs:
9 build:
10 <<: *defaults
11 steps:
12 - checkout
13 - restore_cache:
14 key: dependency-cache-{{ checksum "package.json" }}
15 - run:
16 name: Install dependencies
17 command: npm install
18 - save_cache:
19 key: dependency-cache-{{ checksum "package.json" }}
20 paths:
21 - ./node_modules
22 - run:
23 name: Build
24 command: npm run build
25 - persist_to_workspace:
26 root: ~/project
27 paths: .
28
29 test:
30 <<: *defaults
31 steps:
32 - checkout
33 - restore_cache:
34 key: dependency-cache-{{ checksum "package.json" }}
35 - run:
36 name: Install dependencies
37 command: npm install
38 - save_cache:
39 key: dependency-cache-{{ checksum "package.json" }}
40 paths:
41 - ./node_modules
42 - run:
43 name: Run tests
44 command: npm test
45
46 lint:
47 <<: *defaults
48 steps:
49 - checkout
50 - restore_cache:
51 key: dependency-cache-{{ checksum "package.json" }}
52 - run:
53 name: Install dependencies
54 command: npm install
55 - save_cache:
56 key: dependency-cache-{{ checksum "package.json" }}
57 paths:
58 - ./node_modules
59 - run:
60 name: Lint
61 command: npm run lint
62
63 check-format:
64 <<: *defaults
65 steps:
66 - checkout
67 - restore_cache:
68 key: dependency-cache-{{ checksum "package.json" }}
69 - run:
70 name: Install dependencies
71 command: npm install
72 - save_cache:
73 key: dependency-cache-{{ checksum "package.json" }}
74 paths:
75 - ./node_modules
76 - run:
77 name: Check format
78 command: npm run check-format
79
80 publish:
81 <<: *defaults
82 steps:
83 - attach_workspace:
84 at: ~/project
85 - run:
86 name: Authenticate with npm registry
87 command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/project/.npmrc
88 - run:
89 name: Publish package
90 command: npm publish
91
92workflows:
93 version: 2
94 build_and_test:
95 jobs:
96 - build:
97 filters:
98 tags:
99 only: /.*/
100 - test:
101 filters:
102 tags:
103 only: /.*/
104 - lint:
105 filters:
106 tags:
107 only: /.*/
108 - check-format:
109 filters:
110 tags:
111 only: /.*/
112 - publish:
113 requires:
114 - build
115 - test
116 - check-format
117 filters:
118 tags:
119 only: /^v.*/
120 branches:
121 ignore: /.*/