From 3c14dd9b5a91f97d643877b4b99427b890f74dea Mon Sep 17 00:00:00 2001 From: arescui Date: Mon, 30 Dec 2024 21:39:08 +0800 Subject: [PATCH 1/4] [skip ci](srtool): optimize runtime build workflow - Add automatic trigger for rc version tags (v*.*.*.rc*) - Flatten artifact directory structure - Add runtime info to Slack notification - Remove redundant subwasm artifacts - Improve workflow reusability for release process Co-authored-by: Ares --- .github/workflows/release.yml | 2 + .github/workflows/srtool.yml | 83 +++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0568bf570a..c9a3e419ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ on: jobs: srtool: uses: ./.github/workflows/srtool.yml + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} release: name: Create Release needs: srtool diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 2cdcacfa8d..4c07a238fe 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -6,22 +6,29 @@ env: on: workflow_dispatch: workflow_call: + secrets: + SLACK_WEBHOOK_URL: + required: true + push: + tags: + - 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+' jobs: build: - name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref }} + name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref || github.ref_name }} strategy: fail-fast: false matrix: chain: ["bifrost-kusama", "bifrost-polkadot"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: "📥 Checkout" + uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 + ref: ${{ github.event.inputs.ref || github.ref }} + fetch-depth: 1 - - name: Srtool build + - name: "🏗️ Build Runtime" id: srtool_build uses: chevdor/srtool-actions@v0.8.0 env: @@ -30,45 +37,63 @@ jobs: profile: production chain: ${{ matrix.chain }} runtime_dir: runtime/${{ matrix.chain }} - - name: Summary + + - name: "🔍 Summary" run: | echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json cat ${{ matrix.chain }}-srtool-digest.json echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" + cp ${{ steps.srtool_build.outputs.wasm_compressed }} ./${{ matrix.chain }}_runtime.compact.compressed.wasm - # it takes a while to build the runtime, so let's save the artifact as soon as we have it - - name: Archive Artifacts for ${{ matrix.chain }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - path: | - ${{ steps.srtool_build.outputs.wasm }} - ${{ steps.srtool_build.outputs.wasm_compressed }} - ${{ matrix.chain }}-srtool-digest.json - - # We now get extra information thanks to subwasm, - name: Install subwasm ${{ env.SUBWASM_VERSION }} run: | wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb subwasm --version - - name: Show Runtime information + + - name: "🔍 Get Runtime information" + id: runtime_info run: | + echo "compressed_info<> $GITHUB_OUTPUT + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT subwasm info ${{ steps.srtool_build.outputs.wasm }} subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} - subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json - subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json - - name: Extract the metadata - run: | subwasm meta ${{ steps.srtool_build.outputs.wasm }} - subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json + subwasm info ${{ steps.srtool_build.outputs.wasm }} > runtime_info.txt + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} >> runtime_info.txt - - name: Archive Subwasm results + - name: Archive Artifacts for ${{ matrix.chain }} + id: upload_artifacts uses: actions/upload-artifact@v4 with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} + name: ${{ matrix.chain }}-runtime-${{ github.event.inputs.ref || github.ref_name }} path: | - ${{ matrix.chain }}-info.json - ${{ matrix.chain }}-info_compressed.json - ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt + ${{ matrix.chain }}_runtime.compact.compressed.wasm + ${{ matrix.chain }}-srtool-digest.json + runtime_info.txt + + - uses: 8398a7/action-slack@v3 + name: "Send Slack Notification" + if: success() + with: + status: custom + fields: workflow,job,commit,repo,ref,author,took + custom_payload: | + { + "attachments": [{ + "color": "good", + "text": ":rocket: New runtime build for ${{ matrix.chain }} (${{ github.event.inputs.ref || github.ref_name }})\nDownload artifacts: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload_artifacts.outputs.artifact-id }}" + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Debug Trigger + run: | + echo "github.ref: ${{ github.ref }}" + echo "github.ref_name: ${{ github.ref_name }}" + echo "github.event_name: ${{ github.event_name }}" + echo "github.action: ${{ github.action }}" + + From eaf09ffcc62833c2fd5a173d5d1cc199200e7aac Mon Sep 17 00:00:00 2001 From: arescui Date: Mon, 30 Dec 2024 21:50:04 +0800 Subject: [PATCH 2/4] [skip ci]: fix release srtool file --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9a3e419ef..d617d8bbae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,16 +29,16 @@ jobs: target: wasm32-unknown-unknown toolchain: 1.81.0 - - name: Download kusama strool result + - name: Download kusama srtool result uses: actions/download-artifact@v4 with: - name: bifrost-kusama-runtime + name: bifrost-kusama-runtime-${{ github.ref_name }} path: ${{ github.workspace }}/artifacts - - name: Download polkadot strool result + - name: Download polkadot srtool result uses: actions/download-artifact@v4 with: - name: bifrost-polkadot-runtime + name: bifrost-polkadot-runtime-${{ github.ref_name }} path: ${{ github.workspace }}/artifacts - name: Build bifrost @@ -48,8 +48,8 @@ jobs: make production-release mkdir -p ${{ github.workspace }}/artifacts mv ${{ github.workspace }}/target/production/bifrost ${{ github.workspace }}/artifacts/ - mv ${{ github.workspace }}/artifacts/runtime/bifrost-kusama/target/srtool/production/wbuild/bifrost-kusama-runtime/bifrost_kusama_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ - mv ${{ github.workspace }}/artifacts/runtime/bifrost-polkadot/target/srtool/production/wbuild/bifrost-polkadot-runtime/bifrost_polkadot_runtime.compact.compressed.wasm ${{ github.workspace }}/artifacts/ + + ls -a ${{ github.workspace }}/artifacts pushd ${{ github.workspace }}/artifacts sha256sum bifrost | tee bifrost.sha256 shasum -c bifrost.sha256 @@ -98,4 +98,4 @@ jobs: status: ${{ job.status }} fields: repo,author,eventName,workflow,ref,commit env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} From ef22597cf69f4cca4ceddee04b6a5bbdfc8c501c Mon Sep 17 00:00:00 2001 From: arescui Date: Tue, 31 Dec 2024 11:55:48 +0800 Subject: [PATCH 3/4] [skip ci] fix release file name --- .github/workflows/release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d617d8bbae..fa4fe8890f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,12 +69,12 @@ jobs: Low: This is a low priority release and you may upgrade at your convenience." >> ${{ github.workspace }}-CHANGELOG.txt echo "## Bifrost Kusama Runtime" >> ${{ github.workspace }}-CHANGELOG.txt echo '```' >> ${{ github.workspace }}-CHANGELOG.txt - subwasm info ${{ github.workspace }}/artifacts/bifrost_kusama_runtime.compact.compressed.wasm >> ${{ github.workspace }}-CHANGELOG.txt + subwasm info ${{ github.workspace }}/artifacts/bifrost-kusama_runtime.compact.compressed.wasm >> ${{ github.workspace }}-CHANGELOG.txt echo '```' >> ${{ github.workspace }}-CHANGELOG.txt echo ' ' >> ${{ github.workspace }}-CHANGELOG.txt echo "## Bifrost Polkadot Runtime" >> ${{ github.workspace }}-CHANGELOG.txt echo '```' >> ${{ github.workspace }}-CHANGELOG.txt - subwasm info ${{ github.workspace }}/artifacts/bifrost_polkadot_runtime.compact.compressed.wasm >> ${{ github.workspace }}-CHANGELOG.txt + subwasm info ${{ github.workspace }}/artifacts/bifrost-polkadot_runtime.compact.compressed.wasm >> ${{ github.workspace }}-CHANGELOG.txt echo '```' >> ${{ github.workspace }}-CHANGELOG.txt - name: Create Release @@ -89,8 +89,8 @@ jobs: files: | ${{ github.workspace }}/artifacts/bifrost ${{ github.workspace }}/artifacts/bifrost.sha256 - ${{ github.workspace }}/artifacts/bifrost_kusama_runtime.compact.compressed.wasm - ${{ github.workspace }}/artifacts/bifrost_polkadot_runtime.compact.compressed.wasm + ${{ github.workspace }}/artifacts/bifrost-kusama_runtime.compact.compressed.wasm + ${{ github.workspace }}/artifacts/bifrost-polkadot_runtime.compact.compressed.wasm - uses: 8398a7/action-slack@v3 if: always() From 69edb8806b6785cea5aab0ac8ddf35afe8f2a914 Mon Sep 17 00:00:00 2001 From: arescui Date: Mon, 30 Dec 2024 21:39:08 +0800 Subject: [PATCH 4/4] [skip ci](srtool): optimize runtime build workflow - Add automatic trigger for rc version tags (v*.*.*.rc*) - Flatten artifact directory structure - Add runtime info to Slack notification - Remove redundant subwasm artifacts - Improve workflow reusability for release process Co-authored-by: Ares --- .github/workflows/release.yml | 2 + .github/workflows/srtool.yml | 83 +++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 29 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0568bf570a..c9a3e419ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ on: jobs: srtool: uses: ./.github/workflows/srtool.yml + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} release: name: Create Release needs: srtool diff --git a/.github/workflows/srtool.yml b/.github/workflows/srtool.yml index 2cdcacfa8d..4c07a238fe 100644 --- a/.github/workflows/srtool.yml +++ b/.github/workflows/srtool.yml @@ -6,22 +6,29 @@ env: on: workflow_dispatch: workflow_call: + secrets: + SLACK_WEBHOOK_URL: + required: true + push: + tags: + - 'v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]+' jobs: build: - name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref }} + name: Build ${{ matrix.chain }} ${{ github.event.inputs.ref || github.ref_name }} strategy: fail-fast: false matrix: chain: ["bifrost-kusama", "bifrost-polkadot"] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - name: "📥 Checkout" + uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.ref }} - fetch-depth: 0 + ref: ${{ github.event.inputs.ref || github.ref }} + fetch-depth: 1 - - name: Srtool build + - name: "🏗️ Build Runtime" id: srtool_build uses: chevdor/srtool-actions@v0.8.0 env: @@ -30,45 +37,63 @@ jobs: profile: production chain: ${{ matrix.chain }} runtime_dir: runtime/${{ matrix.chain }} - - name: Summary + + - name: "🔍 Summary" run: | echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.chain }}-srtool-digest.json cat ${{ matrix.chain }}-srtool-digest.json echo "Runtime location: ${{ steps.srtool_build.outputs.wasm }}" + cp ${{ steps.srtool_build.outputs.wasm_compressed }} ./${{ matrix.chain }}_runtime.compact.compressed.wasm - # it takes a while to build the runtime, so let's save the artifact as soon as we have it - - name: Archive Artifacts for ${{ matrix.chain }} - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.chain }}-runtime - path: | - ${{ steps.srtool_build.outputs.wasm }} - ${{ steps.srtool_build.outputs.wasm_compressed }} - ${{ matrix.chain }}-srtool-digest.json - - # We now get extra information thanks to subwasm, - name: Install subwasm ${{ env.SUBWASM_VERSION }} run: | wget https://github.com/chevdor/subwasm/releases/download/v${{ env.SUBWASM_VERSION }}/subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb sudo dpkg -i subwasm_linux_amd64_v${{ env.SUBWASM_VERSION }}.deb subwasm --version - - name: Show Runtime information + + - name: "🔍 Get Runtime information" + id: runtime_info run: | + echo "compressed_info<> $GITHUB_OUTPUT + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT subwasm info ${{ steps.srtool_build.outputs.wasm }} subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} - subwasm --json info ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-info.json - subwasm --json info ${{ steps.srtool_build.outputs.wasm_compressed }} > ${{ matrix.chain }}-info_compressed.json - - name: Extract the metadata - run: | subwasm meta ${{ steps.srtool_build.outputs.wasm }} - subwasm --json meta ${{ steps.srtool_build.outputs.wasm }} > ${{ matrix.chain }}-metadata.json + subwasm info ${{ steps.srtool_build.outputs.wasm }} > runtime_info.txt + subwasm info ${{ steps.srtool_build.outputs.wasm_compressed }} >> runtime_info.txt - - name: Archive Subwasm results + - name: Archive Artifacts for ${{ matrix.chain }} + id: upload_artifacts uses: actions/upload-artifact@v4 with: - name: ${{ matrix.chain }}-runtime-${{ github.sha }} + name: ${{ matrix.chain }}-runtime-${{ github.event.inputs.ref || github.ref_name }} path: | - ${{ matrix.chain }}-info.json - ${{ matrix.chain }}-info_compressed.json - ${{ matrix.chain }}-metadata.json - ${{ matrix.chain }}-diff.txt + ${{ matrix.chain }}_runtime.compact.compressed.wasm + ${{ matrix.chain }}-srtool-digest.json + runtime_info.txt + + - uses: 8398a7/action-slack@v3 + name: "Send Slack Notification" + if: success() + with: + status: custom + fields: workflow,job,commit,repo,ref,author,took + custom_payload: | + { + "attachments": [{ + "color": "good", + "text": ":rocket: New runtime build for ${{ matrix.chain }} (${{ github.event.inputs.ref || github.ref_name }})\nDownload artifacts: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.upload_artifacts.outputs.artifact-id }}" + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Debug Trigger + run: | + echo "github.ref: ${{ github.ref }}" + echo "github.ref_name: ${{ github.ref_name }}" + echo "github.event_name: ${{ github.event_name }}" + echo "github.action: ${{ github.action }}" + +