Skip to content

Release koi-6654 (#1576) #182

Release koi-6654 (#1576)

Release koi-6654 (#1576) #182

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
- "koi*"
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_TERM_COLOR: always
DOCKER_REGISTRY: ghcr.io
GOMPLATE_VERSION: v3.11.6
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: true
jobs:
build-nodes:
name: Build nodes
runs-on: ubuntu-latest
strategy:
matrix:
node:
- network: mainnet
features: darwinia-native,crab-native
bz2: true
- network: mainnet
features: darwinia-native,crab-native,evm-tracing
type: tracing
- network: testnet
features: koi-native
bz2: true
- network: testnet
features: koi-native,evm-tracing
type: tracing
steps:
- name: Free disk space
if: ${{ env.SKIP_BUILD != 'true' }}
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: true
swap-storage: false
- name: Set swap space
if: ${{ env.SKIP_BUILD != 'true' }}
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 8
- name: Fetch latest code
uses: actions/checkout@v4
- name: Build mainnet node
if: ${{ startsWith(github.ref, 'refs/tags/v') && (matrix.node.network == 'mainnet') }}
uses: ./.github/actions/build
with:
features: ${{ matrix.node.features }}
suffix: ${{ matrix.node.type }}
enable_tar_bz2: ${{ matrix.node.bz2 }}
skip-build: ${{ env.SKIP_BUILD }}
- name: Build testnet node
if: ${{ startsWith(github.ref, 'refs/tags/koi') && (matrix.node.network == 'testnet') }}
uses: ./.github/actions/build
with:
features: ${{ matrix.node.features }}
suffix: ${{ matrix.node.type }}
enable_tar_bz2: ${{ matrix.node.bz2 }}
skip-build: ${{ env.SKIP_BUILD }}
- name: Upload node
uses: actions/upload-artifact@v4
with:
name: darwinia${{ matrix.node.type != '' && format('-{0}', matrix.node.type) || '' }}
path: build
retention-days: 1
- name: Fail fast
uses: vishnudxb/cancel-workflow@v1.2
if: failure()
with:
repo: darwinia-network/darwinia
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
build-runtimes:
name: Build runtimes
runs-on: ubuntu-latest
strategy:
matrix:
runtime:
- name: darwinia
type: mainnet
- name: crab
type: mainnet
- name: koi
type: testnet
steps:
- name: Fetch latest code
uses: actions/checkout@v4
- name: Setup gomplate
run: |
curl -LO ${{ env.GOMPLATE_URL }}/${{ env.GOMPLATE_VERSION }}/${{ env.GOMPLATE }}
chmod u+x ${{ env.GOMPLATE }}
sudo mv ${{ env.GOMPLATE }} /usr/bin/gomplate
- name: Setup wuh
run: |
curl -LO https://github.com/darwinia-network/darwinia-release/releases/download/v0.1.0/wuh.zst
zstd -d wuh.zst
chmod u+x ./wuh
sudo mv ./wuh /usr/bin/wuh
- name: Filter
run: |
SKIP_BUILD=${{ env.SKIP_BUILD }}
IS_MAINNET=${{ matrix.runtime.type == 'mainnet' && startsWith(github.ref, 'refs/tags/v') }}
IS_TESTNET=${{ matrix.runtime.type == 'testnet' && startsWith(github.ref, 'refs/tags/koi') }}
echo "IS_MAINNET='$IS_MAINNET'" >> $GITHUB_ENV
echo "IS_TESTNET='$IS_TESTNET'" >> $GITHUB_ENV
if [[ "$SKIP_BUILD" != "true" && ( "$IS_MAINNET" == "true" || "$IS_TESTNET" == "true" ) ]] ; then
echo "FILTER=true" >> $GITHUB_ENV
fi
- name: Build ${{ matrix.runtime.name }} runtime
id: srtool_build
if: ${{ env.FILTER == 'true' }}
uses: chevdor/srtool-actions@v0.9.2
env:
BUILD_OPTS: --features=on-chain-release-build
with:
image: paritytech/srtool
tag: "1.74.0"
chain: ${{ matrix.runtime.name }}
- name: Prepare runtime
run: |
IS_MAINNET=${{ env.IS_MAINNET }}
IS_TESTNET=${{ env.IS_TESTNET }}
FILTER=${{ env.FILTER }}
export CHAIN=${{ matrix.runtime.name }}
echo $CHAIN
mkdir -p build
if [ "$FILTER" == "true" ]; then
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
WHITELIST_PALLET_INDEX=0x2f
fi
export WHITELIST_HASH=$(wuh ${WASM_FILE} ${WHITELIST_PALLET_INDEX} 0x01)
mv ${WASM_FILE} build/
cat .github/note-template/runtime.md \
| gomplate -d srtool=build/${CHAIN}-srtool.json \
> build/runtime.md
elif [[ "$IS_MAINNET" == "true" || "$IS_TESTNET" == "true" ]]; then
echo SKIP_BUILD > build/${CHAIN}-srtool.json
echo SKIP_BUILD > build/${CHAIN}_runtime.compact.compressed.wasm
echo SKIP_BUILD > build/runtime.md
fi
- name: Upload ${{ matrix.runtime.name }} runtime
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime.name }}-runtime
path: build
retention-days: 1
- name: Fail fast
uses: vishnudxb/cancel-workflow@v1.2
if: failure()
with:
repo: darwinia-network/darwinia
workflow_id: ${{ github.run_id }}
access_token: ${{ github.token }}
publish-docker-image:
name: Publish Docker image
runs-on: ubuntu-latest
needs: [build-nodes]
steps:
- name: Fetch Dockerfile
uses: actions/checkout@v4
- name: Download node
uses: actions/download-artifact@v4
- name: Extract node
run: |
mkdir -p dist
tar -xvf darwinia/darwinia-x86_64-linux-gnu.tar.bz2 -C dist/
- name: Tag
uses: olegtarasov/get-tag@v2.1
- name: Sha
uses: benjlevesque/short-sha@v3.0
- name: Docker login
if: ${{ env.SKIP_BUILD != 'true' }}
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ${{ env.DOCKER_REGISTRY }}
- name: Publish
if: ${{ env.SKIP_BUILD != 'true' }}
uses: docker/build-push-action@v5
with:
push: true
context: .
file: .maintain/docker/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}:sha-${{ env.SHA }}
- name: Publish with tag
if: ${{ env.SKIP_BUILD != 'true' }}
uses: docker/build-push-action@v5
with:
push: true
context: .
file: .maintain/docker/Dockerfile
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}:${{ env.GIT_TAG_NAME }}
publish-github-release:
name: Publish GitHub release
runs-on: ubuntu-latest
needs: [build-nodes, build-runtimes, publish-docker-image]
steps:
- name: Fetch note template
uses: actions/checkout@v4
- name: Download nodes and runtimes
uses: actions/download-artifact@v4
- 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/
- name: Setup gomplate
run: |
curl -LO ${{ env.GOMPLATE_URL }}/${{ env.GOMPLATE_VERSION }}/${{ env.GOMPLATE }}
chmod u+x ${{ env.GOMPLATE }}
sudo mv ${{ env.GOMPLATE }} /usr/bin/gomplate
- name: Tag
uses: olegtarasov/get-tag@v2.1
- name: Sha
uses: benjlevesque/short-sha@v3.0
- name: Prepare note
run: |
export RELEASE_SCHEMA='{"tag":"'$GIT_TAG_NAME'","sha":"'$SHA'"}'
cat .github/note-template/node.md \
| gomplate -d schema='env:/RELEASE_SCHEMA?type=application/json' \
> node.tmp.md
- name: Fill note
run: |
IS_MAINNET=${{ startsWith(github.ref, 'refs/tags/v') }}
if [ "$IS_MAINNET" == "true" ]; then
cat darwinia-runtime/runtime.md >> node.md
cat crab-runtime/runtime.md >> node.md
cat node.tmp.md >> node.md
else
cat koi-runtime/runtime.md >> node.md
cat node.tmp.md >> node.md
fi
- name: Hash file
run: cd deploy && sha256sum * | tee sha256sums.txt
# - name: Verify
# run: |
# set -xe
# cat node.md
# ls -la deploy/
# cat build/*.md
- name: Publish
uses: softprops/action-gh-release@v2
with:
body_path: "node.md"
files: |
deploy/*
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: ${{ startsWith(github.ref, 'refs/tags/koi') }}