-
Notifications
You must be signed in to change notification settings - Fork 358
236 lines (223 loc) · 10.5 KB
/
publish-runtime.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
name: Publish Runtime Draft
# The code (like generate-release-body) will be taken from the tag versions, not master
on:
workflow_dispatch:
inputs:
from:
description: tag (ex. runtime-53) to retrieve commit diff from
required: true
to:
description: tag (ex. runtime-155) to generate release note and srtool runtimes from
required: true
jobs:
####### Build runtimes with srtool #######
setup-scripts:
runs-on: bare-metal
steps:
- uses: actions/checkout@v3
- name: Upload scripts
uses: actions/upload-artifact@v3
with:
name: original-scripts
path: scripts
- name: Upload tools
uses: actions/upload-artifact@v3
with:
name: original-tools
path: tools
build-srtool-runtimes:
needs: ["setup-scripts"]
runs-on: bare-metal
strategy:
matrix:
chain: ["moonbase", "moonriver", "moonbeam"]
srtool_image:
- moonbeamfoundation/srtool
srtool_image_tag:
- 1.70.0
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
- name: Login to DockerHub
uses: docker/[email protected]
if: github.repository == 'moonbeam-foundation/moonbeam'
with:
username: ${{ secrets.MBF_DOCKERHUB_USERNAME }}
password: ${{ secrets.MBF_DOCKERHUB_PASSWORD }}
registry: index.docker.io
- name: Download original scripts
uses: actions/download-artifact@v3
with:
name: original-scripts
path: original-scripts
- name: Build & Push moonbeamfoundation/srtool image
if: github.repository == 'moonbeam-foundation/moonbeam'
run: |
docker pull "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" && image_exists=true || image_exists=false
if [[ $image_exists = "false" ]]; then
echo building "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
docker build --pull --no-cache . \
-f docker/moonbeam-srtool.Dockerfile \
--build-arg SRTOOL_IMAGE_TAG=${{ matrix.srtool_image_tag }} \
-t ${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}
echo pushing "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
docker push "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
else
echo skiping build "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}", image already exists
fi
- name: Build runtime using "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
id: srtool_build
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE: ${{ matrix.srtool_image }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE_TAG: ${{ matrix.srtool_image_tag }}
run: |
# Ensure we have permissions to write to the runtime folder target for the docker user
mkdir -p runtime/${GH_WORKFLOW_MATRIX_CHAIN}/target
chmod uog+rwX runtime/${GH_WORKFLOW_MATRIX_CHAIN}/target
chmod u+x ./original-scripts/build-runtime-srtool.sh
./original-scripts/build-runtime-srtool.sh
- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.chain }}-srtool-digest.json
cat ${{ matrix.chain }}-srtool-digest.json
cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}-runtime.compact.compressed.wasm
- name: Archive Artifacts for ${{ matrix.chain }}
uses: actions/[email protected]
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ matrix.chain }}-runtime.compact.compressed.wasm
${{ matrix.chain }}-srtool-digest.json
- name: Cleanup
run: |
echo "Removing runtime/${{ matrix.chain }}/target"
ls -lna runtime/${{ matrix.chain }}/target
# Removing using docker root to ensure we have permissions
docker run -u 0 -v $(pwd)/runtime/${{ matrix.chain }}/:/runtime \
-it --entrypoint bash ${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }} -c "id; ls -lna /runtime/target; rm -rf /runtime/target"
####### Prepare the release draft #######
publish-draft-release:
runs-on: ubuntu-latest
needs: ["setup-scripts", "build-srtool-runtimes"]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Download moonbase runtime
uses: actions/[email protected]
with:
name: moonbase-runtime
path: build
- name: Download moonriver runtime
uses: actions/[email protected]
with:
name: moonriver-runtime
path: build
- name: Download moonbeam runtime
uses: actions/[email protected]
with:
name: moonbeam-runtime
path: build
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Download Original Tools
uses: actions/download-artifact@v3
with:
name: original-tools
path: original-tools
- name: Generate release body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: generate-release-body
working-directory: original-tools
run: |
yarn
yarn -s run ts-node github/generate-runtimes-body.ts --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ github.event.inputs.from }}" --to "${{ github.event.inputs.to }}" --srtool-report-folder '../build/' > ../body.md
- name: Get runtime version
id: get-runtime-ver
run: |
runtime_moonbase_ver="$(cat ./runtime/moonbase/src/lib.rs | grep -o 'spec_version: [0-9]*' | tail -1 | grep -o '[0-9]*')"
echo "runtime_moonbase_ver=$runtime_moonbase_ver" >> $GITHUB_OUTPUT
mv build/moonbase-runtime.compact.compressed.wasm moonbase-runtime-${runtime_moonbase_ver}.wasm
mv build/moonbase-srtool-digest.json moonbase-runtime-${runtime_moonbase_ver}-srtool-digest.json
runtime_moonriver_ver="$(cat ./runtime/moonriver/src/lib.rs | grep -o 'spec_version: [0-9]*' | tail -1 | grep -o '[0-9]*')"
echo "runtime_moonriver_ver=$runtime_moonriver_ver" >> $GITHUB_OUTPUT
mv build/moonriver-runtime.compact.compressed.wasm moonriver-runtime-${runtime_moonriver_ver}.wasm
mv build/moonriver-srtool-digest.json moonriver-runtime-${runtime_moonriver_ver}-srtool-digest.json
runtime_moonbeam_ver="$(cat ./runtime/moonbeam/src/lib.rs | grep -o 'spec_version: [0-9]*' | tail -1 | grep -o '[0-9]*')"
echo "runtime_moonbeam_ver=$runtime_moonbeam_ver" >> $GITHUB_OUTPUT
mv build/moonbeam-runtime.compact.compressed.wasm moonbeam-runtime-${runtime_moonbeam_ver}.wasm
mv build/moonbeam-srtool-digest.json moonbeam-runtime-${runtime_moonbeam_ver}-srtool-digest.json
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.to }}
release_name: Runtime ${{ github.event.inputs.to }}
body_path: body.md
draft: true
- name: Upload moonbase wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonbase-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbase_ver }}.wasm
asset_name: moonbase-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbase_ver }}.wasm
asset_content_type: application/octet-stream
- name: Upload moonbase srtool digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonbase-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbase_ver }}-srtool-digest.json
asset_name: moonbase-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbase_ver }}.srtool-digest.json
asset_content_type: application/json
- name: Upload moonriver wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonriver-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonriver_ver }}.wasm
asset_name: moonriver-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonriver_ver }}.wasm
asset_content_type: application/octet-stream
- name: Upload moonriver srtool digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonriver-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonriver_ver }}-srtool-digest.json
asset_name: moonriver-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonriver_ver }}.srtool-digest.json
asset_content_type: application/json
- name: Upload moonbeam wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonbeam-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbeam_ver }}.wasm
asset_name: moonbeam-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbeam_ver }}.wasm
asset_content_type: application/octet-stream
- name: Upload moonbeam srtool digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: moonbeam-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbeam_ver }}-srtool-digest.json
asset_name: moonbeam-runtime-${{ steps.get-runtime-ver.outputs.runtime_moonbeam_ver }}.srtool-digest.json
asset_content_type: application/json