-
Notifications
You must be signed in to change notification settings - Fork 59
340 lines (290 loc) · 11.7 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
name: Release
on:
create:
tags:
- v*
jobs:
build-runtime:
runs-on: ubuntu-latest
env:
SUBWASM_VERSION: 0.15.0
strategy:
matrix:
chain: ["alpha","main","ipci"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Srtool build
id: srtool_build
uses: chevdor/srtool-actions@v0.3.0
with:
chain: ${{ matrix.chain }}
- name: Summary
shell: bash
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 }}"
- name: Archive Artifacts for ${{ matrix.chain }}
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ steps.srtool_build.outputs.wasm }}
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ matrix.chain }}-srtool-digest.json
- name: Install subwasm
shell: bash
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: Install deps
run: sudo apt-get -y install protobuf-compiler
- 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
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@v2
with:
name: ${{ matrix.chain }}-runtime
path: |
${{ matrix.chain }}-info.json
${{ matrix.chain }}-compressed-info.json
${{ matrix.chain }}-metadata.json
${{ matrix.chain }}-diff.txt
build-binary:
name: Build binary
runs-on: ubuntu-20.04
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
steps:
- name: Checkout the source code
uses: actions/checkout@v2
- name: Install deps
run: sudo apt-get -y install protobuf-compiler
- name: Install ARM64 multilib
if: contains(matrix.target, 'aarch64')
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
mkdir .cargo
printf '[target.aarch64-unknown-linux-gnu]\nlinker = "aarch64-linux-gnu-gcc"' > .cargo/config
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-08-05
target: ${{ matrix.target }}
components: rustfmt, clippy
default: true
- name: Install WASM target (for runtime building)
shell: bash
run: rustup target add wasm32-unknown-unknown --toolchain nightly-2022-08-05
- name: Build optimized binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.target }}
- name: Upload build artifacts
uses: actions/upload-artifact@master
with:
name: ${{ matrix.target }}
path: target/${{ matrix.target }}/release/robonomics
docker:
name: Docker
needs: build-binary
runs-on: ubuntu-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2.2.1
- name: Login to DockerHub
uses: docker/login-action@v2.1.0
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-custom: latest
tag-sha: true # add git short SHA as Docker tag
- name: create dirs
shell: bash
run: mkdir scripts/docker/amd64/ scripts/docker/arm64/
- name: get amd64 binary
uses: actions/download-artifact@v2
with:
name: x86_64-unknown-linux-gnu
path: scripts/docker/amd64/
- name: get aarch64 binary
uses: actions/download-artifact@v2
with:
name: aarch64-unknown-linux-gnu
path: scripts/docker/arm64/
- name: Chmod binary
shell: bash
run: |
chmod +x scripts/docker/amd64/robonomics
chmod +x scripts/docker/arm64/robonomics
- name: 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
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v2
- uses: cachix/install-nix-action@v12
with:
nix_path: nixpkgs=channel:nixos-21.11
- name: Build crates documentation
run: nix-shell --run "cargo doc --workspace --no-deps"
- name: Push index.html
run: echo "<meta http-equiv=\"refresh\" content=\"0; URL='./robonomics/index.html'\" />" > ./target/doc/index.html
- name: Deploy crates.robonomics.network
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
cname: crates.robonomics.network
release:
name: Release
needs:
- build-binary
- build-runtime
runs-on: ubuntu-latest
steps:
- name: Checkout the source code
uses: actions/checkout@v2
- id: get_version
uses: battila7/get-version-action@v2
- name: Create dir
shell: bash
run: |
mkdir -p release/tmp/
cd release/tmp/
mkdir robonomics robonomics-alpha robonomics-ipci x86_64 aarch64
- name: get x86_64 binary
uses: actions/download-artifact@v2
with:
name: x86_64-unknown-linux-gnu
path: release/tmp/x86_64/
- name: get aarch64 binary
uses: actions/download-artifact@v2
with:
name: aarch64-unknown-linux-gnu
path: release/tmp/aarch64/
- uses: actions/download-artifact@v2
with:
name: main-runtime
path: release/tmp/robonomics
- uses: actions/download-artifact@v2
with:
name: alpha-runtime
path: release/tmp/robonomics-alpha
- uses: actions/download-artifact@v2
with:
name: ipci-runtime
path: release/tmp/robonomics-ipci
- id: compress_artefacts
shell: bash
run: |
cd release/
echo "::set-output name=main::$(jq -r '.core_version' tmp/robonomics/main-info.json | awk '{print $1}')"
echo "::set-output name=alpha::$(jq -r '.core_version' tmp/robonomics-alpha/alpha-info.json | awk '{print $1}')"
chmod +x tmp/x86_64/robonomics tmp/aarch64/robonomics
tar -czvf robonomics-"${{ steps.get_version.outputs.version-without-v }}"-x86_64-unknown-linux-gnu.tar.gz -C tmp/x86_64/ robonomics
tar -czvf robonomics-"${{ steps.get_version.outputs.version-without-v }}"-aarch64-unknown-linux-gnu.tar.gz -C tmp/aarch64/ robonomics
cd tmp/robonomics;tar -czvf ../../runtime-"$(jq -r '.core_version' main-info.json | awk '{print $1}')".tar.gz *;cd ../../
cd tmp/robonomics-alpha;tar -czvf ../../runtime-"$(jq -r '.core_version' alpha-info.json | awk '{print $1}')".tar.gz *;cd ../../
cd tmp/robonomics-ipci;tar -czvf ../../runtime-"$(jq -r '.core_version' ipci-info.json | awk '{print $1}')".tar.gz *;cd ../../
echo "${{ steps.get_version.outputs.version-without-v }}" > version
sha256sum *.tar.gz > sha256sum
rm -rf tmp/
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Pining artefacts to IPFS
uses: aquiladev/ipfs-action@v0.2.0
id: ipfs
with:
path: ./release/
service: pinata
pinataKey: ${{ secrets.PINATA_KEY }}
pinataSecret: ${{ secrets.PINATA_SECRET }}
pinataPinName: ${{ steps.get_version.outputs.version }}
- name: Update DNS
if: contains(github.ref, 'rc') == false
shell: bash
run: |
curl -X PUT -H"Authorization: sso-key ${{ secrets.GODADDY_KEY }}:${{ secrets.GODADDY_SECRET }}" "https://api.godaddy.com/v1/domains/robonomics.network/records/TXT/_dnslink.get" -H "Content-Type: application/json" -d "[{\"data\": \"dnslink=\/ipfs\/${{ steps.ipfs.outputs.ipfs }}\"}]"
- name: Create changelog text
id: changelog
uses: loopwerk/tag-changelog@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release body
id: gen_release_body
shell: bash
run: |
r="> Native runtimes: \`${{ steps.compress_artefacts.outputs.main }}\`, \`${{ steps.compress_artefacts.outputs.alpha }}\`"$'\n'
r=$r$'\n'
r=$r$'\n'"Changelog"
r=$r$'\n'"--------------"
r=$r$'\n'
r=$r$'\n'"$(echo '${{ steps.changelog.outputs.changes }}' | sed '1d')"
r=$r$'\n'
r=$r$'\n'"Downloads"
r=$r$'\n'"--------------"
r=$r$'\n'
r=$r$'\n'"[<img src=\"https://raw.githubusercontent.com/ipfs/logo/f5a1564a99db3244e288473f1a4d597f66f10df5/vector/ipfs-logo-vector-ice-text.svg\" width=\"200px\">](https://ipfs.io/ipfs/${{ steps.ipfs.outputs.ipfs }}) [<img src=\"https://www.docker.com/sites/default/files/d8/2019-07/vertical-logo-monochromatic.png\" height=\"200px\">](https://hub.docker.com/layers/robonomics/robonomics)"
r=$r$'\n'
r=$r$'\n'"| OS | ARCH | Link |"
r=$r$'\n'"|------|------|------|"
r=$r$'\n'"| Ubuntu | x86_64 | [Download](https://github.com/airalab/robonomics/releases/download/${{ steps.get_version.outputs.version }}/robonomics-${{ steps.get_version.outputs.version-without-v }}-x86_64-unknown-linux-gnu.tar.gz) |"
r=$r$'\n'"| Ubuntu | aarch64 | [Download](https://github.com/airalab/robonomics/releases/download/${{ steps.get_version.outputs.version }}/robonomics-${{ steps.get_version.outputs.version-without-v }}-aarch64-unknown-linux-gnu.tar.gz) |"
r=$r$'\n'
r="${r//'%'/'%25'}" # Multiline escape sequences for %
r="${r//$'\n'/'%0A'}" # Multiline escape sequences for '\n'
r="${r//$'\r'/'%0D'}" # Multiline escape sequences for '\r'
echo "::set-output name=RELEASE_BODY::$r"
- name: Upload assets to release
uses: softprops/action-gh-release@v1
with:
name: Robonomics ${{ steps.get_version.outputs.version }}
body: ${{ steps.gen_release_body.outputs.RELEASE_BODY }}
files: ./release/*
draft: true