@@ -18,14 +18,13 @@ jobs:
1818 # Benchmark (with cache hit)
1919 # ubuntu-latest 50 min
2020 # ubuntu-latest-4-cores 34 min
21- runs-on : ubuntu-latest-4-cores
21+ runs-on : ubuntu-latest-4-cores
2222 strategy :
2323 matrix :
24- target : [build-runtime]
25- package : [altair-runtime, centrifuge-runtime, development-runtime]
26- name : ${{ matrix.target }}-${{ matrix.package }}
24+ chain : [ altair, centrifuge, development ]
25+ name : build-runtime-${{ matrix.chain }}
2726 steps :
28- # PREP
27+ # PREP
2928 - name : Check out code
3029 uses : actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # 4.1.4
3130
@@ -42,22 +41,12 @@ jobs:
4241 ./target/srtool
4342 cache-directories : ./runtime
4443
45- # BUILD
46- - name : Run srtool # https://docs.substrate.io/reference/command-line-tools/srtool/
47- run : >
48- docker run --rm --user root --platform=linux/amd64
49- -e PACKAGE=${{ matrix.package }} -v /home/runner/.cargo:/cargo-home
50- -v ${{ github.workspace }}:/build paritytech/srtool:1.75.0-0.14.0
51- /srtool/build --app
52-
53- # Alternative way of running SRTool that allows for "script-like" execution,
54- # extremely useful to debug:
55-
44+ # Use this to debug what's going on inside the srtool container
5645 # - name: Run Docker SRTool
5746 # uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 #v3
5847 # with:
5948 # image: paritytech/srtool:${{ matrix.rust_version }}
60- # options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.package }}
49+ # options: --user root -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build -e BUILD_OPTS=${{ env.BUILD_OPTS || ''}} -e PACKAGE=${{ matrix.chain }}-runtime
6150 # run: |
6251 # echo "---- Env VARS ----"
6352 # echo "BUILD_OPT=${BUILD_OPT}"
@@ -66,13 +55,60 @@ jobs:
6655 # ls -la /cargo-home/
6756 # du -sh /cargo-home/*
6857 # echo "---- RUNNING BUILD ----"
69- # /srtool/build --save
58+ # /srtool/build --app --json -cM
59+
60+
61+ # Build and setup env vars:
62+ - name : Run srtool # https://docs.substrate.io/reference/command-line-tools/srtool/
63+ id : srtool_build
64+ shell : bash
65+ run : |
66+ ##"RUNNING SRTOOL"
67+ echo ::group::Docker run srtool build ${{ inputs.chain }}
68+ CMD="docker run --rm --user root --platform=linux/amd64
69+ -e PROFILE=release -e PACKAGE=${{ matrix.chain }}-runtime -e BUILD_OPTS="--features=on-chain-release-build"
70+ -v /home/runner/.cargo:/cargo-home -v ${{ github.workspace }}:/build
71+ paritytech/srtool:1.77.0-0.15.0 /srtool/build --app --json -cM"
72+ echo ::debug::build::docker_run $CMD
73+ echo ::endgroup
74+ # here we keep streaming the progress and fetch the last line for the json result
75+ stdbuf -oL $CMD | {
76+ while IFS= read -r line
77+ do
78+ echo ║ $line
79+ JSON="$line"
80+ done
81+ echo "json=$JSON" >> $GITHUB_OUTPUT
7082
71- - name : Upload srtool report
72- uses : actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
73- with :
74- name : srtool-wasm-report.txt
75- path : ./${{ matrix.package }}-srtool-wasm-report.json
83+ PROP=`echo $JSON | jq -r .runtimes.compact.prop`
84+ echo "proposal_hash=$PROP" >> $GITHUB_OUTPUT
85+
86+ WASM=`echo $JSON | jq -r .runtimes.compact.wasm`
87+ echo "wasm=$WASM" >> $GITHUB_OUTPUT
88+
89+ Z_WASM=`echo $JSON | jq -r .runtimes.compressed.wasm`
90+ echo "wasm_compressed=$Z_WASM" >> $GITHUB_OUTPUT
91+
92+ IPFS=`echo $JSON | jq -r .runtimes.compact.ipfs`
93+ echo "ipfs=$IPFS" >> $GITHUB_OUTPUT
94+ }
95+
96+ - name : Summary
97+ run : |
98+ ## Summary and JSON output
99+ echo "::group::Summary"
100+ echo "- version: ${{ steps.srtool_build.outputs.version }}"
101+ echo "- info: ${{ steps.srtool_build.outputs.info }}"
102+ echo "- prop: ${{ steps.srtool_build.outputs.proposal_hash }}"
103+ echo "- runtime location: ${{ steps.srtool_build.outputs.wasm }}"
104+ echo "::endgroup"
105+
106+ echo "::group::JSON output"
107+ PRETTY_JSON=$(echo '${{ steps.srtool_build.outputs.json }}' | jq .)
108+ echo '${{ steps.srtool_build.outputs.json }}' | jq . > "${{ matrix.chain }}-srtool-digest.json"
109+ echo "JSON Output:"
110+ cat "${{ matrix.chain }}-srtool-digest.json"
111+ echo "::endgroup"
76112
77113 - id : ' auth'
78114 if : github.event_name != 'pull_request'
@@ -89,8 +125,29 @@ jobs:
89125 if : ${{ steps.auth.outcome == 'success' }}
90126 shell : bash
91127 run : |
92- runtime_name=$(echo "${{ matrix.package }}" | sed -e "s/-runtime$//" )
93- filename=$( echo " ${{ matrix.package }}" | sed -e 's/-/_/g' )
128+ ## Publish WASM and JSON summary
129+ echo ' ${{ steps.srtool_build.outputs.json }}' | jq . > "${{ matrix.chain }}-srtool-digest.json"
94130 gsutil cp \
95- ./runtime/${runtime_name}/target/srtool/release/wbuild/${{ matrix.package }}/${filename}.compact.compressed.wasm \
96- gs://centrifuge-wasm-repo/${runtime_name}/${runtime_name}-$(git rev-parse --short HEAD).wasm
131+ "${{ steps.srtool_build.outputs.wasm }}" \
132+ "gs://centrifuge-wasm-repo/${{ matrix.chain }}/${{ matrix.chain }}-$(git rev-parse --short HEAD).wasm"
133+ gsutil cp \
134+ "${{ matrix.chain }}-srtool-digest.json" \
135+ "gs://centrifuge-wasm-repo/${{ matrix.chain }}/${{ matrix.chain }}-$(git rev-parse --short HEAD)-srtool-digest.json"
136+
137+ - name : Upload WASM to release tag ${{ github.ref_name }}
138+ uses : ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # @v1
139+ if : github.event_name == 'release'
140+ # https://github.com/ncipollo/release-action
141+ with :
142+ tag : ${{ github.ref_name }}
143+ commit : ${{ github.sha }}
144+ artifacts : " ${{ steps.srtool_build.outputs.wasm }}, ${{ matrix.chain }}-srtool-digest.json"
145+ replacesArtifacts : true
146+ allowUpdates : true
147+ artifactErrorsFailBuild : true
148+ omitBodyDuringUpdate : true
149+ omitDraftDuringUpdate : true
150+ omitNameDuringUpdate : true
151+ omitPrereleaseDuringUpdate : true
152+ # updateOnlyUnreleased: true # When allowUpdates is enabled, this will fail the action if the release it is updating is not a draft or a prerelease.
153+
0 commit comments