Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automate chain specs generation #132

Merged
merged 19 commits into from
Sep 26, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
name: Build Deterministic Runtimes
name: Create Runtimes releases

on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_version:
description: 'Tag version for the release'
required: true
type: string

jobs:
generate-chain-specs:
uses: ./.github/workflows/generate-chain-specs.yaml
with:
tag_version: ${{ github.event.inputs.tag_version }}

create-tag:
needs: generate-chain-specs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- name: Setup Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.PASEO_RUNTIME_CI_PAT }}

- name: Create and push tag
run: |
git checkout ${{ github.ref }}
git tag ${{ github.event.inputs.tag_version }}
git push origin ${{ github.event.inputs.tag_version }}

srtool:
needs: create-tag
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -21,9 +53,14 @@ jobs:
path: "system-parachains/bridge-hub-paseo"
- name: "people-paseo"
path: "system-parachains/people-paseo"
- name: "coretime-paseo"
path: "system-parachains/coretime-paseo"

steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag_version }}

- name: Cache runtime target dir
uses: actions/cache@v3
Expand All @@ -49,24 +86,27 @@ jobs:
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq . > ${{ matrix.runtime.name }}-srtool-digest.json

# Manual trigger: add artifacts to run
# Copy artifacts
- name: Copy artifacts
if: github.event_name != 'release'
run: cp `dirname ${{ steps.srtool_build.outputs.wasm }}`/*.wasm ./

- name: Archive Runtime
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.runtime.name }}-runtime-${{ github.sha }}
name: ${{ matrix.runtime.name }}-runtime-${{ github.event.inputs.tag_version }}
path: |
${{ matrix.runtime.name }}*.wasm
${{ matrix.runtime.name }}-srtool-digest.json

# Release published: add artifacts to release
- name: Add artifacts to release
if: github.event_name == 'release'
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag_version }}
name: Release ${{ github.event.inputs.tag_version }}
draft: false
prerelease: false
generate_release_notes: true
append_body: true
body: |
## Runtime: `${{ matrix.runtime.name }}`
Expand All @@ -82,3 +122,5 @@ jobs:
files: |
${{ steps.srtool_build.outputs.wasm_compressed }}
${{ matrix.runtime.name }}-srtool-digest.json
env:
GITHUB_TOKEN: ${{ secrets.PASEO_RUNTIME_CI_PAT }}
85 changes: 85 additions & 0 deletions .github/workflows/generate-chain-specs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Generate Chain Specs

on:
workflow_dispatch:
inputs:
tag_version:
description: 'Tag version for the release'
required: true
type: string
workflow_call:
inputs:
tag_version:
description: 'Tag version for the release'
required: true
type: string

permissions:
contents: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
generate-chain-specs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y git protobuf-compiler

- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: 1.77.0
target: wasm32-unknown-unknown
components: rust-src
override: true

- name: Add rust-src
run: rustup component add rust-src --toolchain 1.77.0-x86_64-unknown-linux-gnu

- name: Build chain-spec-generator
run: cargo build --package chain-spec-generator --features=fast-runtime --release

- name: Generate chain specs
run: |
mkdir -p chain-specs/local
PACKAGES=(
"paseo-local"
"paseo-dev"
"asset-hub-paseo-local"
"bridge-hub-paseo-local"
"people-paseo-local"
"coretime-paseo-local"
raynaudoe marked this conversation as resolved.
Show resolved Hide resolved
)

for pkg in "${PACKAGES[@]}"; do
./target/release/chain-spec-generator "$pkg" --raw > "chain-specs/local/$pkg.json"
echo "Generated chain-specs/local/$pkg.json"
done

- name: Setup Git
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.PASEO_RUNTIME_CI_PAT }}

- name: Commit changes
run: |
git add chain-specs/local/*.json
if git diff --staged --quiet; then
echo "No changes detected in chain specs. Skipping commit."
else
COMMIT_MESSAGE="Update chain specs for version ${{ inputs.tag_version }}"
git commit -m "$COMMIT_MESSAGE"
git push
echo "Changes committed and pushed successfully."
fi