-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.yml
371 lines (363 loc) · 12.7 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
version: 2.1
orbs:
keeper: gravitee-io/keeper@0.6.2
gh: circleci/github-cli@2.0.0
executors:
node-lts:
parameters:
class:
description: The resource class
type: enum
enum: ['small', 'medium', 'large', 'xlarge']
default: 'medium'
docker:
- image: cimg/node:20.11
resource_class: <<parameters.class>>
commands:
yarn-install:
description: 'Runs Yarn install'
steps:
- restore_cache:
name: Restore Yarn cache
keys:
- gio-ui-particles-yarn-cache-v3-{{ checksum "yarn.lock" }}
- run:
name: 'Install Yarn dependencies'
command: yarn install
- save_cache:
paths:
- .yarn/cache
key: gio-ui-particles-yarn-cache-v3-{{ checksum "yarn.lock" }}
jobs:
lint-test:
executor:
class: xlarge
name: node-lts
steps:
- checkout
- yarn-install
- run:
name: Run lint
command: yarn lint
- run:
name: Run test
command: yarn test
build:
parameters:
package_name:
type: string
executor:
class: large
name: node-lts
steps:
- checkout
- yarn-install
- run:
name: Build
command: yarn build
working_directory: << parameters.package_name >>
- persist_to_workspace:
root: .
paths:
- << parameters.package_name >>/dist
- node_modules
prerelease:
parameters:
package_name:
type: string
angular_package_name:
type: string
executor:
class: small
name: node-lts
steps:
- checkout
- attach_workspace:
at: .
- gh/setup
- run:
name: 🐙 Prerelease the Kraken
working_directory: << parameters.package_name >>/dist/<< parameters.angular_package_name >>
command: |
export version=$(git describe --tags --abbrev=0 | tr -d v)
export commit=$(git rev-parse --short HEAD)
export branch=$(git rev-parse --abbrev-ref HEAD | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)
export versionTag=$version-$branch-$commit
echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > ~/.npmrc
npm version $versionTag --git-tag-version=false
npm publish --tag prerelease --access=public
echo "export VERSION_TAG=$versionTag" >> $BASH_ENV
- run:
name: 🐙 Comment Pull Request
command: |
# First check there is an associated pull request, otherwise just stop the job here
if ! gh pr view --json title;
then
echo "No PR found for this branch, stopping the job here."
exit 0
fi
# If PR state is different from OPEN
if [ "$(gh pr view --json state --jq .state)" != "OPEN" ];
then
echo "PR is not opened, stopping the job here."
exit 0
fi
export PR_BODY_PRERELEASE_SECTION="
<!-- Prerelease placeholder << parameters.angular_package_name >> -->
---
#### 🧪 Gravitee.io Automatic Prerelease @gravitee/<< parameters.angular_package_name >>
\`\`\`
npm install @gravitee/<< parameters.angular_package_name >>@${VERSION_TAG}
\`\`\`
\`\`\`
yarn add @gravitee/<< parameters.angular_package_name >>@${VERSION_TAG}
\`\`\`
<!-- Prerelease placeholder << parameters.angular_package_name >> end -->
"
export CLEAN_BODY=$(gh pr view --json body --jq .body | sed '/Prerelease placeholder << parameters.angular_package_name >> -->/,/Prerelease placeholder << parameters.angular_package_name >> end -->/d')
gh pr edit --body "$CLEAN_BODY$PR_BODY_PRERELEASE_SECTION"
release:
parameters:
package_name:
type: string
dry_run:
type: boolean
default: true
docker:
# TODO: Try to fix. Hack because npm publish + semantic-release is not working as before with 18.10 node version
- image: cimg/node:16.13
steps:
- add_ssh_keys:
fingerprints:
- 'ac:88:23:8f:c6:0f:7d:f0:fc:df:73:20:34:56:02:6c'
- checkout
- attach_workspace:
at: .
- when:
condition: << parameters.dry_run >>
steps:
- run:
name: 🧑🔬 dry-run release
working_directory: << parameters.package_name >>
command: yarn semantic-release --debug --no-ci --dry-run
- when:
condition:
not: << parameters.dry_run >>
steps:
- run:
name: 🚀 Release the Kraken
working_directory: << parameters.package_name >>
command: yarn semantic-release --debug
build-storybook:
parameters:
package_name:
type: string
executor:
class: large
name: node-lts
steps:
- checkout
- attach_workspace:
at: .
- yarn-install
- run:
name: Build
command: yarn storybook:build
working_directory: << parameters.package_name >>
environment:
NODE_OPTIONS: --max_old_space_size=3072
- persist_to_workspace:
root: .
paths:
- << parameters.package_name >>/storybook-static
- node_modules
chromatic-deployment:
parameters:
package_name:
type: string
executor:
class: small
name: node-lts
steps:
- checkout
- attach_workspace:
at: .
- run:
name: 📚 Running Chromatic
# TODO:
# - Handle npx chromatic command failure, make the job fails
command: |
SB_URL=$(npx chromatic --project-token=$CHROMATIC_PROJECT_TOKEN --exit-once-uploaded -d=<< parameters.package_name >>/storybook-static | grep -o "View your Storybook at https:\/\/[0-9a-z-]*\.chromatic\.com" | grep -o "https:.*")
echo "export SB_URL=$SB_URL" >> $BASH_ENV
- gh/setup
- run:
name: 📚 Edit Pull Request Description
command: |
# First check there is an associated pull request, otherwise just stop the job here
if ! gh pr view --json title;
then
echo "No PR found for this branch, stopping the job here."
exit 0
fi
# If PR state is different from OPEN
if [ "$(gh pr view --json state --jq .state)" != "OPEN" ];
then
echo "PR is not opened, stopping the job here."
exit 0
fi
export PR_BODY_STORYBOOK_SECTION="
<!-- Storybook placeholder -->
---
#### 📚 View the storybook of this branch [here](${SB_URL})
<!-- Storybook placeholder end -->
"
export CLEAN_BODY=$(gh pr view --json body --jq .body | sed '/Storybook placeholder -->/,/Storybook placeholder end -->/d')
gh pr edit --body "$CLEAN_BODY$PR_BODY_STORYBOOK_SECTION"
workflows:
version: 2.1
validate_build_branch:
# Trigger on all branches except `main` & `7.x`
when:
and:
- not:
equal: [main, << pipeline.git.branch >>]
- not:
equal: [7.x, << pipeline.git.branch >>]
jobs:
- lint-test:
name: Lint & Test
- build:
name: Build Angular
package_name: ui-particles-angular
- prerelease:
name: Prerelease ui-particles-angular
package_name: ui-particles-angular
angular_package_name: ui-particles-angular
pre-steps:
- keeper/env-export:
secret-url: keeper://hyuyfd_i5JChvc8OgSoxgg/field/password
var-name: NPM_TOKEN
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
context: cicd-orchestrator
requires:
- Build Angular
- prerelease:
name: Prerelease ui-policy-studio-angular
package_name: ui-particles-angular
angular_package_name: ui-policy-studio-angular
pre-steps:
- keeper/env-export:
secret-url: keeper://hyuyfd_i5JChvc8OgSoxgg/field/password
var-name: NPM_TOKEN
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
context: cicd-orchestrator
requires:
- Build Angular
- release:
name: '[Dry Run] Release Angular'
package_name: ui-particles-angular
dry_run: true
pre-steps:
- keeper/env-export:
secret-url: keeper://hyuyfd_i5JChvc8OgSoxgg/field/password
var-name: NPM_TOKEN
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_AUTHOR_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_AUTHOR_EMAIL
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_COMMITTER_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_COMMITTER_EMAIL
context: cicd-orchestrator
requires:
- Build Angular
- build-storybook:
name: Build Angular Storybook
package_name: ui-particles-angular
requires:
- Build Angular
- chromatic-deployment:
name: Chromatic deployment for Angular
context: cicd-orchestrator
package_name: ui-particles-angular
requires:
- Build Angular Storybook
pre-steps:
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
- keeper/env-export:
secret-url: keeper://ZC9NhWiu_AgpJbmW0naJag/field/password
var-name: CHROMATIC_PROJECT_TOKEN
release:
# Trigger only for `main` & `7.x` branch
when:
or:
- equal: [main, << pipeline.git.branch >>]
- equal: [7.x, << pipeline.git.branch >>]
# TODO: Remove me. Used to test release
- equal: [circleci, << pipeline.git.branch >>]
jobs:
- build:
name: Build Angular
package_name: ui-particles-angular
- lint-test:
name: Lint & Test
requires:
- Build Angular
- build-storybook:
name: Build Angular Storybook
package_name: ui-particles-angular
requires:
- Lint & Test
- chromatic-deployment:
name: Chromatic deployment for Angular
context: cicd-orchestrator
package_name: ui-particles-angular
requires:
- Build Angular Storybook
pre-steps:
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
- keeper/env-export:
secret-url: keeper://ZC9NhWiu_AgpJbmW0naJag/field/password
var-name: CHROMATIC_PROJECT_TOKEN
- release:
name: Release Angular
package_name: ui-particles-angular
dry_run: false
pre-steps:
- keeper/env-export:
secret-url: keeper://hyuyfd_i5JChvc8OgSoxgg/field/password
var-name: NPM_TOKEN
- keeper/env-export:
secret-url: keeper://TIlcGPFq4rN5GvgnZb9hng/field/password
var-name: GITHUB_TOKEN
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_AUTHOR_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_AUTHOR_EMAIL
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/field/login
var-name: GIT_COMMITTER_NAME
- keeper/env-export:
secret-url: keeper://q9AKrHbbTqSGDoUl-Lg85g/custom_field/email
var-name: GIT_COMMITTER_EMAIL
context: cicd-orchestrator
requires:
- Chromatic deployment for Angular