Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 26 additions & 49 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
name: "Build darwinia node"
name: "Build Darwinia node"

description: "Darwinia artifacts building action."

inputs:
features:
description: "build features"
required: true
enable_tar_bz2:
description: "enable package tar.bz2"
required: false
default: ""
default: "false"
suffix:
description: "output file suffix"
required: false
default: ""
enable_cache:
description: "enable cache"
required: false
default: "false"
cache_shrink_script:
description: "shrink cache script file path"
required: false
default: ".github/shrink-cache.sh"
enable_tar_bz2:
description: "enable package tar.bz2"
required: false
default: "false"
skip-build:
description: "use this for testing purposes only"
required: false
Expand All @@ -38,51 +29,37 @@ runs:
context: .
file: .maintain/docker/ubuntu:20.04.Dockerfile
tags: darwinia-network/build-tool:latest
- name: Cache cargo
if: ${{ inputs.enable_cache == 'true' && inputs.skip-build != 'true' }}
uses: actions/cache@v3
with:
path: |
./target
key: darwinia-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
darwinia-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-
darwinia-${{ runner.os }}-

- name: Build node
shell: bash
run: |
FEATURES=${{ inputs.features }}
SUFFIX=${{ inputs.suffix }}
ENABLE_TAR_BZ2=${{ inputs.enable_tar_bz2 }}
SKIP_BUILD=${{ inputs.skip-build }}
set -euxo pipefail

FEATURES="${{ inputs.features }}"
SUFFIX="${{ inputs.suffix }}"
ENABLE_TAR_BZ2="${{ inputs.enable_tar_bz2 }}"
SKIP_BUILD="${{ inputs['skip-build'] }}"

APP_NAME="darwinia"
ARCH="x86_64-linux-gnu"
OUTPUT_BASENAME="${APP_NAME}${SUFFIX:+-$SUFFIX}-$ARCH"
BUILD_DIR="build"

if [ "$SKIP_BUILD" != "true" ]; then
docker run -i --rm \
--name=build-darwinia \
-v=$(pwd):/build \
darwinia-network/build-tool:latest \
cargo b --release --locked \
-p darwinia \
--features=$FEATURES
docker run -i --rm \
--name=build-darwinia \
-v="$(pwd):/build" \
darwinia-network/build-tool:latest \
cargo b --release --locked -p darwinia --features="$FEATURES"
else
mkdir -p target/release
echo SKIP_BUILD > target/release/darwinia
fi

BUILD_DIR=build
mkdir -p $BUILD_DIR
mkdir -p "$BUILD_DIR"

if [ "$ENABLE_TAR_BZ2" == "true" ]; then
tar cjSf ${BUILD_DIR}/darwinia${SUFFIX:+-$SUFFIX}-x86_64-linux-gnu.tar.bz2 -C target/release darwinia
if [ "$ENABLE_TAR_BZ2" = "true" ]; then
tar cjf "$BUILD_DIR/${OUTPUT_BASENAME}.tar.bz2" -C target/release darwinia
fi

tar cf ${BUILD_DIR}/darwinia${SUFFIX:+-$SUFFIX}-x86_64-linux-gnu.tar.zst -C target/release darwinia -I zstd
- name: Shrink cache
if: ${{ inputs.enable_cache == 'true' && inputs.skip-build != 'true' }}
shell: bash
run: |
docker run -i --rm \
--name=build-darwinia \
-v=$(pwd):/build \
darwinia-network/build-tool:latest \
${{ inputs.cache_shrink_script }} release
tar cf "$BUILD_DIR/${OUTPUT_BASENAME}.tar.zst" -C target/release darwinia -I zstd
15 changes: 8 additions & 7 deletions .github/note-template/runtime.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
## {{ .Env.CHAIN | strings.Title }}
<h3 align="right">Upgrade Priority LOW :green_circle:</h3>
## {{ .Env.RUNTIME | strings.Title }}
<h4 align="right">Upgrade Priority LOW :green_circle:</h3>

#### Whitelist Hash
### Digest
```json
{{ (ds "prr" | data.ToJSONPretty " ") }}
```

