Skip to content

Initialization

Initialization #12

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
# Necessary to trigger the override workflow.
actions: write
# Necessary to publish the release.
contents: write
env:
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
jobs:
# This job triggers the override workflow for the target runtime.
trigger-override:
name: Trigger override
runs-on: ubuntu-latest
strategy:
matrix:
# Add the runtime here that you want to build its override.
#
# The possible values are defined in the `override.yml` workflow.
runtime: [polkadot-runtime, staging-kusama-runtime]
steps:
- name: Trigger override
env:
# Use a Personal Access Token (PAT) if `GITHUB_TOKEN` does not have enough permissions to trigger the override workflow.
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# It is recommended to put the override workflow in the main branch in the runtime-overrides repository.
# So, we dispatch it from main branch to build for other `RUNTIME` branches by `--ref main`.
run: gh workflow run override.yml
--repo hack-ink/polkadot-runtime-releaser-workshop
--ref main
-f runtime="${{ matrix.runtime }}"
-f ref="${{ github.ref_name }}"
build-runtime:
name: Build runtime
runs-on: ubuntu-latest
strategy:
matrix:
# Add the runtime here that you want to release.
runtime: [polkadot-runtime, staging-kusama-runtime]
steps:
- name: Fetch latest code
uses: actions/checkout@v4
- 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@main
with:
# The target runtime to build.
#
# For example, `polkadot-runtime` or `staging-kusama-runtime`.
runtime: ${{ matrix.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: Construct runtime info
id: construction
run: |
RUNTIME="$(echo "${{ matrix.runtime }}" | sed 's/-/_/g')"
echo "RUNTIME=$RUNTIME"
echo "runtime=$RUNTIME" >> "$GITHUB_OUTPUT"
WASM=$(ls "${RUNTIME}"-*.compact.compressed.wasm)
JSON=$(ls "${RUNTIME}"-*.json)
cat "$JSON" | jq '.' > tmp.json
mv tmp.json "$JSON"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime }}-artifact
path: |
${{ steps.construction.outputs.runtime }}-*.compact.compressed.wasm
${{ steps.construction.outputs.runtime }}-*.json
release:
name: Release
runs-on: ubuntu-latest
needs: build-runtime
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
path: download
- name: Construct release notes
run: |
for artifact_dir in download/*-artifact; do
if [ -d "$artifact_dir" ]; then
for json_file in "$artifact_dir"/*.json; do
[ -f "$json_file" ] || continue
BASE_NAME="$(basename "$json_file")"
NAME_NO_EXT="${BASE_NAME%.json}"
NAME="${NAME_NO_EXT//_/-}"
echo "## $NAME" >> release_note.md
echo "\`\`\`json" >> release_note.md
cat "$json_file" >> release_note.md
echo "\`\`\`" >> release_note.md
echo "" >> release_note.md
done
fi
done
- name: Publish release
uses: softprops/action-gh-release@v2
with:
body_path: release_note.md
files: |
download/**/*.wasm