This repository has been archived by the owner on Mar 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
307 lines (261 loc) · 9.89 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
name: Release
on:
push:
tags:
- "v*"
env:
DOCKER_REGISTRY: ghcr.io
jobs:
##
# Build the Rust package
##
build-package:
name: Build package [linux]
runs-on: ubuntu-latest
container:
image: ubuntu:18.04
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apt update -y
apt install --no-install-recommends -y \
ca-certificates curl git python3-pip zstd \
clang make gcc g++ libssl-dev pkg-config protobuf-compiler
pip3 install --upgrade pip
pip3 install cmake --upgrade
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: Cache target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --locked -p darwinia --features all-natives
- name: Collect shared
run: |
mkdir -p shared
tar cjSf shared/darwinia2-x86_64-linux-gnu.tar.bz2 -C target/release darwinia
tar cf shared/darwinia2-x86_64-linux-gnu.tar.zst -C target/release darwinia -I zstd
- name: Upload shared
uses: actions/upload-artifact@v2
with:
name: darwinia-artifact
path: shared
- name: Optimize cache
run: .github/shrink-cache.sh || exit 0
- uses: vishnudxb/[email protected]
if: failure()
with:
repo: darwinia-network/darwinia-2.0
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
##
# Generate subwasm info
##
build-subwasm:
name: Generate subwasm info
runs-on: ubuntu-latest
container:
image: ubuntu:22.04
strategy:
matrix:
runtime:
- darwinia
- crab
- pangolin
- pangoro
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apt update -y
apt install --no-install-recommends -y \
ca-certificates curl git python3-pip \
clang make gcc g++ libssl-dev pkg-config protobuf-compiler
pip3 install --upgrade pip
pip3 install cmake --upgrade
- name: Install subwasm
env:
# Currently, Same with srtool version v0.9.25
# https://github.com/paritytech/srtool/blob/v0.9.25/Dockerfile#L27
SUBWASM_VERSION: 0.18.0
run: |
curl -L https://github.com/chevdor/subwasm/releases/download/v${SUBWASM_VERSION}/subwasm_linux_amd64_v${SUBWASM_VERSION}.deb \
--output subwasm.deb && \
dpkg -i subwasm.deb && \
subwasm --version
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown
- name: Cache target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build runtime
run: |
set -xe
RUNTIME_DIR=runtime/${{ matrix.runtime }}
cargo build \
--manifest-path runtime/${{ matrix.runtime }}/Cargo.toml \
--release \
# --features on-chain-release-build # not have this feature currently
- name: Collect shared
run: |
mkdir -p shared/${{ matrix.runtime }}-runtime
mv target/release/wbuild/${{ matrix.runtime }}-runtime/*.wasm \
shared/${{ matrix.runtime }}-runtime
- name: Generate subwasm info for ${{ matrix.runtime }}-runtime
run: |
set -xe
Z_WASM=shared/${{ matrix.runtime }}-runtime/*.compact.compressed.wasm
echo '${{ matrix.runtime }}-runtime compressed compact subwasm info'
subwasm -j info $Z_WASM | tee shared/${{ matrix.runtime }}-runtime/${{ matrix.runtime }}-runtime.compact.compressed.json
- name: Upload shared
uses: actions/[email protected]
with:
name: darwinia-artifact
path: shared
- name: Optimize cache
run: .github/shrink-cache.sh || exit 0
- uses: vishnudxb/[email protected]
if: failure()
with:
repo: darwinia-network/darwinia-2.0
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
##
# Build and publish the Docker image
##
build-docker-image:
name: Build Docker image
runs-on: ubuntu-latest
needs: [build-package]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
with:
name: darwinia-artifact
path: shared
- uses: olegtarasov/[email protected]
- uses: benjlevesque/[email protected]
- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.DOCKER_REGISTRY }}
- name: Extract shared
run: |
mkdir -p dist
tar -xvf shared/darwinia2-x86_64-linux-gnu.tar.bz2 -C dist/
- name: Publish docker image
uses: docker/build-push-action@v3
with:
push: true
context: .
file: .maintain/docker/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}:sha-${{ env.SHA }}
# todo: merge to above
- name: Publish docker image with tag
uses: docker/build-push-action@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
push: true
context: .
file: .maintain/docker/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}:${{ env.GIT_TAG_NAME }}
##
# Publish the release
##
publish-release:
name: Publish release
runs-on: ubuntu-latest
needs: [build-package, build-subwasm, build-docker-image]
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v2
with:
name: darwinia-artifact
path: shared
- name: Prepare deploy folder
run: |
mkdir -p deploy
mv shared/darwinia2-x86_64-linux-gnu.tar.zst deploy/
mv shared/darwinia2-x86_64-linux-gnu.tar.bz2 deploy/
mv shared/*-runtime/*.compact.compressed.* deploy/
- name: Hash file
run: |
(cd deploy && sha256sum * | tee sha256sums.txt)
- uses: olegtarasov/[email protected]
- uses: benjlevesque/[email protected]
- name: Generate template data
run: |
FILE_CRAB=deploy/crab-runtime.compact.compressed.json
FILE_DARWINIA=deploy/darwinia-runtime.compact.compressed.json
FILE_PANGOLIN=deploy/pangolin-runtime.compact.compressed.json
FILE_PANGORO=deploy/pangoro-runtime.compact.compressed.json
PROPOSAL_CRAB_COMPRESSED=$(cat ${FILE_CRAB} | jq -r .proposal_hash)
RUNTIME_VERSION_CRAB=$(cat ${FILE_CRAB} | jq .core_version.specVersion)
PROPOSAL_DARWINIA_COMPRESSED=$(cat ${FILE_DARWINIA} | jq -r .proposal_hash)
RUNTIME_VERSION_DARWINIA=$(cat ${FILE_DARWINIA} | jq .core_version.specVersion)
PROPOSAL_PANGOLIN_COMPRESSED=$(cat ${FILE_PANGOLIN} | jq -r .proposal_hash)
RUNTIME_VERSION_PANGOLIN=$(cat ${FILE_PANGOLIN} | jq .core_version.specVersion)
PROPOSAL_PANGORO_COMPRESSED=$(cat ${FILE_PANGORO} | jq -r .proposal_hash)
RUNTIME_VERSION_PANGORO=$(cat ${FILE_PANGORO} | jq .core_version.specVersion)
echo 'Template data:'
jq -n \
--arg crab_proposal_compressed "$PROPOSAL_CRAB_COMPRESSED" \
--arg crab_runtime_version "$RUNTIME_VERSION_CRAB" \
--arg darwinia_proposal_compressed "$PROPOSAL_DARWINIA_COMPRESSED" \
--arg darwinia_runtime_version "$RUNTIME_VERSION_DARWINIA" \
--arg pangolin_proposal_compressed "$PROPOSAL_PANGOLIN_COMPRESSED" \
--arg pangolin_runtime_version "$RUNTIME_VERSION_PANGOLIN" \
--arg pangoro_proposal_compressed "$PROPOSAL_PANGORO_COMPRESSED" \
--arg pangoro_runtime_version "$RUNTIME_VERSION_PANGORO" \
--arg tag "$GIT_TAG_NAME" \
--arg sha "$SHA" \
'{
crab_proposal_compressed: $crab_proposal_compressed,
crab_runtime_version: $crab_runtime_version,
darwinia_proposal_compressed: $darwinia_proposal_compressed,
darwinia_runtime_version: $darwinia_runtime_version,
pangolin_proposal_compressed: $pangolin_proposal_compressed,
pangolin_runtime_version: $pangolin_runtime_version,
pangoro_proposal_compressed: $pangoro_proposal_compressed,
pangoro_runtime_version: $pangoro_runtime_version,
tag: $tag,
sha: $sha
}' | tee shared/template_data.json
- name: Render release page
uses: jayamanikharyono/[email protected]
with:
datafile: shared/template_data.json
path: .github/release-template.md
# - name: Verify
# run: |
# set -xe
# cat .github/release-template.md
# ls -la deploy/
- name: Publish github release
uses: softprops/action-gh-release@v1
with:
files: |
deploy/*
body_path: ".github/release-template.md"
token: ${{ secrets.GITHUB_TOKEN }}
clean-artifacts:
name: Clean artifacts
runs-on: ubuntu-latest
needs: [publish-release]
if: always()
steps:
- uses: geekyeggo/delete-artifact@v1
with:
name: darwinia-artifact