### Whitelist Hash
```txt
{{ .Env.WHITELIST_HASH }}
```
#### Blake2 256 Hash
```
{{ (ds "srtool").runtimes.compressed.subwasm.blake2_256 }}
```
58 changes: 34 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ env:

DOCKER_REGISTRY: ghcr.io

GOMPLATE_VERSION: v3.11.6
GOMPLATE_VERSION: v4.3.1
GOMPLATE: gomplate_linux-amd64
GOMPLATE_URL: https://github.com/hairyhenderson/gomplate/releases/download

RUST_BACKTRACE: full
RUST_TOOLCHAIN: 1.74.0

# Set this to true for CI testing purposes only.
SKIP_BUILD: false
Expand Down Expand Up @@ -92,44 +91,56 @@ jobs:
zstd -d wuh.zst
chmod u+x ./wuh
sudo mv ./wuh /usr/bin/wuh
- name: Build ${{ matrix.runtime }} runtime
id: srtool_build
if: ${{ env.SKIP_BUILD != 'true' }}
uses: chevdor/srtool-actions@v0.9.2
env:
BUILD_OPTS: --features=on-chain-release-build
- name: Build runtime
# It is recommended to use a specific version of the action in production.
#
# For example:
# uses: hack-ink/polkadot-runtime-releaser/action/build@vX.Y.Z
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.2.0
with:
image: paritytech/srtool
tag: "1.74.0"
chain: ${{ matrix.runtime }}
# The target runtime to build.
#
# For example, `polkadot-runtime` or `staging-kusama-runtime`.
runtime: ${{ matrix.runtime }}-runtime
# The features to enable for this release build.
#
# Generally, this would be `on-chain-release-build` in order to disable the logging to shrink the WASM binary size.
features: on-chain-release-build
# Rust toolchain version to build the runtime.
toolchain-ver: 1.81.0
# The workdir to build the runtime.
#
# By default, it is current directory.
# workdir: .
# The output directory of the WASM binary.
output-dir: .
- name: Prepare runtime
run: |
SKIP_BUILD=${{ env.SKIP_BUILD }}

export CHAIN=${{ matrix.runtime }}

echo $CHAIN
# Template will use this env var.
export RUNTIME=${{ matrix.runtime }}

mkdir -p build

if [ "$SKIP_BUILD" == "true" ]; then
echo SKIP_BUILD > build/${CHAIN}-srtool.json
echo SKIP_BUILD > build/${CHAIN}_runtime.compact.compressed.wasm
echo SKIP_BUILD > build/${RUNTIME}.wasm
echo SKIP_BUILD > build/runtime.md
else
echo '${{ steps.srtool_build.outputs.json }}' | jq > build/${CHAIN}-srtool.json

WASM_FILE='${{ steps.srtool_build.outputs.wasm_compressed }}'
WHITELIST_PALLET_INDEX=0x33
if [ "$CHAIN" == "crab" ]; then
if [ "$RUNTIME" == "crab" ]; then
WHITELIST_PALLET_INDEX=0x2f
fi
export WHITELIST_HASH=$(wuh ${WASM_FILE} ${WHITELIST_PALLET_INDEX} 0x01)
WASM=$(ls ${RUNTIME}*.wasm)
# Template will use this env var.
export WHITELIST_HASH=$(wuh ${WASM} ${WHITELIST_PALLET_INDEX} 0x01)

mv ${WASM} build/

mv ${WASM_FILE} build/
DIGEST=$(ls ${RUNTIME}*.json)

cat .github/note-template/runtime.md \
| gomplate -d srtool=build/${CHAIN}-srtool.json \
| gomplate -d prr=${DIGEST} \
> build/runtime.md
fi
- name: Upload ${{ matrix.runtime }} runtime
Expand Down Expand Up @@ -199,7 +210,6 @@ jobs:
- name: Prepare nodes and runtimes
run: |
mkdir -p deploy
mv *runtime/*.json deploy/
mv *runtime/*.wasm deploy/
mv darwinia/*.tar.* deploy/
mv darwinia-tracing/*.tar.* deploy/
Expand Down