Publish Runtime Draft #220
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- flashbox-only | |
- dancebox-only | |
- templates-only | |
- simple-template-only | |
- frontier-template-only | |
- dancelight-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@v4 | |
- name: Upload scripts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: original-scripts | |
path: scripts | |
- name: Upload tools | |
uses: actions/upload-artifact@v4 | |
with: | |
name: original-tools | |
path: tools | |
matrix_prep: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix_tests: ${{ steps.prepare.outputs.matrix_tests }} | |
steps: | |
- uses: actions/checkout@v4 | |
# Build input dependent matrix | |
- name: create matrix | |
id: prepare | |
run: | | |
dancebox='{"runtime_name": "dancebox","runtime_path" : "./runtime/dancebox/src/lib.rs"}' | |
flashbox='{"runtime_name": "flashbox","runtime_path" : "./runtime/flashbox/src/lib.rs"}' | |
frontier_template='{"runtime_name": "frontier-template","runtime_path" : "./container-chains/runtime-templates/frontier/src/lib.rs"}' | |
simple_template='{"runtime_name": "simple-template","runtime_path" : "./container-chains/runtime-templates/simple/src/lib.rs"}' | |
dancelight='{"runtime_name": "dancelight","runtime_path" : "./solo-chains/runtime/dancelight/src/lib.rs"}' | |
if [[ ${{ github.event.inputs.chains }} = "tanssi-only" ]]; then | |
echo "matrix_tests=[$dancebox, $flashbox]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "templates-only" ]]; then | |
echo "matrix_tests=[$simple_template, $frontier_template]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "flashbox-only" ]]; then | |
echo "matrix_tests=[$flashbox]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "dancebox-only" ]]; then | |
echo "matrix_tests=[$dancebox]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "simple-template-only" ]]; then | |
echo "matrix_tests=[$simple_template]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "frontier-template-only" ]]; then | |
echo "matrix_tests=[$frontier_template]" >> $GITHUB_OUTPUT | |
elif [[ ${{ github.event.inputs.chains }} = "dancelight-only" ]]; then | |
echo "matrix_tests=[$dancelight]" >> $GITHUB_OUTPUT | |
else | |
echo "matrix_tests=[$dancebox, $flashbox, $simple_template, $frontier_template, $dancelight]" >> $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: | |
- moondancelabs/srtool | |
srtool_image_tag: | |
- 1.75.0 | |
# Change this once https://github.com/paritytech/srtool/pull/81 gets merged | |
srtool_build_base_dockerhub: | |
- moondancelabs/srtool | |
srtool_build_source_image_tag: | |
- temp-1.75 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.to }} | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
registry: index.docker.io | |
- name: Download original scripts | |
uses: actions/download-artifact@v4 | |
with: | |
name: original-scripts | |
path: original-scripts | |
- name: Build & Push moondancelabs/srtool image | |
if: github.repository == 'moondance-labs/tanssi' | |
run: | | |
docker pull "registry.hub.docker.com/${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" && image_exists=true || image_exists=false | |
if [[ $image_exists = "false" ]]; then | |
echo building "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" | |
docker build --pull --no-cache . \ | |
-f docker/tanssi-srtool.Dockerfile \ | |
--build-arg SRTOOL_IMAGE_TAG=${{ matrix.srtool_build_source_image_tag }} \ | |
--build-arg SRTOOL_IMAGE_REPO=${{ matrix.srtool_build_base_dockerhub }} \ | |
-t ${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }} | |
echo pushing "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" | |
docker push "${{ matrix.srtool_image }}:${{ matrix.srtool_image_tag }}" | |
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@v3 | |
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@v4 | |
with: | |
ref: ${{ github.event.inputs.to }} | |
fetch-depth: 0 | |
- name: Use Node.js 22.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
- name: Download Original Tools | |
uses: actions/download-artifact@v4 | |
with: | |
name: original-tools | |
path: original-tools | |
- name: Download runtime-info | |
uses: actions/download-artifact@v3 | |
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@v4 | |
with: | |
ref: ${{ github.event.inputs.to }} | |
fetch-depth: 0 | |
- name: Download ${{ matrix.chain }} runtime | |
uses: actions/download-artifact@v3 | |
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 |