Skip to content

Commit d012037

Browse files
committed
chore(common): CHECKOUT-4374 Create release and upload source maps to Sentry from CircleCi
1 parent 48c8c9c commit d012037

File tree

3 files changed

+145
-20
lines changed

3 files changed

+145
-20
lines changed

.circleci/config.yml

+139-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,152 @@
1+
aliases:
2+
- &node_executor
3+
executor:
4+
name: node/node
5+
node-version: "10"
6+
7+
- &release_filter
8+
branches:
9+
only:
10+
- master
11+
12+
- &pull_request_filter
13+
branches:
14+
ignore:
15+
- master
16+
117
version: 2.1
218

319
orbs:
420
ci: bigcommerce/internal@volatile
521
node: bigcommerce/internal-node@volatile
22+
checkout-js:
23+
commands:
24+
install_dependencies:
25+
steps:
26+
- restore_cache:
27+
keys:
28+
- checkout-js
29+
- run:
30+
name: "Install NPM dependencies"
31+
command: npm ci
32+
- save_cache:
33+
key: checkout-js
34+
paths:
35+
- ~/.npm
636

737
jobs:
38+
test:
39+
<<: *node_executor
40+
steps:
41+
- ci/pre-setup
42+
- checkout-js/install_dependencies
43+
- run:
44+
name: "Run unit tests"
45+
command: npm run test -- --coverage --runInBand
46+
- store_artifacts:
47+
path: coverage
48+
destination: coverage
49+
850
build:
9-
executor:
10-
name: node/node
11-
node-version: "10"
51+
<<: *node_executor
1252
steps:
1353
- ci/pre-setup
14-
- restore_cache:
15-
keys:
16-
- checkout-js
17-
- run: npm ci
18-
- save_cache:
19-
key: checkout-js
54+
- checkout-js/install_dependencies
55+
- run:
56+
name: "Test build"
57+
command: npm run build
58+
- persist_to_workspace:
59+
root: .
2060
paths:
21-
- ~/.npm
61+
- dist
62+
63+
release:
64+
<<: *node_executor
65+
steps:
66+
- ci/pre-setup
67+
- checkout-js/install_dependencies
68+
- run:
69+
name: "Configure Git user"
70+
command: |
71+
git config user.email $GIT_USER_EMAIL
72+
git config user.name $GIT_USER_NAME
2273
- run:
23-
name: 'Build'
24-
command: 'npm run build'
74+
name: "Remove old release files"
75+
command: rm -rf dist
76+
- attach_workspace:
77+
at: .
2578
- run:
26-
name: 'Unit Tests'
27-
command: 'npm run test -- --coverage --runInBand'
28-
when: always
79+
name: "Create and tag new release"
80+
command: npm run release:version
81+
- run:
82+
name: "Push commits and tag to GitHub"
83+
command: |
84+
git push --follow-tags origin $CIRCLE_BRANCH
85+
- run:
86+
name: "Export release version to file"
87+
command: |
88+
echo "export RELEASE_VERSION=$(git describe --abbrev=0)" > /tmp/release_version.txt
89+
echo "export RELEASE_REVISION=$(git rev-parse HEAD)" >> /tmp/release_version.txt
90+
- persist_to_workspace:
91+
root: /tmp
92+
paths:
93+
- release_version.txt
94+
95+
upload_to_sentry:
96+
<<: *node_executor
97+
steps:
98+
- ci/pre-setup
99+
- run:
100+
name: "Install Sentry cli"
101+
command: curl -sL https://sentry.io/get-cli/ | bash
102+
- attach_workspace:
103+
at: /tmp
104+
- run:
105+
name: "Upload source maps to Sentry"
106+
command: |
107+
source /tmp/release_version.txt
108+
SENTRY_RELEASE=$SENTRY_PROJECT@$RELEASE_VERSION
109+
SENTRY_COMMIT=$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME@$RELEASE_REVISION
110+
sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG new $SENTRY_RELEASE
111+
sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG set-commits $SENTRY_RELEASE --commit $SENTRY_COMMIT
112+
sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG files $SENTRY_RELEASE upload-sourcemaps dist
113+
sentry-cli releases --project $SENTRY_PROJECT --org $SENTRY_ORG finalize $SENTRY_RELEASE
114+
115+
workflows:
116+
version: 2
117+
118+
pull_request:
119+
jobs:
120+
- test:
121+
filters:
122+
<<: *pull_request_filter
123+
- build:
124+
filters:
125+
<<: *pull_request_filter
126+
127+
release:
128+
jobs:
129+
- test:
130+
filters:
131+
<<: *release_filter
132+
- build:
133+
filters:
134+
<<: *release_filter
135+
- approve:
136+
filters:
137+
<<: *release_filter
138+
type: approval
139+
requires:
140+
- test
141+
- build
142+
- release:
143+
filters:
144+
<<: *release_filter
145+
requires:
146+
- approve
147+
- upload_to_sentry:
148+
filters:
149+
<<: *release_filter
150+
requires:
151+
- approve
152+
- release

.versionrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
"type": "test",
3333
"hidden": true
3434
}
35-
]
35+
],
36+
"releaseCommitMessageFormat": "chore(release): {{currentTag}} [skip ci]"
3637
}

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"private": true,
55
"description": "Browser-based application providing a seamless UI for BigCommerce shoppers to complete their checkout.",
66
"scripts": {
7+
"build": "rm -rf dist && webpack --mode production",
78
"dev": "webpack --mode development --watch",
8-
"build": "webpack --mode production",
9-
"prerelease": "npm run test -- --coverage && rm -rf dist && npm run build",
9+
"release": "npm run test -- --coverage && npm run build && standard-version -a",
10+
"release:version": "standard-version -a",
1011
"test": "jest",
11-
"test:watch": "jest --watch",
12-
"release": "standard-version -a"
12+
"test:watch": "jest --watch"
1313
},
1414
"repository": {
1515
"type": "git",

0 commit comments

Comments
 (0)