-
Notifications
You must be signed in to change notification settings - Fork 12
303 lines (268 loc) · 18.5 KB
/
release.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
name: Release Dispatch
on:
repository_dispatch:
types: [release-command]
jobs:
create-release-branch:
runs-on: ubuntu-latest
steps:
- name: Get Environment Info
id: env_info
run: |
ISSUE_TITLE=$(jq -r .client_payload.github.payload.issue.title $GITHUB_EVENT_PATH)
echo ::set-output name=release::$(git ls-remote --heads https://github.com/$GITHUB_REPOSITORY $ISSUE_TITLE)
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH)
echo ::set-output name=issuetitle::$ISSUE_TITLE
- name: Create Release Branch
uses: peterjgrainger/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
branch: "${{ steps.env_info.outputs.issuetitle }}"
if: ${{ steps.env_info.outputs.release == null }}
- name: Alert that release already exists
run: |
echo "Release branch ${{ steps.env_info.outputs.issuetitle }} already exists. Skipping..."
if: ${{ steps.env_info.outputs.release != null }}
- name: Check if label exists
uses: actions/github-script@v1
id: label_check
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: "${{ steps.env_info.outputs.issuetitle }}"
})
- name: Create label to be used for release
uses: actions/github-script@v1
id: create_label
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: "${{ steps.env_info.outputs.issuetitle }}",
color: "2d5893"
})
if: ${{ steps.label_check.outcome == 'failure' }}
- name: Apply label to issue
uses: actions/github-script@v1
if: ${{ steps.create_label.outcome == 'success' }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: ${{steps.env_info.outputs.issuenm}},
labels: ["${{ steps.env_info.outputs.issuetitle }}"]
})
update-release-pointers:
runs-on: ubuntu-latest
needs: create-release-branch
env:
URL: ${{ secrets.RELEASE_NOTIFICATON_URL }}
## String to match for ImageTag replacement where applicable
ImageTagMatchString: 'imageTag:.*'
## End-to-End (E2E) testing - match string and replacement string
e2eTestMatchString: 'enabled: true'
e2eDisableReplacementString: 'enabled: false'
## Versions assignment for components that need both version and imageTag
FrontendVersion: ${{ github.event.client_payload.slash_command.args.named.frontend }}
FrontendImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.frontend }}'
BackendVersion: ${{ github.event.client_payload.slash_command.args.named.backend }}
BackendImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.backend }}'
GitApiVersion: ${{ github.event.client_payload.slash_command.args.named.gitapi }}
GitApiImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.gitapi }}'
StatusVersion: ${{ github.event.client_payload.slash_command.args.named.status }}
StatusImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.status }}'
ConfigVersion: ${{ github.event.client_payload.slash_command.args.named.config }}
ConfigImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.config }}'
ActivityVersion: ${{ github.event.client_payload.slash_command.args.named.activity }}
ActivityImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.activity }}'
ArtifactsVersion: ${{ github.event.client_payload.slash_command.args.named.artifacts }}
ArtifactsImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.artifacts }}'
EngagementsVersion: ${{ github.event.client_payload.slash_command.args.named.engagements }}
EngagementsImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.engagements }}'
EngagementStatusVersion: ${{ github.event.client_payload.slash_command.args.named.engagement-status }}
EngagementStatusImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.engagement-status }}'
HostingVersion: ${{ github.event.client_payload.slash_command.args.named.hosting }}
HostingImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.hosting }}'
ParticipantsVersion: ${{ github.event.client_payload.slash_command.args.named.participants }}
ParticipantsImageVersion: 'imageTag: ${{ github.event.client_payload.slash_command.args.named.participants }}'
## Variables for Status Service Versions - matching and replacement strings
Versions_FrontendMatchString: 'lodestar-frontend:.*'
Versions_FrontendVersion: 'lodestar-frontend: ${{ github.event.client_payload.slash_command.args.named.frontend }}'
Versions_BackendMatchString: 'lodestar-backend:.*'
Versions_BackendVersion: 'lodestar-backend: ${{ github.event.client_payload.slash_command.args.named.backend }}'
Versions_GitApiMatchString: 'lodestar-git-api:.*'
Versions_GitApiVersion: 'lodestar-git-api: ${{ github.event.client_payload.slash_command.args.named.gitapi }}'
Versions_StatusMatchString: 'lodestar-status:.*'
Versions_StatusVersion: 'lodestar-status: ${{ github.event.client_payload.slash_command.args.named.status }}'
Versions_ConfigMatchString: 'lodestar-config:.*'
Versions_ConfigVersion: 'lodestar-config: ${{ github.event.client_payload.slash_command.args.named.config }}'
Versions_ActivityMatchString: 'lodestar-activity:.*'
Versions_ActivityVersion: 'lodestar-activity: ${{ github.event.client_payload.slash_command.args.named.activity }}'
Versions_ArtifactsMatchString: 'lodestar-artifacts:.*'
Versions_ArtifactsVersion: 'lodestar-artifacts: ${{ github.event.client_payload.slash_command.args.named.artifacts }}'
Versions_EngagementsMatchString: 'lodestar-engagements:.*'
Versions_EngagementsVersion: 'lodestar-engagements: ${{ github.event.client_payload.slash_command.args.named.engagements }}'
Versions_EngagementStatusMatchString: 'lodestar-engagement-status:.*'
Versions_EngagementStatusVersion: 'lodestar-engagement-status: ${{ github.event.client_payload.slash_command.args.named.engagement-status }}'
Versions_HostingMatchString: 'lodestar-hosting:.*'
Versions_HostingVersion: 'lodestar-hosting ${{ github.event.client_payload.slash_command.args.named.hosting }}'
Versions_ParticipantsMatchString: 'lodestar-participants:.*'
Versions_ParticipantsVersion: 'lodestar-participants: ${{ github.event.client_payload.slash_command.args.named.participants }}'
Versions_DispatcherMatchString: 'resource-dispatcher:.*'
Versions_DispatcherVersion: 'resource-dispatcher: ${{ github.event.client_payload.slash_command.args.named.dispatcher }}'
## LodeStar Overall Version String - value obtained at runtime
Versions_LodeStarMatchString: 'lodestar:.*'
steps:
- name: Get Environment Info
id: env_info
run: |
ISSUE_TITLE=$(jq -r .client_payload.github.payload.issue.title $GITHUB_EVENT_PATH)
echo ::set-output name=issuetitle::$ISSUE_TITLE
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH)
echo ::set-output name=comment_url::$(jq .client_payload.github.payload.comment.html_url $GITHUB_EVENT_PATH)
echo ::set-output name=lodestarVersion::"lodestar: ${ISSUE_TITLE}"
- uses: actions/checkout@v2
with:
ref: ${{ steps.env_info.outputs.issuetitle }}
- name: Update LodeStar Frontend Release Info
if: ${{ github.event.client_payload.slash_command.args.named.frontend != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(e2eTestMatchString),strenv(e2eDisableReplacementString))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-frontend.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(FrontendImageVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-frontend.yaml ;
yq -i e '.spec.source.targetRevision = env(FrontendVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-frontend.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_FrontendMatchString),strenv(Versions_FrontendVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Backend Release Info
if: ${{ github.event.client_payload.slash_command.args.named.backend != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(BackendImageVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-backend.yaml ;
yq -i e '.spec.source.targetRevision = env(BackendVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-backend.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_BackendMatchString),strenv(Versions_BackendVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Git API Release Info
if: ${{ github.event.client_payload.slash_command.args.named.gitapi != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(GitApiImageVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-git-api.yaml ;
yq -i e '.spec.source.targetRevision = env(GitApiVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-git-api.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_GitApiMatchString),strenv(Versions_GitApiVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Config Release Info
if: ${{ github.event.client_payload.slash_command.args.named.config != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(ConfigImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-config.yaml ;
yq -i e '.spec.source.targetRevision = env(ConfigVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-config.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_ConfigMatchString),strenv(Versions_ConfigVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Activity Release Info
if: ${{ github.event.client_payload.slash_command.args.named.activity != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(ActivityImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-activity.yaml ;
yq -i e '.spec.source.targetRevision = env(ActivityVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-activity.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_ActivityMatchString),strenv(Versions_ActivityVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Artifacts Release Info
if: ${{ github.event.client_payload.slash_command.args.named.activity != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(ArtifactsImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-artifacts.yaml ;
yq -i e '.spec.source.targetRevision = env(ArtifactsVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-artifacts.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_ArtifactsMatchString),strenv(Versions_ArtifactsVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Engagements Release Info
if: ${{ github.event.client_payload.slash_command.args.named.engagements != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(EngagementsImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-engagements.yaml ;
yq -i e '.spec.source.targetRevision = env(EngagementsVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-engagements.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_EngagementsMatchString),strenv(Versions_EngagementsVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Engagement Status Release Info
if: ${{ github.event.client_payload.slash_command.args.named.engagement-status != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(EngagementStatusImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-engagement-status.yaml ;
yq -i e '.spec.source.targetRevision = env(EngagementStatusVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-engagement-status.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_EngagementStatusMatchString),strenv(Versions_EngagementStatusVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Hosting Release Info
if: ${{ github.event.client_payload.slash_command.args.named.hosting != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(HostingImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-hosting.yaml ;
yq -i e '.spec.source.targetRevision = env(HostingVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-hosting.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_HostingMatchString),strenv(Versions_HostingVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Participants Release Info
if: ${{ github.event.client_payload.slash_command.args.named.participants != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(ParticipantsImageVersion)| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-participants.yaml ;
yq -i e '.spec.source.targetRevision = env(ParticipantsVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-participants.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_ParticipantsMatchString),strenv(Versions_ParticipantsVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Status Release Info
if: ${{ github.event.client_payload.slash_command.args.named.status != null }}
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(ImageTagMatchString),strenv(StatusImageVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
yq -i e '.spec.source.targetRevision = env(StatusVersion)' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_StatusMatchString),strenv(Versions_StatusVersion))| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Update LodeStar Overall Version Info
uses: mikefarah/[email protected]
with:
cmd: >
yq -i e '. as $prnt | .spec.source.helm.values | . = sub(strenv(Versions_LodeStarMatchString),"${{ steps.env_info.outputs.lodestarVersion }}")| $prnt' $GITHUB_WORKSPACE/bootstrap/patches/lodestar-status.yaml ;
- name: Commit Release Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: "${{ steps.env_info.outputs.issuetitle }}"
commit_message: "Merging changes requested from ${{ steps.env_info.outputs.comment_url }}"
# - name: 'Get Previous tag'
# id: previoustag
# uses: actions-ecosystem/action-get-latest-tag@v1
- name: Fetch Previous Release Info
id: previous_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: rht-labs/lodestar-deployment
- name: Generate Release Body
id: release_body
run: |
echo ::set-output name=text::$(git log ${{ steps.previous_release.outputs.release }}..HEAD --pretty=format:"- %h %s by %an" --no-merges)
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.env_info.outputs.issuetitle }}
release_name: ${{ steps.env_info.outputs.issuetitle }}
body: ${{ steps.release_body.outputs.text }}
draft: false
prerelease: false
- name: Create Release Comment
uses: peter-evans/create-or-update-comment@v1
with:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: "${{ steps.env_info.outputs.issuenm }}"
body: |
Created release ${{ steps.env_info.outputs.issuetitle }}!
- name: Notify Chat
run: |
echo "Thread key ${{ steps.env_info.outputs.threadKey }} issue ${{ steps.env_info.outputs.issuenm }} "
[ ! -z "$URL" ] && curl "$URL&threadKey=$GITHUB_REPOSITORY-${{ steps.env_info.outputs.issuenm}}" -H "Content-Type: application/json" -d '{ "text" : "Release created *${{ steps.env_info.outputs.issuetitle }}*" }'