Skip to content

Publish Runtime Draft #138

Publish Runtime Draft

Publish Runtime Draft #138

name: Publish Runtime Draft
# The code (like generate-release-body) will be taken from the tag versions, not master
on:
workflow_dispatch:
inputs:
from:
description: tag (ex. runtime-53) to retrieve commit diff from
required: true
to:
description: tag (ex. runtime-155) to generate release note and srtool runtimes from
required: true
chains:
description: the chains for which we should do the release (ex. dancebox)
required: false
type: choice
default: tanssi-only
options:
- tanssi-only
- templates-only
- run-all
jobs:
####### Build runtimes with srtool #######
setup-scripts:
runs-on: self-hosted
steps:
## Use scripts and tools from current branch
- uses: actions/checkout@v3
- name: Upload scripts
uses: actions/upload-artifact@v3
with:
name: original-scripts
path: scripts
- name: Upload tools
uses: actions/upload-artifact@v3
with:
name: original-tools
path: tools
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix_tests: ${{ steps.prepare.outputs.matrix_tests }}
steps:
- uses: actions/checkout@v3
# Build input dependent matrix
- name: create matrix
id: prepare
run: |
dancebox='{"runtime_name": "dancebox","runtime_path" : "./runtime/dancebox/src/lib.rs"}'
frontier_template='{"runtime_name": "frontier-template","runtime_path" : "./container-chains/templates/frontier/runtime/src/lib.rs"}'
simple_template='{"runtime_name": "simple-template","runtime_path" : "./container-chains/templates/simple/runtime/src/lib.rs"}'
if [[ ${{ github.event.inputs.chains }} = "tanssi-only" ]]; then
echo "matrix_tests=[$dancebox]" >> $GITHUB_OUTPUT
elif [[ ${{ github.event.inputs.chains }} = "templates-only" ]]; then
echo "matrix_tests=[$simple_template, $frontier_template]" >> $GITHUB_OUTPUT
else
echo "matrix_tests=[$dancebox, $simple_template, $frontier_template]" >> $GITHUB_OUTPUT
fi
build-srtool-runtimes:
needs: ["setup-scripts", "matrix_prep"]
runs-on: self-hosted
strategy:
matrix:
chain: ${{ fromJson(needs.matrix_prep.outputs.matrix_tests) }}
srtool_image:
- purestake/srtool
srtool_image_tag:
- 1.69.0
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
- name: Download original scripts
uses: actions/download-artifact@v3
with:
name: original-scripts
path: original-scripts
- name: Build & Push purestake/srtool image
if: github.repository == 'moondance-labs/tanssi'
run: |
echo ${{ matrix.chain.runtime_name }}
docker pull "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" && image_exists=true || image_exists=false
if [[ $image_exists = "false" ]]; then
exit 1
else
echo skiping build "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}", image already exists
fi
- name: Build runtime using "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}"
id: srtool_build
env:
GH_WORKFLOW_MATRIX_CHAIN: ${{ matrix.chain.runtime_name }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE: ${{ matrix.srtool_image }}
GH_WORKFLOW_MATRIX_SRTOOL_IMAGE_TAG: ${{ matrix.srtool_image_tag }}
run: |
chmod u+x ./original-scripts/build-runtime-srtool.sh
./original-scripts/build-runtime-srtool.sh
- name: Summary
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.chain.runtime_name }}-srtool-digest.json
cat ${{ matrix.chain.runtime_name }}-srtool-digest.json
cp ${{ steps.srtool_build.outputs.wasm_compressed }} ${{ matrix.chain.runtime_name }}-runtime.compact.compressed.wasm
- name: Archive Artifacts for ${{ matrix.chain }}
uses: actions/upload-artifact@v2
with:
name: runtime-info
path: |
${{ matrix.chain.runtime_name }}-runtime.compact.compressed.wasm
${{ matrix.chain.runtime_name }}-srtool-digest.json
####### Prepare the release draft #######
prepare-draft-release:
runs-on: ubuntu-latest
needs: ["setup-scripts", "build-srtool-runtimes", "matrix_prep"]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Download Original Tools
uses: actions/download-artifact@v3
with:
name: original-tools
path: original-tools
- name: Download runtime-info
uses: actions/[email protected]
with:
name: runtime-info
path: build
- name: Generate release body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: generate-release-body
working-directory: original-tools
run: |
RUNTIMES=$(echo '${{needs.matrix_prep.outputs.matrix_tests}}' | jq -r '.[] | .runtime_name + " "')
yarn
yarn -s run ts-node github/generate-runtimes-body.ts --owner "${{ github.repository_owner }}" --repo "$(basename ${{ github.repository }})" --from "${{ github.event.inputs.from }}" --to "${{ github.event.inputs.to }}" --srtool-report-folder '../build/' --runtimes $RUNTIMES > ../body.md - name: Get runtime version
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.to }}
release_name: Runtime ${{ github.event.inputs.to }}
body_path: body.md
draft: true
####### Upload asserts to the release draft #######
publish-draft-release:
runs-on: ubuntu-latest
needs: ["setup-scripts", "build-srtool-runtimes", "prepare-draft-release", "matrix_prep"]
strategy:
matrix:
chain: ${{ fromJson(needs.matrix_prep.outputs.matrix_tests) }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.to }}
fetch-depth: 0
- name: Download ${{ matrix.chain }} runtime
uses: actions/[email protected]
with:
name: runtime-info
path: build
- name: Get runtime version
id: get-runtime-ver
run: |
runtime_ver="$(cat ${{ matrix.chain.runtime_path }} | grep -o 'spec_version: [0-9]*' | tail -1 | grep -o '[0-9]*')"
echo "runtime_ver=$runtime_ver" >> $GITHUB_OUTPUT
mv build/${{ matrix.chain.runtime_name }}-runtime.compact.compressed.wasm ${{ matrix.chain.runtime_name }}-runtime-${runtime_ver}.wasm
mv build/${{ matrix.chain.runtime_name }}-srtool-digest.json ${{ matrix.chain.runtime_name }}-runtime-${runtime_ver}-srtool-digest.json
- name: Upload ${{ matrix.chain }} wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare-draft-release.outputs.asset_upload_url }}
asset_path: ${{ matrix.chain.runtime_name }}-runtime-${{ steps.get-runtime-ver.outputs.runtime_ver }}.wasm
asset_name: ${{ matrix.chain.runtime_name }}-runtime-${{ steps.get-runtime-ver.outputs.runtime_ver }}.wasm
asset_content_type: application/octet-stream
- name: Upload ${{ matrix.chain.runtime_name }} srtool digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.prepare-draft-release.outputs.asset_upload_url }}
asset_path: ${{ matrix.chain.runtime_name }}-runtime-${{ steps.get-runtime-ver.outputs.runtime_ver }}-srtool-digest.json
asset_name: ${{ matrix.chain.runtime_name }}-runtime-${{ steps.get-runtime-ver.outputs.runtime_ver }}.srtool-digest.json
asset_content_type: application/json