-
Notifications
You must be signed in to change notification settings - Fork 20
567 lines (558 loc) · 21 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
name: Release
concurrency:
group: ${{github.workflow}}-${{github.ref}}
cancel-in-progress: true
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # ex. v0.29.9
- "v[0-9]+.[0-9]+.[0-9]+-[0-9]+" # ex. v0.29.9-1
- "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # ex. v0.29.9-1-rc1
- "vX.X.X" # used for testing only
env:
RUST_TOOLCHAIN: nightly-2022-09-22 # Update this when updating the Rust toolchain
NEW_RELEASE_VERSION: ${{github.ref_name}}
NEW_RELEASE_TAG: ${{github.ref_name}}
jobs:
build-binaries:
name: Build ${{matrix.arch}} Binary for ${{matrix.network}}
strategy:
matrix:
os: [[self-hosted, Linux, X64], [self-hosted, Linux, ARM64]]
network: [local, rococo, mainnet]
include:
- network: local
spec: frequency-rococo-local
build-profile: release
release-file-name-prefix: frequency-local
- network: rococo
spec: frequency-rococo-testnet
build-profile: production
release-file-name-prefix: frequency-rococo
- network: mainnet
spec: frequency
build-profile: production
release-file-name-prefix: frequency
- os: [self-hosted, Linux, X64]
arch: amd64
- os: [self-hosted, Linux, ARM64]
arch: arm64
runs-on: ${{matrix.os}}
steps:
- name: Set Global Env Vars
run: |
echo "BIN_DIR=target/${{matrix.build-profile}}" >> $GITHUB_ENV
echo "BUILT_BIN_FILENAME=frequency" >> $GITHUB_ENV
echo "RELEASE_BIN_FILENAME=${{matrix.release-file-name-prefix}}.${{matrix.arch}}" >> $GITHUB_ENV
- name: Set Ubuntu Env Vars
run: |
echo "HOME=/home/ubuntu" >> $GITHUB_ENV
- name: Install Required Packages
run: |
sudo apt-get update
sudo apt install -y protobuf-compiler
- name: Check Out Repo
uses: actions/checkout@v3
# # XXX Keep this step as it lets us skip full binary builds during development/testing
# - name: Cache Binary for Testing
# id: cache-binary
# uses: actions/cache@v3
# with:
# path: ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}}
# key: ${{runner.os}}-${{matrix.network}}-${{matrix.arch}}-${{env.NEW_RELEASE_VERSION}}
- name: Install Rust Toolchain
if: steps.cache-binary.outputs.cache-hit != 'true'
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
target: wasm32-unknown-unknown
- name: Cache Rust Dependencies
if: steps.cache-binary.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{env.RUST_TOOLCHAIN}}
- name: Compile for ${{matrix.network}}
if: steps.cache-binary.outputs.cache-hit != 'true'
run: |
CARGO_INCREMENTAL=0 RUSTFLAGS="-D warnings" cargo build \
--locked \
--features ${{matrix.spec}} \
--profile ${{matrix.build-profile}}
- name: Run Sanity Checks
run: |
file ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}} && \
${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}} --version
- name: Rename Binary
run: |
cp -p ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}} \
${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}}
- name: Generate Binary Hash
working-directory: ${{env.BIN_DIR}}
run: sha256sum ${{env.RELEASE_BIN_FILENAME}} > ${{env.RELEASE_BIN_FILENAME}}.sha256
- name: Import GPG key
id: import-gpg
# Pinning it to the exact version since this touches our private key
uses: crazy-max/ghaction-import-gpg@v5.2.0
with:
gpg_private_key: ${{secrets.FREQUENCY_PGP_SECRET_SUBKEYS}}
passphrase: ${{secrets.FREQUENCY_PGP_MASTER_KEY_PASSWORD}}
fingerprint: B6327D1474C6392032870E8EFA4FD1E73A0FE707 # signing subkey
- name: Generate Binary Signature
working-directory: ${{env.BIN_DIR}}
run: gpg --detach-sign --armor ${{env.RELEASE_BIN_FILENAME}}
- name: Verify Binary
working-directory: ${{env.BIN_DIR}}
run: gpg --verify ${{env.RELEASE_BIN_FILENAME}}.asc
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: |
${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}}
${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}}.sha256
${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}}.asc
if-no-files-found: error
build-runtimes:
name: Build Runtime for ${{matrix.network}}
strategy:
matrix:
network: [rococo, mainnet]
include:
- network: rococo
build-profile: production
package: frequency-runtime
runtime-dir: runtime/frequency
built-wasm-file-name-prefix: frequency_runtime
release-wasm-file-name-prefix: frequency-rococo_runtime
features: frequency-rococo-testnet
- network: mainnet
build-profile: production
package: frequency-runtime
runtime-dir: runtime/frequency
built-wasm-file-name-prefix: frequency_runtime
release-wasm-file-name-prefix: frequency_runtime
features: frequency
runs-on: [self-hosted, Linux, X64]
steps:
- name: Set Ubuntu Env Vars
run: |
echo "HOME=/home/ubuntu" >> $GITHUB_ENV
- name: Install Required Packages
run: |
sudo apt-get update
sudo apt install -y protobuf-compiler
- name: Check Out Repo
uses: actions/checkout@v3
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
default: true
profile: minimal
toolchain: stable
- name: Install Docker
run: |
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
- name: Prune Docker Resources
run: |
docker system prune -a --volumes -f
docker container prune -f
docker image prune -a -f
docker container ls
docker image ls
- name: Extract Runtime Spec Version
run: |
echo "RUNTIME_SPEC_VERSION=$(sed -nr 's/spec_version:\s*([0-9]+),/\1/p' \
${{matrix.runtime-dir}}/src/lib.rs | tr -d '[:space:]')" >> $GITHUB_ENV
- name: Validate Extracted Version
run: |
echo "Runtime Spec Version:|${{env.RUNTIME_SPEC_VERSION}}|"
echo "Runtime Spec Version:||$RUNTIME_SPEC_VERSION||"
[[ $RUNTIME_SPEC_VERSION == ?(-)+([0-9]) ]] || \
(echo "ERROR: \"${{env.RUNTIME_SPEC_VERSION}}\" is not a valid integer" && exit 10)
- name: Set Env Vars
run: |
echo "WASM_DIR=${{matrix.runtime-dir}}/target/srtool/${{matrix.build-profile}}/wbuild/${{matrix.package}}" >> $GITHUB_ENV
echo "BUILT_WASM_FILENAME=${{matrix.built-wasm-file-name-prefix}}.compact.compressed.wasm" >> $GITHUB_ENV
echo "RELEASE_WASM_FILENAME=${{matrix.release-wasm-file-name-prefix}}-v${{env.RUNTIME_SPEC_VERSION}}.${{env.NEW_RELEASE_VERSION}}.compact.compressed.wasm" >> $GITHUB_ENV
# # XXX Keep this step as it lets us skip WASM builds during development/testing
# - name: Cache WASM for Testing
# id: cache-wasm
# uses: actions/cache@v3
# with:
# path: ${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}}
# key: ${{runner.os}}-${{matrix.network}}-${{env.NEW_RELEASE_VERSION}}
- name: Install srtool-cli
run: |
cargo install --git https://github.com/chevdor/srtool-cli
srtool --version
- name: Build Deterministic WASM
run: |
set -ex
srtool build \
--default-features="on-chain-release-build,no-metadata-docs,${{matrix.features}}" \
--profile=${{matrix.build-profile}} \
--package=${{matrix.package}} \
--root
- name: Rename WASM file
run: |
cp -p ./${{env.WASM_DIR}}/${{env.BUILT_WASM_FILENAME}} \
./${{env.WASM_DIR}}/${{env.RELEASE_WASM_FILENAME}}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: ${{env.WASM_DIR}}/${{env.RELEASE_WASM_FILENAME}}
if-no-files-found: error
build-rust-developer-docs:
name: Build Rust Developer Docs
runs-on: [self-hosted, Linux, X64]
steps:
- name: Set Ubuntu Env Vars
run: echo "HOME=/home/ubuntu" >> $GITHUB_ENV
- name: Install Required Packages
run: |
sudo apt-get update
sudo apt install -y protobuf-compiler
- name: Check Out Repo
uses: actions/checkout@v3
- name: Install Rust Toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
profile: minimal
target: wasm32-unknown-unknown
- name: Cache Rust Dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{env.RUST_TOOLCHAIN}}
- name: Build Docs
run: |
RUSTDOCFLAGS="--enable-index-page -Zunstable-options" cargo doc --no-deps
- name: Upload Docs
uses: actions/upload-artifact@v3
with:
name: rust-developer-docs-${{github.run_id}}
path: ./target/doc
if-no-files-found: error
build-js-api-augment:
needs: build-binaries
name: Build JS API Augment
strategy:
matrix:
os: [ubuntu-20.04]
network: [mainnet]
include:
- network: mainnet
spec: frequency
build-profile: production
- os: ubuntu-20.04
arch: amd64
runs-on: ${{matrix.os}}
steps:
- name: Set Env Vars
run: |
echo "BIN_DIR=target/${{matrix.build-profile}}" >> $GITHUB_ENV
echo "RELEASE_BIN_FILENAME=frequency-${{matrix.network}}.${{matrix.arch}}" >> $GITHUB_ENV
- name: Check Out Repo
uses: actions/checkout@v3
- name: Set up NodeJs
uses: actions/setup-node@v3
with:
node-version: 16
cache: "npm"
registry-url: "https://registry.npmjs.org"
cache-dependency-path: js/api-augment/package-lock.json
- name: Install
run: npm install # DO NOT use `npm ci` as we want the latest polkadot/api possible
working-directory: js/api-augment
- name: Download Binary Artifacts
id: download
uses: actions/download-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: .
- name: Move Binary to Target Dir
run: |
mkdir -p ${{env.BIN_DIR}}
mv ${{env.RELEASE_BIN_FILENAME}} ${{env.BIN_DIR}}
chmod 755 ${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}}
- name: Output Metadata
run: ${{env.BIN_DIR}}/${{env.RELEASE_BIN_FILENAME}} export-metadata ./js/api-augment/metadata.json
- name: Build
run: npm run build
working-directory: js/api-augment
- name: Upload Dist Dir
uses: actions/upload-artifact@v3
with:
name: js-api-augment-${{github.run_id}}
path: js/api-augment/dist
if-no-files-found: error
wait-for-all-builds:
needs: [build-binaries, build-runtimes, build-rust-developer-docs, build-js-api-augment]
name: Wait for All Builds to Finish
runs-on: ubuntu-20.04
steps:
- name: Proceed Forward
run: echo "All build jobs have finished, proceeding with the release"
release-artifacts:
needs: wait-for-all-builds
name: Release Built Artifacts
runs-on: ubuntu-20.04
steps:
- name: Check Out Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Full Release?
run: |
is_full_release=$([[ "$NEW_RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && \
echo 'true' || echo 'false')
echo "is_full_release: $is_full_release"
echo "IS_FULL_RELEASE=$is_full_release" >> $GITHUB_ENV
- name: Get Latest Release Tag
run: |
git show-ref --tags -d
latest_tag_commit=$(git show-ref --tags -d | grep latest^{} | cut -d' ' -f1)
latest_release_tag=$(git show-ref --tags -d | grep "^$latest_tag_commit" | \
grep refs/tags/v | sed -e 's,.* refs/tags/,,' -e 's/\^{}//')
echo "latest_release_tag: $latest_release_tag"
echo "PREVIOUS_RELEASE_TAG=$latest_release_tag" >> $GITHUB_ENV
- name: Install Tera CLI
if: steps.cache-tera.outputs.cache-hit != 'true'
run: |
cargo install --git https://github.com/chevdor/tera-cli
tera --version
- name: Build Changelog
id: build-changelog
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
fromTag: ${{env.PREVIOUS_RELEASE_TAG}}
toTag: ${{env.NEW_RELEASE_TAG}}
configurationJson: |
{
"template": "#{{UNCATEGORIZED}}",
"pr_template": "- #{{TITLE}} ##{{NUMBER}}",
"empty_template": "- No changes",
"transformers": [
{
"pattern": "- (.*)",
"target": "- $1|n|"
}
]
}
- name: Sanitize Changelog
id: sanitize-changelog
run: |
echo "original: ${{steps.build-changelog.outputs.changelog}}"
echo "1---------------------"
changelog='${{steps.build-changelog.outputs.changelog}}'
clean="${changelog//[\`\[\]$'\n']/}"
echo "sanitized: $clean"
echo "2---------------------"
echo "sanitized=$clean" >> $GITHUB_OUTPUT
- name: Generate Release Notes
working-directory: tools/ci/release-notes
run: |
./build-release-notes.sh '${{steps.sanitize-changelog.outputs.sanitized}}' > \
release-notes.md
- name: Download Binary Artifacts
id: download
uses: actions/download-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: /tmp
- name: List Downloaded Artifacts
run: |
ls -la /tmp/frequency*.*
- name: Publish Release on GitHub
uses: softprops/action-gh-release@v1
with:
body_path: tools/ci/release-notes/release-notes.md
files: /tmp/frequency*.*
- name: Update latest tag
if: env.IS_FULL_RELEASE == 'true'
uses: rickstaa/action-create-tag@v1
with:
tag: "latest"
force_push_tag: true
message: "Latest full release"
release-node-images:
needs: wait-for-all-builds
name: Release ${{matrix.arch}} Node Docker Image for ${{matrix.network}}
strategy:
matrix:
arch: [amd64]
network: [rococo, mainnet]
include:
- network: rococo
build-profile: production
- network: mainnet
build-profile: production
- arch: amd64
docker-platform: linux/amd64
env:
DOCKER_HUB_PROFILE: frequencychain
IMAGE_NAME: parachain-node
runs-on: ubuntu-20.04
steps:
- name: Set Env Vars
run: |
echo "BIN_DIR=target/${{matrix.build-profile}}" >> $GITHUB_ENV
echo "BUILT_BIN_FILENAME=frequency" >> $GITHUB_ENV
echo "RELEASE_BIN_FILENAME=frequency-${{matrix.network}}.${{matrix.arch}}" >> $GITHUB_ENV
- name: Check Out Repo
uses: actions/checkout@v3
- name: Download Binary Artifacts
id: download
uses: actions/download-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: .
- name: Move Binary to Target Dir
run: |
mkdir -p ${{env.BIN_DIR}}
mv ${{env.RELEASE_BIN_FILENAME}} ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}}
chmod +x ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{matrix.arch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKERHUB_USERNAME_FC}}
password: ${{secrets.DOCKERHUB_TOKEN_FC}}
- name: Build and Push Parachain Image
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{matrix.docker-platform}}
push: true
file: ./docker/${{env.IMAGE_NAME}}.dockerfile
tags: |
${{env.DOCKER_HUB_PROFILE}}/${{env.IMAGE_NAME}}-${{matrix.network}}:${{env.NEW_RELEASE_VERSION}}
${{env.DOCKER_HUB_PROFILE}}/${{env.IMAGE_NAME}}-${{matrix.network}}:latest
- name: Update DockerHub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME_FC}}
password: ${{secrets.DOCKERHUB_TOKEN_FC}}
repository: ${{env.DOCKER_HUB_PROFILE}}/${{env.IMAGE_NAME}}-${{matrix.network}}
readme-filepath: docker/${{env.IMAGE_NAME}}-${{matrix.network}}.overview.md
release-dev-images:
needs: wait-for-all-builds
name: Release Dev Docker Image for ${{matrix.node}}
strategy:
matrix:
network: [local]
arch: [amd64]
node: [collator-node-local, instant-seal-node]
include:
- network: local
build-profile: release
- arch: amd64
docker-platform: linux/amd64
env:
DOCKER_HUB_PROFILE: frequencychain
runs-on: ubuntu-20.04
steps:
- name: Set Env Vars
run: |
echo "BIN_DIR=target/${{matrix.build-profile}}" >> $GITHUB_ENV
echo "BUILT_BIN_FILENAME=frequency" >> $GITHUB_ENV
echo "RELEASE_BIN_FILENAME=frequency-${{matrix.network}}.${{matrix.arch}}" >> $GITHUB_ENV
- name: Check Out Repo
uses: actions/checkout@v3
- name: Download Binary Artifacts
id: download
uses: actions/download-artifact@v3
with:
name: artifacts-${{github.run_id}}
path: .
- name: Move Binary to Target Dir
run: |
mkdir -p ${{env.BIN_DIR}}
mv ${{env.RELEASE_BIN_FILENAME}} ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}}
chmod +x ${{env.BIN_DIR}}/${{env.BUILT_BIN_FILENAME}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: ${{matrix.arch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{secrets.DOCKERHUB_USERNAME_FC}}
password: ${{secrets.DOCKERHUB_TOKEN_FC}}
- name: Build and Push Dev Image
uses: docker/build-push-action@v3
with:
context: .
platforms: ${{matrix.docker-platform}}
push: true
file: ./docker/${{matrix.node}}.dockerfile
tags: |
${{env.DOCKER_HUB_PROFILE}}/${{matrix.node}}:${{env.NEW_RELEASE_VERSION}}
${{env.DOCKER_HUB_PROFILE}}/${{matrix.node}}:latest
- name: Update DockerHub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{secrets.DOCKERHUB_USERNAME_FC}}
password: ${{secrets.DOCKERHUB_TOKEN_FC}}
repository: ${{env.DOCKER_HUB_PROFILE}}/${{matrix.node}}
readme-filepath: docker/${{matrix.node}}.overview.md
release-rust-developer-docs:
needs: wait-for-all-builds
name: Release Rust Developer Docs
runs-on: ubuntu-20.04
steps:
- name: Check Out Repo
uses: actions/checkout@v3
- name: Download Docs
id: download
uses: actions/download-artifact@v3
with:
name: rust-developer-docs-${{github.run_id}}
path: ./target/doc
- name: Deploy Frequency docs to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ./target/doc
release-js-api-augment:
needs: wait-for-all-builds
name: Release JS API Augment
runs-on: ubuntu-20.04
steps:
- name: Check Out Repo
uses: actions/checkout@v3
- name: Set up NodeJs
uses: actions/setup-node@v3
with:
node-version: 16
cache: "npm"
registry-url: "https://registry.npmjs.org"
cache-dependency-path: js/api-augment/package-lock.json
- name: Download Dist Dir
id: download
uses: actions/download-artifact@v3
with:
name: js-api-augment-${{github.run_id}}
path: js/api-augment/dist
- name: Version Package
run: npm version --new-version "${{env.NEW_RELEASE_VERSION}}" --no-git-tag-version
working-directory: js/api-augment/dist
- name: Release on NPM @latest
run: npm publish --tag latest --access public
working-directory: ./js/api-augment/dist
env:
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}