Skip to content

Commit 78f5c78

Browse files
authored
Merge pull request #294 from rtfpessoa/revert-to-circleci
feature: Release in CircleCI
2 parents 128204d + eda3e66 commit 78f5c78

File tree

6 files changed

+212
-237
lines changed

6 files changed

+212
-237
lines changed

.circleci/config.yml

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
version: 2.1
2+
3+
jobs:
4+
checkout-and-version:
5+
docker:
6+
- image: codacy/git-version
7+
working_directory: ~/workdir
8+
steps:
9+
- 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
41+
- restore_cache:
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
51+
- save_cache:
52+
key: yarn-cache-{{ checksum "yarn.lock" }}
53+
paths:
54+
- /usr/local/share/.cache/yarn
55+
- run: yarn run validate
56+
- store_artifacts:
57+
path: coverage
58+
- store_test_results:
59+
path: coverage
60+
61+
build-latest: &latest-build
62+
docker:
63+
- image: node
64+
working_directory: ~/workdir
65+
steps:
66+
- attach_workspace:
67+
at: ~/workdir
68+
- restore_cache:
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
78+
- save_cache:
79+
key: yarn-cache-{{ checksum "yarn.lock" }}
80+
paths:
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+
- '*'
92+
93+
build-node-10:
94+
<<: *common-build
95+
docker:
96+
- image: node:10
97+
98+
build-node-11:
99+
<<: *common-build
100+
docker:
101+
- image: node:11
102+
103+
build-node-12:
104+
<<: *common-build
105+
docker:
106+
- image: node:12
107+
108+
build-node-13:
109+
<<: *latest-build
110+
docker:
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 "[email protected]"
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",/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",/g' package.json
167+
168+
publish_website:
169+
machine:
170+
enabled: true
171+
working_directory: ~/workdir
172+
steps:
173+
- attach_workspace:
174+
at: ~/workdir
175+
- run:
176+
name: Deploy
177+
working_directory: ~/workdir/docs
178+
command: |
179+
aws s3 sync --region eu-west-1 --delete . s3://diff2html.xyz --metadata-directive REPLACE --cache-control max-age=31557600
180+
aws cloudfront create-invalidation --region eu-west-1 --distribution-id $AWS_CF_DISTRIBUTION_ID --paths /index.html /demo.html /sitemap.xml /robots.txt
181+
182+
workflows:
183+
validate-and-publish:
184+
jobs:
185+
- checkout-and-version
186+
- build-node-10:
187+
requires:
188+
- checkout-and-version
189+
- build-node-11:
190+
requires:
191+
- checkout-and-version
192+
- build-node-12:
193+
requires:
194+
- checkout-and-version
195+
- build-node-13:
196+
requires:
197+
- checkout-and-version
198+
- publish_approval:
199+
type: approval
200+
requires:
201+
- build-node-10
202+
- build-node-11
203+
- build-node-12
204+
- build-node-13
205+
- publish_library:
206+
requires:
207+
- publish_approval
208+
- publish_website:
209+
requires:
210+
- publish_approval

.github/workflows/ci.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)