-
Notifications
You must be signed in to change notification settings - Fork 59
400 lines (339 loc) · 12.8 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
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
name: Release Build
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:
env:
SUBWASM_VERSION: 0.16.1
jobs:
checks-and-tests:
runs-on: ubuntu-latest
steps:
- name: Free disk space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
df -h
- name: Checkout the source code
uses: actions/checkout@v3
- name: Install deps
run: sudo apt -y install protobuf-compiler
- name: Install & display rust toolchain
run: rustup show
- name: Check targets are installed correctly
run: rustup target list --installed
- name: Check all features compilation
run: cargo check --verbose --features runtime-benchmarks --locked
- name: Run all tests
run: cargo test --features runtime-benchmarks --locked
native-linux:
needs: checks-and-tests
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
steps:
- name: Checkout the source code
uses: actions/checkout@v3
- name: Install deps
run: sudo apt -y install protobuf-compiler
- name: aarch64 setup
if: contains(matrix.target, 'aarch64')
shell: bash
run: |
sudo apt update
sudo apt install -y gcc-multilib g++-multilib
sudo apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
mkdir -p .cargo
touch .cargo/config
printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' >> .cargo/config
- name: x86_64 setup
if: contains(matrix.target, 'x86_64')
run: |
mkdir -p .cargo
touch .cargo/config
printf '[target.x86_64-unknown-linux-gnu]\nrustflags = ["-Clink-arg=-fuse-ld=lld"]' >> .cargo/config
- name: Install & display rust toolchain
run: rustup show
- name: Add aarch64 target
if: contains(matrix.target, 'aarch64')
run: rustup target add ${{ matrix.target }}
- name: Check targets are installed correctly
run: rustup target list --installed
- name: Build optimized binary
run: CARGO_PROFILE_RELEASE_LTO=true RUSTFLAGS="-C codegen-units=1" cargo build --release --target ${{ matrix.target }} --verbose --locked
- name: Set artifact name
env:
TARGET: ${{ matrix.target }}
id: artifact-name
run: echo "::set-output name=name::robonomics-ubuntu-latest-${TARGET%%-*}"
- uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-name.outputs.name }}
path: target/${{ matrix.target }}/release/robonomics
native-macos:
needs: checks-and-tests
runs-on: macos-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v3
- name: Install deps
run: brew install protobuf sccache
- name: Install & display rust toolchain
run: rustup show
- name: Check targets are installed correctly
run: rustup target list --installed
- name: Build optimized binary
run: cargo build --release --verbose --locked
- uses: actions/upload-artifact@v3
with:
name: robonomics-macOS-latest-x86_64
path: target/release/robonomics
docker:
needs: native-linux
runs-on: ubuntu-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: robonomics/robonomics
tag-sha: true # add git short SHA as Docker tag
- name: Download pre-built amd64 linux collator binary
uses: actions/download-artifact@v3
with:
name: robonomics-ubuntu-latest-x86_64
path: scripts/docker/amd64/
- name: Download pre-built aarch64 linux collator binary
uses: actions/download-artifact@v3
with:
name: robonomics-ubuntu-latest-aarch64
path: scripts/docker/arm64/
- name: Make binary executable and copy it to docker folder
run: |
chmod +x scripts/docker/amd64/robonomics
chmod +x scripts/docker/arm64/robonomics
- name: Build & Push docker image
uses: docker/build-push-action@v3
with:
context: scripts/docker
platforms: linux/amd64,linux/arm64
labels: ${{ steps.docker_meta.outputs.labels }}
tags: ${{ steps.docker_meta.outputs.tags }}
push: true
srtool:
needs: checks-and-tests
runs-on: ubuntu-latest
strategy:
matrix:
chain: ["main"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Srtool build
id: srtool_build
uses: chevdor/srtool-actions@v0.8.0
with:
chain: ${{ matrix.chain }}
runtime_dir: runtime/${{ matrix.chain }}
- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json
cat ${{ matrix.chain }}-srtool-digest.json
echo "Compact Runtime: ${{ steps.srtool_build.outputs.wasm }}"
echo "Compressed Runtime: ${{ steps.srtool_build.outputs.wasm_compressed }}"
cp ${{ steps.srtool_build.outputs.wasm }} ${{ matrix.chain }}_runtime.compact.wasm
cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain }}_runtime.compact.compressed.wasm
# it takes a while to build the runtime, so let's save the artifact as soon as we have it
- name: Archive Artifacts for ${{ matrix.chain }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ matrix.chain }}_runtime.compact.wasm
${{ matrix.chain }}_runtime.compact.compressed.wasm
${{ matrix.chain }}-srtool-digest.json
# We now get extra information thanks to subwasm
- name: Install subwasm
run: |
wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb
subwasm --version
- name: Show Runtime information
shell: bash
run: |
subwasm info ${{ steps.srtool_build.outputs.wasm }}
subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }}
subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json
subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-compressed-info.json
- name: Extract the metadata
shell: bash
run: |
subwasm meta ${{ steps.srtool_build.outputs.wasm }}
subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json
- name: Check the metadata diff
shell: bash
# the following subwasm call will error for chains that are not known and/or live, that includes shell for instance
run: |
subwasm diff ${{ steps.srtool_build.outputs.wasm }} --chain-b ${{ matrix.chain }} || \
echo "Subwasm call failed, check the logs. This is likely because ${{ matrix.chain }} is not known by subwasm" | \
tee ${{ matrix.chain }}-diff.txt
- name: Archive Subwasm results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ matrix.chain }}-info.json
${{ matrix.chain }}-compressed-info.json
${{ matrix.chain }}-metadata.json
${{ matrix.chain }}-diff.txt
publish-release-draft:
needs: [native-linux, native-macOS, srtool]
runs-on: ubuntu-latest
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download main runtime
uses: actions/download-artifact@v3
with:
name: main-runtime
path: runtime-artifacts
- name: Use Node.js 18.x
uses: actions/setup-node@v2
with:
node-version: 18.x
- name: Get the latest release
id: latest-release
uses: pozetroninc/github-action-get-latest-release@v0.5.0
with:
repository: airalab/robonomics
excludes: "prerelease, draft"
- name: Generate Release Body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: generate-release-body
run: |
cd .github/scripts
yarn
yarn -s run ts-node generate-release-body.ts generate --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ steps.latest-release.outputs.release }}" --to "${{ github.ref_name }}" --srtool-report-folder '../../runtime-artifacts/' > ../../body.md
- name: Create Release Draft
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
body_path: body.md
draft: true
upload-binaries:
needs: publish-release-draft
runs-on: ubuntu-latest
strategy:
matrix:
os: ["ubuntu", "macOS"]
arch: ["x86_64", "aarch64"]
exclude:
- os: macOS
arch: aarch64
steps:
- name: Create download folder
run: |
mkdir -p ${{ matrix.os }}-${{ matrix.arch }}-bin
- name: Download pre-built collator binary
uses: actions/download-artifact@v3
with:
name: robonomics-${{ matrix.os }}-latest-${{ matrix.arch }}
path: ${{ matrix.os }}-${{ matrix.arch }}-bin
- name: Make binary executable and tar gzip
run: |
cd ${{ matrix.os }}-${{ matrix.arch }}-bin
chmod +x robonomics
tar zcvf robonomics.tar.gz robonomics
- name: Upload binary artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release-draft.outputs.upload_url }}
asset_path: ${{ matrix.os }}-${{ matrix.arch }}-bin/robonomics.tar.gz
asset_name: robonomics-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
asset_content_type: application/gzip
upload-runtimes:
needs: publish-release-draft
runs-on: ubuntu-latest
strategy:
matrix:
chain: ["main"]
steps:
- name: Download runtime
uses: actions/download-artifact@v3
with:
name: ${{ matrix.chain }}-runtime
- name: Get runtime version
id: get-runtime-version
run: |
ls -R
chain=${{ matrix.chain }}
runtime_version=$(cat $chain-compressed-info.json | jq '.core_version' | tr -d '"' | cut -d ' ' -f 1)
echo $runtime_version
echo "runtime=$(echo $runtime_version)" >> $GITHUB_ENV
echo "${{ matrix.chain }}=$(echo $runtime_version)" >> $GITHUB_OUTPUT
- name: Upload ${{ matrix.chain }} Wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release-draft.outputs.upload_url }}
asset_path: ${{ matrix.chain }}_runtime.compact.compressed.wasm
asset_name: ${{ env.runtime }}.wasm
asset_content_type: application/wasm
- name: Upload ${{ matrix.chain }} Metadata
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release-draft.outputs.upload_url }}
asset_path: ${{ matrix.chain }}-metadata.json
asset_name: ${{ matrix.chain }}-metadata.json
asset_content_type: application/json
- name: Upload ${{ matrix.chain }} Compressed Info
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release-draft.outputs.upload_url }}
asset_path: ${{ matrix.chain }}-compressed-info.json
asset_name: ${{ matrix.chain }}-compressed-info.json
asset_content_type: application/json
- name: Upload ${{ matrix.chain }} Srtool Digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release-draft.outputs.upload_url }}
asset_path: ${{ matrix.chain }}-srtool-digest.json
asset_name: ${{ matrix.chain }}-srtool-digest.json
asset_content_type: application/json
outputs:
main_runtime_version: ${{ steps.get-runtime-version.outputs.main }}