299 lines (256 loc) · 8.95 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
name: Release
on:
push:
tags:
- "v*"
jobs:
##
# Build the Rust package
##
build-package:
name: Build package
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
apt update -y
apt install --no-install-recommends -y \
git curl ca-certificates \
make gcc g++ clang-4.0
- 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 darwinia
run: |
echo "::set-output name=BUILD_AT::$(date --iso-8601=seconds)"
cargo build --release --target x86_64-unknown-linux-gnu
- name: Collect shared
run: |
mkdir -p shared
mv target/x86_64-unknown-linux-gnu/release/darwinia shared/
- name: Upload shared
uses: actions/upload-artifact@v2.2.4
with:
name: darwinia-artifact
path: shared
- name: Optimize cache
run: .github/optimize-cache.sh || exit 0
- uses: vishnudxb/cancel-workflow@v1.2
if: failure()
with:
repo: darwinia-network/bridger
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:16.04
strategy:
matrix:
runtime: [crab, darwinia]
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
apt update -y
apt install --no-install-recommends -y \
git curl ca-certificates \
make gcc g++ clang-4.0
- name: Install subwasm
env:
# Currently, Same with srtool version v0.9.18
# https://github.com/paritytech/srtool/blob/v0.9.18/Dockerfile#L19
SUBWASM_VERSION: 0.15.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 darwinia
run: |
set -xe
RUNTIME_DIR=runtime/${{ matrix.runtime }}
cargo build \
--manifest-path runtime/${{ matrix.runtime }}/Cargo.toml \
--features on-chain-release-build \
--release \
--target x86_64-unknown-linux-gnu
- name: Collect shared
run: |
mkdir -p shared/${{ matrix.runtime }}-runtime
mv target/x86_64-unknown-linux-gnu/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/upload-artifact@v2.2.4
with:
name: darwinia-artifact
path: shared
- name: Optimize cache
run: .github/optimize-cache.sh || exit 0
- uses: vishnudxb/cancel-workflow@v1.2
if: failure()
with:
repo: darwinia-network/bridger
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@v2
- uses: actions/download-artifact@v2
with:
name: darwinia-artifact
path: shared
- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ secrets.QUAY_IO_BOT_USERNAME }}
password: ${{ secrets.QUAY_IO_BOT_PASSWORD }}
registry: quay.io
- uses: olegtarasov/get-tag@v2.1
id: tag-name
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 7
##
# Uploading artifacts does not retain the file permissions,
# binaries should regain the executive permission before packing.
# See: https://github.com/actions/upload-artifact#permission-loss
##
- name: Build and publish docker image
run: |
IMAGE_NAME=darwinia
IMAGE_PREFIX=quay.io/darwinia-network
IMAGE_PUSH_NAME_TAG=${IMAGE_PREFIX}/${IMAGE_NAME}:${GIT_TAG_NAME}
IMAGE_PUSH_NAME_SHA=${IMAGE_PREFIX}/${IMAGE_NAME}:sha-${SHA}
chmod +x shared/darwinia # REQUIRED, see above
docker build \
-t ${IMAGE_PUSH_NAME_TAG} \
-t ${IMAGE_PUSH_NAME_SHA} \
--build-arg CI_BUILD_AT=${{ needs.build-package.outputs.BUILD_AT }} \
--build-arg CI_GIT_TAG=${GIT_TAG_NAME} \
--build-arg CI_GIT_SHA=${{ github.sha }} \
-f .maintain/docker/Dockerfile \
.
docker push ${IMAGE_PUSH_NAME_TAG}
docker push ${IMAGE_PUSH_NAME_SHA}
##
# Publish the release
##
publish-release:
name: Publish release
runs-on: ubuntu-latest
needs: [build-package, build-subwasm, build-docker-image]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: darwinia-artifact
path: shared
- name: Prepare deploy folder
run: |
chmod +x shared/darwinia # REQUIRED, same as Docker image
tar cf darwinia-x86_64-linux-gnu.tar.zst -C shared darwinia -I pzstd
tar cjSf darwinia-x86_64-linux-gnu.tar.bz2 -C shared darwinia
mkdir -p deploy
mv darwinia-x86_64-linux-gnu.tar.zst deploy/
mv darwinia-x86_64-linux-gnu.tar.bz2 deploy/
mv shared/crab-runtime/*.compact.compressed.wasm deploy/
mv shared/crab-runtime/*.compact.compressed.json deploy/
mv shared/darwinia-runtime/*.compact.compressed.wasm deploy/
mv shared/darwinia-runtime/*.compact.compressed.json deploy/
- name: Hash file
run: |
(cd deploy && sha256sum * | tee sha256sums.txt)
- uses: olegtarasov/get-tag@v2.1
id: tag-name
- uses: benjlevesque/short-sha@v1.2
id: short-sha
with:
length: 7
- name: Generate template data
run: |
PROPOSAL_CRAB_COMPRESSED=$(cat deploy/crab-runtime.compact.compressed.json | jq -r .proposal_hash)
PROPOSAL_DARWINIA_COMPRESSED=$(cat deploy/darwinia-runtime.compact.compressed.json | jq -r .proposal_hash)
IMAGE_NAME=darwinia
IMAGE_PREFIX=quay.io/darwinia-network
IMAGE_PUSH_NAME_TAG=${IMAGE_PREFIX}/${IMAGE_NAME}:${GIT_TAG_NAME}
IMAGE_PUSH_NAME_SHA=${IMAGE_PREFIX}/${IMAGE_NAME}:sha-${SHA}
echo 'Template data:'
jq -n \
--arg crab_proposal_compressed "$PROPOSAL_CRAB_COMPRESSED" \
--arg darwinia_proposal_compressed "$PROPOSAL_DARWINIA_COMPRESSED" \
--arg image_tag "$IMAGE_PUSH_NAME_TAG" \
--arg image_sha "$IMAGE_PUSH_NAME_SHA" \
--arg tag "$GIT_TAG_NAME" \
--arg sha "$SHA" \
'{
crab_proposal_compressed: $crab_proposal_compressed,
darwinia_proposal_compressed: $darwinia_proposal_compressed,
image_tag: $image_tag,
image_sha: $image_sha,
tag: $tag,
sha: $sha
}' | tee shared/template_data.json
- name: Render release page
uses: jayamanikharyono/jinja-action@v0.1
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