Skip to content

kusama: enable disabling ParachainHost API (#148) #5

kusama: enable disabling ParachainHost API (#148)

kusama: enable disabling ParachainHost API (#148) #5

Workflow file for this run

name: Create Release
on:
push:
branches: [ "main" ]
paths: [ "CHANGELOG.md" ]
workflow_dispatch:
jobs:
collect-release-information:
runs-on: ubuntu-latest
outputs:
should-release: ${{ steps.run.outputs.should-release }}
version: ${{ steps.run.outputs.version }}
steps:
- uses: actions/checkout@v2
- id: run
run: |
echo "should-release=$(.github/changelog-processor.py CHANGELOG.md --should-release)" >> $GITHUB_OUTPUT
echo "version=$(.github/changelog-processor.py CHANGELOG.md --print-latest-version)" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
runtime-matrix:
needs: [ collect-release-information ]
if: needs.collect-release-information.outputs.should-release == '1'
runs-on: ubuntu-latest
outputs:
runtime: ${{ steps.runtime.outputs.runtime }}
steps:
- uses: actions/checkout@v2
- id: runtime
run: |
TASKS=$(echo $(cat .github/workflows/runtimes-matrix.json) | sed 's/ //g' )
echo $TASKS
echo "runtime=$TASKS" >> $GITHUB_OUTPUT
build-runtimes:
needs: [ runtime-matrix ]
continue-on-error: true
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Cache target dir
uses: actions/cache@v3
with:
path: "${{ github.workspace }}/${{ matrix.runtime.path }}/target"
key: srtool-target-${{ matrix.runtime.path }}-${{ matrix.runtime.name }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ matrix.runtime.path }}-${{ matrix.runtime.name }}-
srtool-target-${{ matrix.runtime.path }}-
- name: Build ${{ matrix.runtime.name }}
id: srtool_build
uses: chevdor/[email protected]
env:
BUILD_OPTS: "--features on-chain-release-build"
with:
chain: ${{ matrix.runtime.name }}
package: ${{ matrix.runtime.package }}
runtime_dir: ${{ matrix.runtime.path }}
profile: "production"
- name: Store ${{ matrix.runtime.name }} srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | jq > ${{ matrix.runtime.name }}_srtool_output.json
- name: Upload ${{ matrix.runtime.name }} srtool json
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.runtime.name }}-srtool-json
path: ${{ matrix.runtime.name }}_srtool_output.json
- name: Upload ${{ matrix.runtime.name }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.runtime.name }}
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
publish-release:
runs-on: ubuntu-latest
needs: [ build-runtimes, collect-release-information ]
outputs:
release_url: ${{ steps.create-release.outputs.html_url }}
asset_upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download srtool json output
uses: actions/download-artifact@v3
- name: Archive context output
uses: actions/upload-artifact@v3
with:
name: release-notes-context
path: |
**/*_srtool_output.json
- name: Add runtime info to changelog
run: |
CONTEXT=$(find . -name '*_srtool_output.json')
SRTOOL() { <$(<<<$CONTEXT head -n1) jq -r .$1; }
WASM() { <${JSON} jq -r ".runtimes.compressed.subwasm.$1"; }
# Copy the relevant parts of the changelog
.github/changelog-processor.py CHANGELOG.md --print-changelog-from-last-release > DRAFT
tee -a DRAFT <<-EOF
# Runtime info
*These runtimes were built with **$(SRTOOL rustc)** using **[$(SRTOOL gen)](https://github.com/paritytech/srtool)***
To replicate the build, use the following command:
```sh
srtool build \
--root --profile production \
--package CRATE_NAME --runtime-dir PATH_TO_CRATE \
--build-opts="--features=on-chain-release-build"
```
EOF
for JSON in $(<<<$CONTEXT sort -sr)
do
SPEC_NAME=$(WASM 'core_version.specName')
# Check for spec names and adjust the heading accordingly
if [[ "$SPEC_NAME" == "statemint" ]]; then
HEADING="Asset Hub Polkadot (previously Statemint)"
elif [[ "$SPEC_NAME" == "statemine" ]]; then
HEADING="Asset Hub Kusama (previously Statemine)"
else
HEADING=$(WASM 'core_version.specName / "-" | map(. / "" | first |= ascii_upcase | add) | join(" ")')
fi
tee -a DRAFT <<-EOF
## $HEADING
~~~
🏋️ Runtime Size: $(numfmt --to iec-i --format "%.2f" $(WASM size)) ($(WASM size) bytes)
🗜 Compressed: $(WASM 'compression | if .compressed then "Yes: \(1 - .size_compressed / .size_decompressed | . * 10000 | round / 100)%" else "No" end')
🔥 Core Version: $(WASM 'core_version | "\(.specName)-\(.specVersion) \(.implName)-\(.implVersion).tx\(.transactionVersion).au\(.authoringVersion)"')
🎁 Metadata version: V$(WASM metadata_version)
🗳️ Blake2-256 hash: $(WASM blake2_256)
📦 IPFS: $(WASM ipfs_hash)
~~~
EOF
done
- name: Create release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ format('v{0}', needs.collect-release-information.outputs.version) }}
release_name: Runtimes ${{ needs.collect-release-information.outputs.version }}
body_path: DRAFT
draft: false
publish-runtimes:
needs: [ runtime-matrix, publish-release ]
continue-on-error: true
runs-on: ubuntu-latest
env:
RUNTIME_DIR: runtime
strategy:
matrix:
runtime: ${{ fromJSON(needs.runtime-matrix.outputs.runtime) }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Get runtime info
env:
JSON: release-notes-context/${{ matrix.runtime.name }}-srtool-json/${{ matrix.runtime.name }}_srtool_output.json
run: |
>>$GITHUB_ENV echo ASSET=$(find ${{ matrix.runtime.name }} -name '*.compact.compressed.wasm')
>>$GITHUB_ENV echo SPEC=$(<${JSON} jq -r .runtimes.compact.subwasm.core_version.specVersion)
- name: Upload compressed ${{ matrix.runtime.name }} v${{ env.SPEC }} wasm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release.outputs.asset_upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ matrix.runtime.name }}_runtime-v${{ env.SPEC }}.compact.compressed.wasm
asset_content_type: application/wasm