UNPKG

2.85 kBYAMLView Raw
1version: 2
2
3defaults: &defaults
4 working_directory: ~/repo
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 "yarn.lock" }}
15 - run:
16 name: Install Dependences
17 command: yarn install
18 - run:
19 name: Build Package
20 command: NODE_ENV=production yarn build
21 - save_cache:
22 key: dependency-cache-{{ checksum "yarn.lock" }}
23 paths:
24 - ./node_modules
25 - persist_to_workspace:
26 root: ~/repo
27 paths:
28 - .
29
30 test:
31 <<: *defaults
32
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
49 steps:
50 - attach_workspace:
51 at: ~/repo
52 - setup_remote_docker
53 - run:
54 name: Setup Environment Variables
55 command: |
56 echo "export TAG=`if test $CIRCLE_TAG; then echo $CIRCLE_TAG; else echo "$CIRCLE_BRANCH"; fi`" >> $BASH_ENV
57 source $BASH_ENV
58 - run:
59 name: Build and Push Image
60 command: |
61 unset CI
62 chmod +x bin/build-docker.sh
63 bin/build-docker.sh $TAG $DOCKER_USER $DOCKER_PASS $DOCKER_REGISTRY
64
65 bump:
66 <<: *defaults
67 steps:
68 - add_ssh_keys:
69 fingerprints:
70 - "b1:ae:28:64:a6:7f:88:27:a9:6c:12:a7:85:d9:4e:03"
71 - checkout
72 - restore_cache:
73 key: dependency-cache-{{ checksum "yarn.lock" }}
74 - run:
75 name: Install Dependences
76 command: yarn install
77 - run:
78 name: git config
79 command: |
80 git config --global user.email "robot@circleci.com"
81 git config --global user.name "robot"
82 - run:
83 name: bump version
84 command: bin/bump.sh
85
86workflows:
87 version: 2
88 main:
89 jobs:
90 - build:
91 filters: # required since `release` has tag filters AND requires `build`
92 tags:
93 only: /.*/
94 - test:
95 requires:
96 - build
97 filters: # required since `release` has tag filters AND requires `test`
98 tags:
99 only: /.*/
100 - release:
101 context: production
102 requires:
103 - test
104 filters:
105 tags:
106 only: /v.*/
107 branches:
108 ignore: /.*/
109 weekly:
110 triggers:
111 - schedule:
112 cron: "0 23 * * 6"
113 filters:
114 branches:
115 only:
116 - master
117 jobs:
118 - bump