-
Notifications
You must be signed in to change notification settings - Fork 2
/
codefresh.yaml
207 lines (194 loc) · 4.72 KB
/
codefresh.yaml
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
version: '1.0'
mode: parallel
stages:
- Build & Test
- Push
- Github Release
steps:
main_clone:
stage: Build & Test
type: git-clone
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
git: ${{GIT_CONTEXT}}
revision: ${{CF_REVISION}}
calculate_version:
stage: Build & Test
title: 'Calculate latest version'
image: alpine:3.15
commands:
- cf_export VERSION=$(cat VERSION)
when:
steps:
- name: main_clone
on:
- success
test:
stage: Build & Test
image: golang
commands:
- make test
when:
steps:
- name: main_clone
on:
- success
build:
title: "Building image"
type: build
stage: Build & Test
disable_push: true
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
image_name: ${{IMAGE_NAME}}
when:
steps:
- name: main_clone
on:
- success
run_arm_build:
type: codefresh-run
stage: Build & Test
when:
steps:
- name: calculate_version
on:
- success
arguments:
PIPELINE_ID: ${{ARM_PIPELINE_ID}}
DETACH: false
VARIABLE:
- CF_REPO_OWNER=${{CF_REPO_OWNER}}
- CF_REPO_NAME=${{CF_REPO_NAME}}
- CF_REVISION=${{CF_REVISION}}
- CF_BRANCH=${{CF_BRANCH}}
- CF_BRANCH_TAG_NORMALIZED=${{CF_BRANCH_TAG_NORMALIZED}}
- GIT_CONTEXT=${{GIT_CONTEXT}}
- IMAGE_NAME=${{IMAGE_NAME}}
- VERSION=${{VERSION}}
- ARM_TAG_POSTFIX="${{ARM_TAG_POSTFIX}}"
push_dev_image:
title: "Pushing dev version of the image"
type: push
stage: Push
candidate: ${{build}}
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
when:
steps:
- name: build
on:
- success
scale:
push_quay_dev:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_dev:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_dev:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
push_prod_image:
title: "Pushing prod version of the image"
type: push
stage: Push
candidate: ${{build}}
tags:
- ${{VERSION}}
- 'latest'
when:
steps:
- name: build
on:
- success
branch:
only: [ master ]
scale:
push_quay_prod:
registry: "${{REGISTRY_INTEGRATION_QUAY}}"
push_dockerhub_prod:
registry: "${{REGISTRY_INTEGRATION_DOCKERHUB}}"
push_gcr_enterprise_prod:
registry: "${{REGISTRY_INTEGRATION_ENTERPRISE}}"
create_manifest_list:
stage: Push
type: "codefresh-inc/multiarch-manifester"
when:
steps:
- name: run_arm_build
on:
- success
arguments:
image_name: ${{IMAGE_NAME}}
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-enterprise
username: '${{GCR_USERNAME}}'
password: '${{GCR_PASSWORD}}'
scale:
master_branch_tags:
when:
branch:
only: [ master ]
steps:
- name: push_prod_image
on:
- success
arguments:
tags:
- ${{CF_BRANCH_TAG_NORMALIZED}}
- ${{VERSION}}
- latest
dev_branches_tags:
when:
branch:
ignore: [ master ]
steps:
- name: push_dev_image
on:
- success
arguments:
tags:
- ${{CF_BRANCH_TAG_NORMALIZED}}
create_git_tag:
title: Push tag to git
image: codefreshio/ci-helpers
stage: Github Release
commands:
- source /get-token/get-gh-token.sh
- cf_export GITHUB_TOKEN
- export OLD_ORIGIN=$(git remote get-url origin)
- git remote rm origin
- git remote add origin https://${GITHUB_TOKEN}@github.com/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}.git
- git tag v${{VERSION}}
- git push --tags
- git remote rm origin
- git remote add origin $OLD_ORIGIN
fail_fast: false
when:
steps:
- name: test
on:
- success
branch:
only:
- master
release_binaries:
title: Create release in Github
image: goreleaser/goreleaser
stage: Github Release
fail_fast: false
commands:
- go mod download
- goreleaser release -f goreleaser.yaml --rm-dist --skip-validate
when:
steps:
- name: create_git_tag
on:
- finished
branch:
only:
- master