1 | version: 2
|
2 |
|
3 | defaults: &defaults
|
4 | working_directory: ~/repo
|
5 | docker:
|
6 | - image: circleci/node:10
|
7 |
|
8 | jobs:
|
9 |
|
10 | build:
|
11 | <<: *defaults
|
12 | steps:
|
13 | - checkout
|
14 | - restore_cache:
|
15 | key: dependency-cache-{{ checksum "yarn.lock" }}
|
16 | - run:
|
17 | name: Install Dependences
|
18 | command: yarn install
|
19 | - run:
|
20 | name: Build Package
|
21 | command: NODE_ENV=production yarn build
|
22 | - save_cache:
|
23 | key: dependency-cache-{{ checksum "yarn.lock" }}
|
24 | paths:
|
25 | - ./node_modules
|
26 | - persist_to_workspace:
|
27 | root: ~/repo
|
28 | paths:
|
29 | - .
|
30 |
|
31 | test:
|
32 | <<: *defaults
|
33 | steps:
|
34 | - attach_workspace:
|
35 | at: ~/repo
|
36 | - run:
|
37 | name: Eslint
|
38 | command: yarn lint
|
39 | - run:
|
40 | name: Unit Test
|
41 | command: NODE_ENV=test yarn test --coverage
|
42 | - run:
|
43 | name: Upload Coverage
|
44 | command: bash <(curl -s https://codecov.io/bash)
|
45 |
|
46 | release:
|
47 | <<: *defaults
|
48 | steps:
|
49 | - attach_workspace:
|
50 | at: ~/repo
|
51 | - run:
|
52 | name: Authenticate With Registry
|
53 | command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/repo/.npmrc
|
54 | - run:
|
55 | name: Publish Package
|
56 | command: npm publish
|
57 |
|
58 | bump:
|
59 | <<: *defaults
|
60 | steps:
|
61 | - add_ssh_keys:
|
62 | fingerprints:
|
63 | - "b1:ae:28:64:a6:7f:88:27:a9:6c:12:a7:85:d9:4e:03"
|
64 | - checkout
|
65 | - restore_cache:
|
66 | key: dependency-cache-{{ checksum "yarn.lock" }}
|
67 | - run:
|
68 | name: Install Dependences
|
69 | command: yarn install
|
70 | - run:
|
71 | name: git config
|
72 | command: |
|
73 | git config --global user.email "robot@circleci.com"
|
74 | git config --global user.name "robot"
|
75 | - run:
|
76 | name: bump version
|
77 | command: bin/bump.sh
|
78 |
|
79 | workflows:
|
80 | version: 2
|
81 | main:
|
82 | jobs:
|
83 | - build:
|
84 | filters:
|
85 | tags:
|
86 | only: /.*/
|
87 | - test:
|
88 | requires:
|
89 | - build
|
90 | filters:
|
91 | tags:
|
92 | only: /.*/
|
93 | - release:
|
94 | context: production
|
95 | requires:
|
96 | - test
|
97 | filters:
|
98 | tags:
|
99 | only: /v.*/
|
100 | branches:
|
101 | ignore: /.*/
|
102 | nightly:
|
103 | triggers:
|
104 | - schedule:
|
105 | cron: "20 20 * * *"
|
106 | filters:
|
107 | branches:
|
108 | only:
|
109 | - master
|
110 | jobs:
|
111 | - bump
|