Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 14 additions & 0 deletions .github/runtime-matrix.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"name": "BridgeHubPolkadot",
"runtime_uri": "https://github.com/polkadot-fellows/runtimes/releases/download/${runtime_version}/bridge-hub-polkadot_runtime-${release_version}.compact.compressed.wasm",
"runtime_file": "./tools/wbuild/bridge-hub-polkadot_runtime-${release_version}.compact.compressed.wasm",
"target_dir": "relay-clients/client-bridge-hub-polkadot/src"
},
{
"name": "BridgeHubKusama",
"runtime_uri": "https://github.com/polkadot-fellows/runtimes/releases/download/${runtime_version}/bridge-hub-kusama_runtime-${release_version}.compact.compressed.wasm",
"runtime_file": "./tools/wbuild/bridge-hub-kusama_runtime-${release_version}.compact.compressed.wasm",
"target_dir": "relay-clients/client-bridge-hub-kusama/src"
}
]
218 changes: 218 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
name: Release Relayer

on:
workflow_dispatch:
inputs:
runtime_version:
description: 'Runtime version number (e.g. v1.1.6)'
required: true
type: string
runtime:
description: 'Select runtime to release'
required: true
type: choice
options:
- 'BridgeHubPolkadot'
- 'BridgeHubKusama'
default: 'BridgeHubKusama'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Create wbuild directory
run: mkdir -p ./tools/wbuild

