-
Notifications
You must be signed in to change notification settings - Fork 108
515 lines (455 loc) · 15.8 KB
/
publish-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
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
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
name: Publish Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version for Release.'
required: false
default: ''
skip_checks:
type: boolean
required: false
default: false
description: 'Use this to skip: gosec, gosec-cosmos, check-changelog, check-upgrade-uandler-updated, build-test, smoke-test and go straight to approval step.'
skip_release:
type: boolean
required: false
default: false
description: 'If this is true it will simply execute all the steps for a release prior to actually cutting the release, then stop'
concurrency:
group: publish-release
cancel-in-progress: false
jobs:
check_branch:
if: ${{ (startsWith(github.ref, 'refs/heads/release/v') || startsWith(github.ref, 'refs/heads/hotfix/v')) }}
runs-on: ubuntu-latest
steps:
- name: Branch
run: |
echo "${{ github.ref }}"
gosec:
needs:
- check_branch
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Run Gosec Security Scanner
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: securego/[email protected]
with:
args: ./...
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
gosec-cosmos:
needs:
- check_branch
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- name: Checkout Source
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Run Cosmos Gosec Security Scanner
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: make lint-cosmos-gosec
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
lint:
needs:
- check_branch
runs-on: ubuntu-latest
timeout-minutes: 15
env:
GO111MODULE: on
steps:
- name: Checkout Source
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.20'
- name: Run golangci-lint
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
skip-cache: true
args: --out-format=json
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
check-changelog:
needs:
- check_branch
runs-on: ubuntu-latest
steps:
- name: Checkout code
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get latest commit SHA of Develop & Current Branch
if: ${{ github.event.inputs.skip_checks != 'true' }}
id: get-develop-sha
run: |
SHA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/git/ref/heads/develop | jq -r '.object.sha')
echo "DEVELOP_SHA=${SHA}" >> ${GITHUB_ENV}
echo "CURRENT_BRANCH_SHA=${{ github.sha }}" >> ${GITHUB_ENV}
- name: Check for CHANGELOG.md changes
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: |
echo "Check the changelog has actually been updated from whats in develop"
echo "DEVELOP BRANCH SHA: ${DEVELOP_SHA}"
echo "CURRENT BRANCH SHA: ${CURRENT_BRANCH_SHA}"
CHANGELOG_DIFF=$(git diff ${DEVELOP_SHA}..${CURRENT_BRANCH_SHA} -- changelog.md)
echo "${CHANGELOG_DIFF}"
if [ -z "$CHANGELOG_DIFF" ]; then
echo "ERROR: No changes detected in CHANGELOG.md. Please update the changelog."
exit 1
else
echo "CHANGELOG.md has been updated."
fi
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
check-upgrade-handler-updated:
needs:
- check_branch
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
if: ${{ github.event.inputs.skip_checks != 'true' }}
with:
fetch-depth: 0
- name: Major Version in Upgrade Handler Must Match Tag
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: |
UPGRADE_HANDLER_MAJOR_VERSION=$(cat app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"' | cut -d '.' -f 1 | tr -d '\n')
USER_INPUT_VERSION=$(echo "${{ github.event.inputs.version }}" | cut -d '.' -f 1 | tr -d '\n')
echo "Upgrade Handler Major Version: ${UPGRADE_HANDLER_MAJOR_VERSION}"
echo "User Inputted Release Version: ${USER_INPUT_VERSION}"
if [ ${USER_INPUT_VERSION} != $UPGRADE_HANDLER_MAJOR_VERSION ]; then
echo "ERROR: The input version doesn't match the release handler for the branch selected. Please ensure the upgrade handler of the branch you selected when you ran the pipeline matches the input version."
echo "Did you forget to update the 'releaseVersion' in app/setup_handlers.go?"
exit 1
fi
echo "The major version found in 'releaseVersion' in app/setup_handlers.go matches this tagged release - Moving Forward!"
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
build-test:
needs:
- check_branch
runs-on: buildjet-4vcpu-ubuntu-2204
timeout-minutes: 15
concurrency:
group: "build-test"
steps:
- name: "Checkout Code"
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
- name: Set CPU Architecture
if: ${{ github.event.inputs.skip_checks != 'true' }}
shell: bash
run: |
if [ "$(uname -m)" == "aarch64" ]; then
echo "CPU_ARCH=arm64" >> $GITHUB_ENV
elif [ "$(uname -m)" == "x86_64" ]; then
echo "CPU_ARCH=amd64" >> $GITHUB_ENV
else
echo "Unsupported architecture" >&2
exit 1
fi
- name: Install Pipeline Dependencies
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: ./.github/actions/install-dependencies
timeout-minutes: 8
with:
cpu_architecture: ${{ env.CPU_ARCH }}
skip_python: "true"
skip_aws_cli: "true"
skip_docker_compose: "false"
- name: Test
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: nick-fields/retry@v2
with:
timeout_minutes: 20
max_attempts: 2
retry_on: error
command: |
echo "Running Build Tests"
make clean
make test-coverage
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
file: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
slug: zeta-chain/node
- name: Build zetacored and zetaclientd
if: ${{ github.event.inputs.skip_checks != 'true' }}
env:
CGO_ENABLED: 1
GOOS: linux
GOARCH: ${{ env.CPU_ARCH }}
run: |
make install
cp "$HOME"/go/bin/* ./
chmod a+x ./zetacored
./zetacored version
- name: Clean Up Workspace
if: always()
shell: bash
run: rm -rf *
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
smoke-test:
needs:
- check_branch
runs-on: buildjet-4vcpu-ubuntu-2204
timeout-minutes: 25
steps:
- name: "Checkout Code"
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
- name: Set CPU Architecture
if: ${{ github.event.inputs.skip_checks != 'true' }}
shell: bash
run: |
if [ "$(uname -m)" == "aarch64" ]; then
echo "CPU_ARCH=arm64" >> $GITHUB_ENV
elif [ "$(uname -m)" == "x86_64" ]; then
echo "CPU_ARCH=amd64" >> $GITHUB_ENV
else
echo "Unsupported architecture" >&2
exit 1
fi
- name: Install Pipeline Dependencies
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: ./.github/actions/install-dependencies
timeout-minutes: 8
with:
cpu_architecture: ${{ env.CPU_ARCH }}
skip_python: "false"
skip_aws_cli: "true"
skip_docker_compose: "false"
- name: Login to Docker Hub
uses: docker/login-action@v2
if: ${{ github.event.repository.full_name == 'zetachain-chain/node' && github.event.inputs.skip_checks != 'true' }}
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_READ_ONLY }}
- name: Build zetanode
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: |
make zetanode
- name: Start Private Network
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: |
cd contrib/localnet/
docker compose up -d zetacore0 zetacore1 zetaclient0 zetaclient1 eth bitcoin
- name: Run Smoke Test
if: ${{ github.event.inputs.skip_checks != 'true' }}
run: |
cd contrib/localnet
docker-compose up orchestrator --exit-code-from orchestrator
if [ $? -ne 0 ]; then
echo "Smoke Test Failed"
exit 1
fi
- name: Stop Private Network
if: ${{ always() && github.event.inputs.skip_checks != 'true' }}
run: |
cd contrib/localnet/
docker compose down
- name: Clean Up Workspace
if: always()
shell: bash
run: sudo rm -rf *
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
e2e-admin-tests:
needs:
- check_branch
runs-on: buildjet-4vcpu-ubuntu-2204
timeout-minutes: 120
steps:
- name: "Checkout Code"
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
- name: Execute e2e-admin-tests
if: ${{ github.event.inputs.skip_checks != 'true' }}
shell: bash
run: |
make start-e2e-admin-test
container_id=$(docker ps --filter "ancestor=orchestrator:latest" --format "{{.ID}}")
docker logs -f "${container_id}" & exit $(docker wait "${container_id}")
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
e2e-upgrade-test:
needs:
- check_branch
runs-on: buildjet-4vcpu-ubuntu-2204
timeout-minutes: 120
steps:
- name: "Checkout Code"
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
- name: Execute upgrade-test
if: ${{ github.event.inputs.skip_checks != 'true' }}
shell: bash
run: |
make start-upgrade-test
container_id=$(docker ps --filter "ancestor=orchestrator:latest" --format "{{.ID}}")
docker logs -f "${container_id}" & exit $(docker wait "${container_id}")
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
e2e-stateful-data-test:
needs:
- check_branch
runs-on: buildjet-4vcpu-ubuntu-2204
timeout-minutes: 120
steps:
- name: "Checkout Code"
if: ${{ github.event.inputs.skip_checks != 'true' }}
uses: actions/checkout@v3
- name: Execute stateful-data-test
if: ${{ github.event.inputs.skip_checks != 'true' }}
shell: bash
run: |
make start-e2e-import-mainnet-test
container_id=$(docker ps --filter "ancestor=orchestrator:latest" --format "{{.ID}}")
docker logs -f "${container_id}" & exit $(docker wait "${container_id}")
- name: Mark Job Complete Skipped
if: ${{ github.event.inputs.skip_checks == 'true' }}
shell: bash
run: |
echo "continue"
publish-release:
if: ${{ github.event.inputs.skip_release == 'false' }}
needs:
- gosec
- gosec-cosmos
- lint
- check-changelog
- check-upgrade-handler-updated
- smoke-test
- build-test
- e2e-admin-tests
- e2e-upgrade-test
- check_branch
- e2e-stateful-data-test
runs-on: ubuntu-20.04
timeout-minutes: 60
environment: release
steps:
- uses: actions/checkout@v3
- name: Install Pipeline Dependencies
uses: ./.github/actions/install-dependencies
timeout-minutes: 8
with:
cpu_architecture: ${{ env.CPU_ARCH }}
skip_python: "true"
skip_aws_cli: "true"
skip_docker_compose: "true"
- name: Change Log Release Notes.
id: release_notes
run: |
cat changelog.md > ${{ github.workspace }}-CHANGELOG.txt
cat ${{ github.workspace }}-CHANGELOG.txt
- name: Set Version
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ github.event.inputs.version }}" >> ${GITHUB_ENV}
- name: Set CPU Architecture
shell: bash
run: |
if [ "$(uname -m)" == "aarch64" ]; then
echo "CPU_ARCH=arm64" >> $GITHUB_ENV
elif [ "$(uname -m)" == "x86_64" ]; then
echo "CPU_ARCH=amd64" >> $GITHUB_ENV
else
echo "Unsupported architecture" >&2
exit 1
fi
- name: Create Release Tag
shell: bash
run: |
git tag ${GITHUB_TAG_MAJOR_VERSION}
create_tag=$(git push --tags || echo "tag exists")
if [[ $create_tag == "tag exists" ]]; then
echo "Delete existing tag to re-create"
git tag -d ${GITHUB_TAG_MAJOR_VERSION}
git push --delete origin ${GITHUB_TAG_MAJOR_VERSION}
echo "sleep for 5 seconds to let github catch up."
sleep 5
echo "Re-Create Tag."
git tag ${GITHUB_TAG_MAJOR_VERSION}
git push --tags
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
prerelease: true
token: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }}
body_path: ${{ github.workspace }}-CHANGELOG.txt
tag_name: ${{ env.GITHUB_TAG_MAJOR_VERSION }}
- name: Publish Release Files
env:
GITHUB_TOKEN: ${{ secrets.PAT_GITHUB_SERVICE_ACCT }}
GORELEASER_CURRENT_TAG: ${{ env.GITHUB_TAG_MAJOR_VERSION }}
run: |
touch .release-env
make release
- name: Clean Up Workspace
if: always()
shell: bash
run: sudo rm -rf * || echo "failed to cleanup workspace please investigate"