-
Notifications
You must be signed in to change notification settings - Fork 45
168 lines (150 loc) · 7.44 KB
/
branch-main.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
name: Production Release Workflow
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version in the format `vX.X.X`'
required: true
pull_request:
branches: [main]
types: [closed]
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}
jobs:
init:
name: Global init
if: ( github.event.pull_request.merged == true && startsWith(github.head_ref, 'rc/') || github.event_name == 'workflow_dispatch' )
runs-on: ubuntu-latest
outputs:
RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.release_version || steps.set_vars.outputs.RELEASE_VERSION }}
RELEASE_CANDIDATE_VERSION: ${{ github.event_name == 'workflow_dispatch' && format('{0}-rc', inputs.release_version) || steps.set_vars.outputs.RELEASE_CANDIDATE_VERSION }}
steps:
- name: Set release version
id: set_vars
run: |
echo "RELEASE_VERSION=v${GITHUB_HEAD_REF#rc/}" >> $GITHUB_OUTPUT
echo "RELEASE_CANDIDATE_VERSION=v${GITHUB_HEAD_REF#rc/}-rc" >> $GITHUB_OUTPUT
build-and-test:
needs: [init]
name: Build
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }}
branch: main
run-e2e-tests:
name: Run e2e tests
needs: [init,build-and-test]
uses: ./.github/workflows/reusable-e2e-tests.yml
secrets: inherit
permissions:
contents: write
id-token: write
deployments: write
checks: write
with:
globalVersion: ${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }}
parachainDocker: docker.io/mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }}
create-draft-release-and-publish-docker-images:
name: Create Draft Release and Publish Docker Images
needs: [init,run-e2e-tests,build-and-test]
environment: kusama
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
DOCKER_IMAGE_DIGEST: ${{ steps.export_docker_image.outputs.DOCKER_IMAGE_DIGEST }}
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Export docker image
id: export_docker_image
run: |
docker pull mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }}
docker save mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }} -o docker-${{ needs.init.outputs.RELEASE_VERSION }}.tar
zip -r docker-${{ needs.init.outputs.RELEASE_VERSION }}.zip docker-${{ needs.init.outputs.RELEASE_VERSION }}.tar
# Save docker image SHA256 digest as an output variable
echo "DOCKER_IMAGE_DIGEST=$(docker inspect mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }} --format='{{index .RepoDigests 0}}' | sed 's|mangatasolutions/mangata-node@||')" >> $GITHUB_OUTPUT
- name: Tag and push image rococo and kusama specific images
uses: akhilerm/[email protected]
with:
src: docker.io/mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }}
dst: |
docker.io/mangatasolutions/mangata-node:rococo-${{ needs.init.outputs.RELEASE_VERSION }}
docker.io/mangatasolutions/mangata-node:kusama-${{ needs.init.outputs.RELEASE_VERSION }}
- name: Extract wasms
run: |
docker run --entrypoint="" --rm mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }} cat /mangata/mangata_kusama_runtime.compact.compressed.wasm > kusama.wasm
docker run --entrypoint="" --rm mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_CANDIDATE_VERSION }} cat /mangata/mangata_rococo_runtime.compact.compressed.wasm > rococo.wasm
- name: Calculate Blake2 hashes
working-directory: scripts/blake2-hash
run: |
npm install
echo -n "kusama-${{ needs.init.outputs.RELEASE_VERSION }}.wasm [blake2]: " > hashes.txt
node index.js -i ../../kusama.wasm >> hashes.txt
echo -n "kusama-${{ needs.init.outputs.RELEASE_VERSION }}.wasm [md5sum]: " >> hashes.txt
md5sum ../../kusama.wasm | awk '{ print $1 }' >> hashes.txt
echo -n "kusama-${{ needs.init.outputs.RELEASE_VERSION }} spec version : " >> hashes.txt
grep -oE "spec_version:.*" ../../runtime/mangata-kusama/src/lib.rs | grep -oE "[0-9]+" | sort | tail -1 >> hashes.txt
echo -n "rococo-${{ needs.init.outputs.RELEASE_VERSION }}.wasm [blake2]: " >> hashes.txt
node index.js -i ../../rococo.wasm >> hashes.txt
echo -n "rococo-${{ needs.init.outputs.RELEASE_VERSION }}.wasm [md5sum]: " >> hashes.txt
md5sum ../../rococo.wasm | awk '{ print $1 }' >> hashes.txt
echo -n "rococo-${{ needs.init.outputs.RELEASE_VERSION }} spec version : " >> hashes.txt
grep -oE "spec_version:.*" ../../runtime/mangata-rococo/src/lib.rs | grep -oE "[0-9]+" | sort | tail -1 >> hashes.txt
- name: Rename artifacts
run: |
mv kusama.wasm kusama-${{ needs.init.outputs.RELEASE_VERSION }}.wasm
mv rococo.wasm rococo-${{ needs.init.outputs.RELEASE_VERSION }}.wasm
mv ./scripts/blake2-hash/hashes.txt hashes-and-versions-${{ needs.init.outputs.RELEASE_VERSION }}.txt
- name: Upload wasms to release page
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.init.outputs.RELEASE_VERSION }}
allowUpdates: false
generateReleaseNotes: true
draft: true
artifacts: "kusama-${{ needs.init.outputs.RELEASE_VERSION }}.wasm,rococo-${{ needs.init.outputs.RELEASE_VERSION }}.wasm,hashes-and-versions-${{ needs.init.outputs.RELEASE_VERSION }}.txt,docker-${{ needs.init.outputs.RELEASE_VERSION }}.zip"
deploy-rococo:
needs: [init,create-draft-release-and-publish-docker-images]
name: Deploy to Rococo
uses: ./.github/workflows/reusable-deploy-rococo.yml
secrets: inherit
with:
version: rococo-${{ needs.init.outputs.RELEASE_VERSION }}
deploy-kusama:
needs: [init,deploy-rococo]
name: Deploy to Kusama
uses: ./.github/workflows/reusable-deploy-kusama.yml
secrets: inherit
with:
version: kusama-${{ needs.init.outputs.RELEASE_VERSION }}
publish-release:
name: Publish release
needs: [init,deploy-kusama,create-draft-release-and-publish-docker-images]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Tag and push image
uses: akhilerm/[email protected]
with:
src: mangatasolutions/mangata-node@${{ needs.create-draft-release-and-publish-docker-images.outputs.DOCKER_IMAGE_DIGEST }}
dst: docker.io/mangatasolutions/mangata-node:${{ needs.init.outputs.RELEASE_VERSION }}
- name: Upload wasms to release page
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.init.outputs.RELEASE_VERSION }}
allowUpdates: true
omitBodyDuringUpdate: true
updateOnlyUnreleased: true