- name: Parse versions
run: |
runtime_version="${{ github.event.inputs.runtime_version }}"
runtime_num="${runtime_version#v}"
IFS='.' read -ra VERSION_PARTS <<< "$runtime_num"
major="${VERSION_PARTS[0]}"
minor="${VERSION_PARTS[1]}"
patch="${VERSION_PARTS[2]}"
# Add leading zeros
minor=$(printf "%03d" "$minor")
patch=$(printf "%03d" "$patch")
# Convert runtime version to release version (e.g., v1.1.6 -> v1001006)
release_version="v$major$minor$patch"
# Convert runtime version to spec version (e.g., v1.1.6 -> 1_001_006)
spec_version="$major_$minor_$patch"
echo "Runtime version: $runtime_version"
echo "Release version: $release_version"
echo "Spec version: $spec_version"
# Save runtime version for use in subsequent steps
echo "RUNTIME_VERSION=$runtime_version" >> $GITHUB_ENV
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "SPEC_VERSION=$spec_version" >> $GITHUB_ENV
- name: Download runtime files
env:
runtime_version: $RUNTIME_VERSION
release_version: $RELEASE_VERSION
run: |
# Load runtime matrix and set environment variables based on selection
runtime_input="${{ github.event.inputs.runtime }}"
# Extract runtime configuration from matrix
runtime_config=$(jq ".[] | select(.name == \"$runtime_input\")" .github/runtime-matrix.json)
# Set environment variables with interpolated values
runtime_uri=$(echo "$runtime_config" | jq -r '.runtime_uri' | sed "s/\${runtime_version}/$runtime_version/g" | sed "s/\${release_version#v}/$release_version/g")
runtime_file=$(echo "$runtime_config" | jq -r '.runtime_file' | sed "s/\${runtime_version}/$runtime_version/g" | sed "s/\${release_version#v}/$release_version/g")
target_dir=$(echo "$runtime_config" | jq -r '.target_dir')
target_librs="$target_dir/lib.rs"
# Export environment variables
echo "RUNTIME_FILE=$runtime_file" >> $GITHUB_ENV
echo "TARGET_DIR=$target_dir" >> $GITHUB_ENV
echo "TARGET_LIBRS=$target_librs" >> $GITHUB_ENV
echo "Downloading runtime for $runtime_input..."
echo "Runtime URI: $runtime_uri"
echo "Runtime File: $runtime_file"
echo "Target Directory: $target_dir"
echo "Target Lib RS: $target_librs"
# Download runtime
wget -O "$runtime_file" "$runtime_uri"
# Check if file was downloaded successfully
if [[ ! -f "$runtime_file" ]]; then
echo "Error: Failed to download runtime file: $runtime_file"
echo "Aborting workflow."
exit 1
fi
echo "Successfully downloaded: $runtime_file"
ls -lh "$runtime_file"
# Set environment variables for next steps
echo "RUNTIME_NAME=${{ github.event.inputs.runtime }}" >> $GITHUB_ENV
- name: Update spec version in client files
env:
spec_version: $SPEC_VERSION
target_librs: $TARGET_LIBRS
run: |
sed -i "s/spec_version: [0-9_]*/spec_version: $spec_version/" "$target_librs"
- name: Run runtime codegen
env:
runtime_file: $RUNTIME_FILE
target_dir: $TARGET_DIR
run: |
# Extract runtime filename from RUNTIME_FILE
runtime_filename=$(basename "$runtime_file")
echo "Running runtime codegen for $runtime_filename"
cd ./tools && cargo run --bin runtime-codegen --release -- --from-wasm-file "wbuild/$runtime_filename" | tee "$target_dir/codegen_runtime.rs"
- name: Fix Header generic types & Format code
run: |
cargo +nightly fmt --all
find . -name codegen_runtime.rs -exec \
sed -i 's/::sp_runtime::generic::Header<::core::primitive::u32>/::sp_runtime::generic::Header<::core::primitive::u32, ::sp_runtime::traits::BlakeTwo256>/g' {} +
cargo +nightly fmt --all
echo "Cargo check"
SKIP_WASM_BUILD=1 cargo check --workspace --target-dir=target/rust-analyzer
echo "Cargo clippy"
SKIP_WASM_BUILD=1 cargo clippy --workspace --all-targets --all-features --target-dir=target/rust-analyzer
- name: Bump minor version in Cargo.toml
run: |
# Get current version and bump minor version
current_version=$(grep '^version = ' substrate-relay/Cargo.toml | cut -d'"' -f2)
major=$(echo "$current_version" | cut -d. -f1)
minor=$(echo "$current_version" | cut -d. -f2)
patch=$(echo "$current_version" | cut -d. -f3)
# Increment patch version
new_patch=$((patch + 1))
new_version="$major.$minor.$new_patch"
echo "Bumping relayer version from $current_version to $new_version"
sed -i "s/version = \"$current_version\"/version = \"$new_version\"/" substrate-relay/Cargo.toml
- name: Create Pull Request
env:
spec_version: $SPEC_VERSION
runtime_name: $RUNTIME_NAME
runtime_version: $RUNTIME_VERSION
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
Update runtime: $runtime_name $runtime_version
- Update spec version to $spec_version
- Bump substrate-relay version to $runtime_version
- Regenerate runtime code
title: "Update runtime: $runtime_name $runtime_version"
body: |
Automated runtime update:
- Runtime: $runtime_name
- Spec Version: $spec_version
Changes:
- Updated spec version in client files
- Bumped substrate-relay minor version
- Regenerated runtime code
- Applied formatting fixes
branch: runtime-update-$runtime_name-$runtime_version
delete-branch: true

create-tag:
runs-on: ubuntu-latest
needs: release
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Get version from merged PR
id: get-version
run: |
# Extract version from PR title or branch name
if [[ "${{ github.event.pull_request.title }}" =~ Update\ runtime:\ .+\ (.+) ]]; then
version="${BASH_REMATCH[1]}"
else
# Fallback to branch name
version=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's/runtime-update-.*-//')
fi
echo "version=$version" >> $GITHUB_OUTPUT
echo "Detected version: $version"
- name: Get new substrate-relay version
id: get-cargo-version
run: |
# Read the current version from Cargo.toml
version=$(grep '^version = ' substrate-relay/Cargo.toml | cut -d'"' -f2)
echo "cargo_version=$version" >> $GITHUB_OUTPUT
echo "Cargo version: $version"
- name: Create and push tag
run: |
version="${{ steps.get-version.outputs.version }}"
cargo_version="${{ steps.get-cargo-version.outputs.cargo_version }}"
tag_name="v$cargo_version"
echo "Creating tag: $tag_name"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git tag -a "$tag_name" -m "Release $tag_name - Runtime: $version - Substrate-relay: $cargo_version"
git push origin "$tag_name"
Loading