1- version : 2
1+ version : 2.1
22
3- reference :
4- build-common : &common-build
5- working_directory : ~/diff2html-cli
6- steps : &common-steps
3+ jobs :
4+ checkout-and-version :
5+ docker :
6+ - image : codacy/git-version
7+ working_directory : ~/workdir
8+ steps :
79 - checkout
10+ - run :
11+ name : Get next version
12+ command : |
13+ # Hack: Set a unique fake name for the release branch to avoid releasing master as the new 3.x major release for now
14+ export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=FAKE-RELEASE-BRANCH-NAME)"
15+ echo "Next version is ${NEXT_VERSION}"
16+ echo "${NEXT_VERSION}" > .version
17+ - run :
18+ name : Get next npm tag name
19+ command : |
20+ if [ "${GITHUB_REF#refs/heads/}" = "master" ]; then
21+ export PUBLISH_TAG="latest"
22+ elif [ "${GITHUB_REF#refs/heads/}" = "next" ]; then
23+ export PUBLISH_TAG="next"
24+ else
25+ export PUBLISH_TAG="pr"
26+ fi
27+ echo "Next tag is ${PUBLISH_TAG}"
28+ echo "${PUBLISH_TAG}" > .tag
29+ - persist_to_workspace :
30+ root : ~/workdir
31+ paths :
32+ - ' *'
33+
34+ build-common : &common-build
35+ docker :
36+ - image : node
37+ working_directory : ~/workdir
38+ steps :
39+ - attach_workspace :
40+ at : ~/workdir
841 - restore_cache :
9- key : dependency-cache-{{ checksum "yarn.lock" }}
10- - run : yarn
42+ key : yarn-cache-{{ checksum "yarn.lock" }}
43+ - run :
44+ name : Log environment setup
45+ command : |
46+ node -v
47+ yarn -v
48+ - run :
49+ name : Install dependencies
50+ command : yarn
1151 - save_cache :
12- key : dependency -cache-{{ checksum "yarn.lock" }}
52+ key : yarn -cache-{{ checksum "yarn.lock" }}
1353 paths :
14- - ./node_modules
15- - run : yarn run build
16- - run : yarn run coverage
54+ - /usr/local/share/.cache/yarn
55+ - run : yarn run validate
56+ - store_artifacts :
57+ path : coverage
58+ - store_test_results :
59+ path : coverage
1760
1861 build-latest : &latest-build
19- working_directory : ~/diff2html-cli
62+ docker :
63+ - image : node
64+ working_directory : ~/workdir
2065 steps :
21- - checkout
66+ - attach_workspace :
67+ at : ~/workdir
2268 - restore_cache :
23- key : dependency-cache-{{ checksum "yarn.lock" }}
24- - run : yarn
69+ key : yarn-cache-{{ checksum "yarn.lock" }}
70+ - run :
71+ name : Log environment setup
72+ command : |
73+ node -v
74+ yarn -v
75+ - run :
76+ name : Install dependencies
77+ command : yarn
2578 - save_cache :
26- key : dependency -cache-{{ checksum "yarn.lock" }}
79+ key : yarn -cache-{{ checksum "yarn.lock" }}
2780 paths :
28- - ./node_modules
29- - run : yarn run test
30- - run : yarn run lint
31- - run : yarn run coverage
32- - run : yarn run codacy
81+ - /usr/local/share/.cache/yarn
82+ - run : yarn run validate
83+ - store_artifacts :
84+ path : coverage
85+ - store_test_results :
86+ path : coverage
87+ - run : yarn run coverage:push
88+ - persist_to_workspace :
89+ root : ~/workdir
90+ paths :
91+ - ' *'
3392
34- jobs :
35- build-node_8 :
93+ build-node-10 :
3694 << : *common-build
3795 docker :
38- - image : node:8
96+ - image : node:10
3997
40- build-node_10 :
98+ build-node-11 :
4199 << : *common-build
42100 docker :
43- - image : node:10
101+ - image : node:11
44102
45- build-node_11 :
103+ build-node-12 :
46104 << : *common-build
47105 docker :
48- - image : node:11
106+ - image : node:12
49107
50- build-node_12 :
108+ build-node-13 :
51109 << : *latest-build
52110 docker :
53- - image : node:12
111+ - image : node:13
112+
113+ publish_library :
114+ docker :
115+ - image : node:13
116+ working_directory : ~/workdir
117+ steps :
118+ - attach_workspace :
119+ at : ~/workdir
120+ - run :
121+ name : Configure Yarn version
122+ command : |
123+ yarn config set version-tag-prefix ""
124+ yarn config set version-git-message "Release version %s"
125+ - run :
126+ name : Configure Git
127+ command : |
128+ git config user.email "circleci@users.noreply.github.com"
129+ git config user.name "CircleCI"
130+ - run :
131+ name : Version package
132+ command : |
133+ # Update version in packages to publish
134+ yarn version --non-interactive --new-version $(cat .version)
135+ - run :
136+ name : Setup npm credentials
137+ command : |
138+ rm -f .npmrc
139+ touch .npmrc
140+ echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" >> .npmrc
141+ echo "registry=https://registry.npmjs.org/" >> .npmrc
142+ echo "access=public" >> .npmrc
143+ echo "save-exact=true" >> .npmrc
144+ - run :
145+ name : Publish npm package
146+ command : |
147+ # Publish package versions to npmjs.org
148+ yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
149+ - run :
150+ name : Setup gpr credentials
151+ command : |
152+ rm -f .npmrc
153+ touch .npmrc
154+ echo "//npm.pkg.github.com/:_authToken=${GPR_AUTH_TOKEN}" >> .npmrc
155+ echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
156+ echo "access=public" >> .npmrc
157+ echo "save-exact=true" >> .npmrc
158+ - run :
159+ name : Publish gpr package
160+ command : |
161+ # HACK: Override npm package name to be able to publish in GitHub
162+ sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html-cli",/g' package.json
163+ echo "Going to publish version $(cat .version) to GitHub"
164+ yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
165+ # HACK: Restore npm package name
166+ sed -i 's/^ "name":.*/ "name": "diff2html-cli",/g' package.json
54167
55168workflows :
56- version : 2
57- build :
169+ validate-and-publish :
58170 jobs :
59- - build-node_8
60- - build-node_10
61- - build-node_11
62- - build-node_12
171+ - checkout-and-version
172+ - build-node-10 :
173+ requires :
174+ - checkout-and-version
175+ - build-node-11 :
176+ requires :
177+ - checkout-and-version
178+ - build-node-12 :
179+ requires :
180+ - checkout-and-version
181+ - build-node-13 :
182+ requires :
183+ - checkout-and-version
184+ - publish_approval :
185+ type : approval
186+ requires :
187+ - build-node-10
188+ - build-node-11
189+ - build-node-12
190+ - build-node-13
191+ - publish_library :
192+ requires :
193+ - publish_approval
194+
0 commit comments