forked from codefresh-io/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodefresh-release.yml
More file actions
483 lines (459 loc) · 15.4 KB
/
codefresh-release.yml
File metadata and controls
483 lines (459 loc) · 15.4 KB
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# this pipeline should only be executed on master branch
version: '1.0'
mode: parallel
stages:
- prepare
- docker
- build
- github
- packages
- documentation
steps:
fail_if_not_master:
stage: prepare
title: "Validate running on master branch"
image: codefresh/build-cli
commands:
- >-
if [ "${{CF_BRANCH}}" != "master" ]; then
echo This pipeline should be run only on master
exit 1
fi
main_clone:
stage: prepare
title: 'Cloning main repository...'
type: git-clone
repo: codefresh-io/cli
revision: ${{CF_BRANCH}}
git: cf_github
when:
steps:
- name: fail_if_not_master
on:
- success
extract_version:
stage: prepare
title: "Exporting package.json version"
image: codefresh/build-cli
commands:
- 'export PACKAGE_VERSION=$(jq -r ".version" package.json)'
- "echo Current version: $PACKAGE_VERSION"
- "cf_export PACKAGE_VERSION"
when:
steps:
- name: main_clone
on:
- success
install:
stage: prepare
title: "Installing dependencies"
image: codefresh/build-cli
commands:
- "yarn install"
when:
steps:
- name: main_clone
on:
- success
generate_comletion:
stage: prepare
title: "Generating commands completion tree"
image: codefresh/build-cli
commands:
- "yarn generate-completion"
when:
steps:
- name: install
on:
- success
# in case the candidate image will not be found the release flow will crash and this means that the build pipelines has failed
push_step_alpine:
stage: docker
type: push
title: "Push alpine release image"
image_name: codefresh/cli
tags:
- ${{PACKAGE_VERSION}}
- latest
scale:
push_to_dockerhub_alpine:
registry: dockerhub
title: "push to dockerhub"
candidate: codefresh/cli:${{CF_SHORT_REVISION}}
push_to_gcr_alpine:
title: "push to gcr"
candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}
push_to_quay_alpine:
registry: cf-quay
title: "push to quay.io"
candidate: quay.io/codefresh/cli:${{CF_SHORT_REVISION}}
when:
steps:
- name: extract_version
on:
- success
push_step_debian:
stage: docker
type: push
title: "Push debian release image"
image_name: codefresh/cli
tags:
- ${{PACKAGE_VERSION}}${{DEBIAN_TAG_POSTFIX}}
- latest${{DEBIAN_TAG_POSTFIX}}
scale:
push_to_dockerhub_debian:
registry: dockerhub
title: "push to dockerhub"
candidate: codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}
push_to_gcr_debian:
title: "push to gcr"
candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}
push_to_quay_debian:
registry: cf-quay
title: "push to quay.io"
candidate: quay.io/codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}
when:
steps:
- name: extract_version
on:
- success
# in case the candidate image will not be found the release flow will crash and this means that the build pipelines has failed
push_step_alpine_rootless:
stage: docker
type: push
title: "Push alpine release image"
image_name: codefresh/cli
tags:
- ${{PACKAGE_VERSION}}${{ROOTLESS_TAG_POSTFIX}}
- latest${{ROOTLESS_TAG_POSTFIX}}
scale:
push_to_dockerhub_alpine_rootless:
registry: dockerhub
title: "push to dockerhub"
candidate: codefresh/cli:${{CF_SHORT_REVISION}}${{ROOTLESS_TAG_POSTFIX}}
push_to_gcr_alpine_rootless:
title: "push to gcr"
candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}${{ROOTLESS_TAG_POSTFIX}}
push_to_quay_alpine_rootless:
registry: cf-quay
title: "push to quay.io"
candidate: quay.io/codefresh/cli:${{CF_SHORT_REVISION}}${{ROOTLESS_TAG_POSTFIX}}
when:
steps:
- name: extract_version
on:
- success
push_step_debian_rootless:
stage: docker
type: push
title: "Push debian release image"
image_name: codefresh/cli
tags:
- ${{PACKAGE_VERSION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
- latest${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
scale:
push_to_dockerhub_debian_rootless:
registry: dockerhub
title: "push to dockerhub"
candidate: codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
push_to_gcr_debian_rootless:
title: "push to gcr"
candidate: gcr.io/codefresh-inc/codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
push_to_quay_debian_rootless:
registry: cf-quay
title: "push to quay.io"
candidate: quay.io/codefresh/cli:${{CF_SHORT_REVISION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
when:
steps:
- name: extract_version
on:
- success
create_manifest_list:
stage: docker
type: "codefresh-inc/multiarch-manifester"
arguments:
image_name: codefresh/cli
arch_tag_postfixes:
arm64: "${{ARM_TAG_POSTFIX}}"
registries:
- name: 'quay.io'
username: '${{QUAY_USERNAME}}'
password: '${{QUAY_PASSWORD}}'
- name: 'docker.io'
username: '${{DOCKERHUB_USERNAME}}'
password: '${{DOCKERHUB_PASSWORD}}'
- name: 'gcr.io'
path_prefix: codefresh-inc
username: '${{GCR_CODEFRESH_INC_USERNAME}}'
password: '${{GCR_CODEFRESH_INC_PASSWORD}}'
scale:
master_branch_tags_alpine:
arguments:
tags:
- ${{PACKAGE_VERSION}}
- latest
master_branch_tags_debian:
arguments:
tags:
- ${{PACKAGE_VERSION}}${{DEBIAN_TAG_POSTFIX}}
- latest${{DEBIAN_TAG_POSTFIX}}
master_branch_tags_alpine_rootless:
arguments:
tags:
- ${{PACKAGE_VERSION}}${{ROOTLESS_TAG_POSTFIX}}
- latest${{ROOTLESS_TAG_POSTFIX}}
master_branch_tags_debian_rootless:
arguments:
tags:
- ${{PACKAGE_VERSION}}${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
- latest${{DEBIAN_TAG_POSTFIX}}${{ROOTLESS_TAG_POSTFIX}}
when:
steps:
- name: push_step_alpine
on:
- success
- name: push_step_debian
on:
- success
- name: push_step_alpine_rootless
on:
- success
- name: push_step_debian_rootless
on:
- success
compile_executables:
stage: build
title: "Compiling executables"
image: codefresh/build-cli
commands:
- "rm -rf dist"
- "yarn pkg"
when:
steps:
- name: generate_comletion
on:
- success
archive_linux:
stage: build
title: "Archiving linux distribution"
image: codefresh/build-cli
commands:
- "rm -rf ./dist/linux"
- "mkdir -p ./dist/linux"
- "cp --force README.md LICENSE ./dist/linux"
- "cp --force ./dist/codefresh-linux ./dist/linux/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar README.md LICENSE -C ./dist/linux codefresh"
- "gzip -f codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar"
when:
steps:
- name: compile_executables
on:
- success
archive_macos:
stage: build
title: "Archiving macos distribution"
image: codefresh/build-cli
commands:
- "rm -rf ./dist/macos"
- "mkdir -p ./dist/macos"
- "cp --force README.md LICENSE ./dist/macos"
- "cp --force ./dist/codefresh-macos ./dist/macos/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar README.md LICENSE -C ./dist/macos codefresh"
- "gzip -f codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar"
when:
steps:
- name: compile_executables
on:
- success
archive_win:
stage: build
title: "Archiving win distribution"
image: codefresh/build-cli
commands:
- "rm -rf ./dist/win"
- "mkdir -p ./dist/win"
- "cp --force README.md LICENSE ./dist/win"
- "cp --force ./dist/codefresh-win.exe ./dist/win/codefresh.exe"
- "zip codefresh-v${{PACKAGE_VERSION}}-win-x64.zip README.md LICENSE -j ./dist/win/codefresh.exe "
when:
steps:
- name: compile_executables
on:
- success
archive_alpine:
stage: build
title: "Archiving macos distribution"
image: codefresh/build-cli
commands:
- "rm -rf ./dist/alpine"
- "mkdir -p ./dist/alpine"
- "cp --force README.md LICENSE ./dist/alpine"
- "cp --force ./dist/codefresh-alpine ./dist/alpine/codefresh"
- "tar -cf codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar README.md LICENSE -C ./dist/alpine codefresh"
- "gzip -f codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar"
when:
steps:
- name: compile_executables
on:
- success
create_release:
stage: github
title: "Create github release"
image: codefresh/build-cli
fail_fast: false
commands:
- 'curl --fail -X POST -d ''{"tag_name":"v${{PACKAGE_VERSION}}","target_commitish":"${{CF_REVISION}}","name":"Codefresh V${{PACKAGE_VERSION}}"}'' -H "Content-Type: application/json" -H "Authorization: token ${{GITHUB_TOKEN}}" https://api.github.com/repos/codefresh-io/cli/releases'
when:
steps:
- name: compile_executables
on:
- success
get_release:
stage: github
title: "Get github release"
image: codefresh/build-cli
commands:
- "curl --fail https://api.github.com/repos/codefresh-io/cli/releases/tags/v${{PACKAGE_VERSION}}"
- "export GITHUB_RELEASE_ID=$(curl --fail https://api.github.com/repos/codefresh-io/cli/releases/tags/v${{PACKAGE_VERSION}} | jq -r '.id')"
- "echo Github release id: $GITHUB_RELEASE_ID"
- "cf_export GITHUB_RELEASE_ID"
when:
steps:
- name: create_release
on:
- success
- failure
upload_linux:
stage: github
title: "Upload linux executable to github release"
image: codefresh/build-cli
commands:
# upload linux-x64 asset
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-linux-x64.tar.gz'
when:
steps:
- name: get_release
on:
- success
- name: archive_linux
on:
- success
upload_macos:
stage: github
title: "Upload macos executable to github release"
image: codefresh/build-cli
commands:
# upload macos-x64 asset
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-macos-x64.tar.gz'
when:
steps:
- name: get_release
on:
- success
- name: archive_macos
on:
- success
upload_win:
stage: github
title: "Upload win executable to github release"
image: codefresh/build-cli
commands:
# upload win-x64 asset
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-win-x64.zip https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-win-x64.zip'
when:
steps:
- name: get_release
on:
- success
- name: archive_win
on:
- success
upload_alpine:
stage: github
title: "Upload alpine executable to github release"
image: codefresh/build-cli
commands:
# upload alpine-x64 asset
- 'curl --fail -X POST -H "Content-Type:application/octet-stream" -H "Authorization: token ${{GITHUB_TOKEN}}" --data-binary @codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar.gz https://uploads.github.com/repos/codefresh-io/cli/releases/${{GITHUB_RELEASE_ID}}/assets?name=codefresh-v${{PACKAGE_VERSION}}-alpine-x64.tar.gz'
when:
steps:
- name: get_release
on:
- success
- name: archive_alpine
on:
- success
deploy_to_npm:
stage: packages
title: "Publishing To Npm"
type: npm-publish
arguments:
NPM_TOKEN: '${{NPM_TOKEN}}'
DIR: ./cli
when:
steps:
- name: generate_comletion
on:
- success
update_brew_formula:
stage: packages
title: "Updating homebrew formula"
image: codefresh/build-cli
commands:
- VERSION=v${{PACKAGE_VERSION}}
- curl -L https://github.com/codefresh-io/cli/releases/download/$VERSION/codefresh-$VERSION-macos-x64.tar.gz > $VERSION.tar.gz
- echo "compute SHA256 ..."
- SHA256="$(shasum -a 256 ./$VERSION.tar.gz | awk '{print $1}')"
- echo "generate file from template ..."
- sed -e "s/{{ VERSION }}/$VERSION/g" -e "s/{{ SHA256 }}/$SHA256/g" ./brew/template.rb > codefresh.rb
- echo "Updating file in GitHub"
- |
curl -v -i -X PUT -H 'Authorization: token '${{GITHUB_TOKEN}}'' -d "{ \
\"message\": \"update formula version $VERSION\", \
\"content\": \"$(openssl base64 -A -in codefresh.rb)\", \
\"sha\": $(curl -X GET https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/codefresh.rb | jq .sha) \
}" https://api.github.com/repos/codefresh-io/homebrew-cli/contents/Formula/codefresh.rb
when:
steps:
- name: upload_macos
on:
- success
update_documentation:
stage: documentation
title: "Update documentation http://cli.codefresh.io"
image: docker:18.01
commands:
- "apk update && apk add git nodejs"
- "npm install"
- "echo cleaning previous public dir and recreating worktree"
- "rm -rf public && git worktree prune && git worktree add -B gh-pages public origin/gh-pages"
- "echo Building public docs"
- "npm run build-public-docs"
- "echo Push new docs to gh-pages detached branch"
- 'git config --global user.email "[email protected]" && git config --global user.name "Automated CI"'
- 'cd public && git add --all && git commit -m "Publish new documentation for version ${{PACKAGE_VERSION}}" && git push https://${{GITHUB_TOKEN}}@github.com/codefresh-io/cli.git'
environment:
- HUGO_VERSION=0.32.0
when:
steps:
- name: upload_linux
on:
- success
- name: upload_macos
on:
- success
- name: upload_win
on:
- success
- name: upload_alpine
on:
- success
- name: update_brew_formula
on:
- success
- name: deploy_to_npm
on:
- success
- name: create_manifest_list
on:
- success