From 383821b1f722d2eb37eae88a7572d43cc0019d52 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 14:49:53 +0200 Subject: [PATCH 01/16] initial build-wasms commit --- .github/workflows/build-wasms.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/build-wasms.yml diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml new file mode 100644 index 000000000000..856287858a8d --- /dev/null +++ b/.github/workflows/build-wasms.yml @@ -0,0 +1,22 @@ +name: Build runtime WASMS + +# TODO: Change this to be tag-restricted before submitting PR +on: push + +jobs: + build-polkadot-runtime: + runs-on: ubuntu-latest + container: + image: chevdor/srtool:nightly-2020-07-20 + volumes: + - ${{ github.workspace }}:/build + env: + PACKAGE: release + RUSTC_VERSION: nightly-2020-07-20 + steps: + - uses: actions/checkout@v2 + - id: build-runtime + run: | + pwd + ls + build From 98cd3ea5ece50c0736396bcaa0398dcc10a31806 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 15:39:42 +0200 Subject: [PATCH 02/16] fix wasm builds --- .github/workflows/build-wasms.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index 856287858a8d..b097be280115 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -11,12 +11,13 @@ jobs: volumes: - ${{ github.workspace }}:/build env: - PACKAGE: release + PACKAGE: polkadot-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - uses: actions/checkout@v2 - id: build-runtime run: | + cd /build pwd ls build From 880509a3c76c75cdc1515a9747468115c5cf6e8f Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 16:37:18 +0200 Subject: [PATCH 03/16] add caching and artifact upload --- .github/workflows/build-wasms.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index b097be280115..a901a908e83f 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -15,9 +15,27 @@ jobs: RUSTC_VERSION: nightly-2020-07-20 steps: - uses: actions/checkout@v2 - - id: build-runtime + - name: Cache target dir + uses: actions/cache@v2 + with: + path: '/build/target' + key: srtool-target-polkadot-${{ github.sha }} + restore-keys: | + srtool-target-polkadot- + srtool-target + - name: Build polkadot runtime + id: build-runtime + shell: bash run: | cd /build pwd - ls - build + ls -la + build --json | tee srtool_output.json + while IFS= read -r line; do + echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" + done <<< "$(jq -r 'keys[]' < srtool_output.json)" + - name: Upload polkadot runtime + uses: actions/upload-artifact@v2 + with: + name: polkadot-runtime + path: "${{ steps.build-runtime.outputs.wasm }}" From 295e4655484691aed9162f479a87f09c1b1c9317 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 17:37:11 +0200 Subject: [PATCH 04/16] test for git dir --- .github/workflows/build-wasms.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index a901a908e83f..be58c19f74dc 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -9,12 +9,15 @@ jobs: container: image: chevdor/srtool:nightly-2020-07-20 volumes: - - ${{ github.workspace }}:/build + - ${{ github.workspace }}/polkadot:/build env: PACKAGE: polkadot-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - uses: actions/checkout@v2 + - run: | + ls -lha /build + exit 1 - name: Cache target dir uses: actions/cache@v2 with: From 8067da4d43c33ec7367d3f0d4359535531afc1d6 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 17:56:58 +0200 Subject: [PATCH 05/16] Revert "test for git dir" This reverts commit 295e4655484691aed9162f479a87f09c1b1c9317. --- .github/workflows/build-wasms.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index be58c19f74dc..a901a908e83f 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -9,15 +9,12 @@ jobs: container: image: chevdor/srtool:nightly-2020-07-20 volumes: - - ${{ github.workspace }}/polkadot:/build + - ${{ github.workspace }}:/build env: PACKAGE: polkadot-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - uses: actions/checkout@v2 - - run: | - ls -lha /build - exit 1 - name: Cache target dir uses: actions/cache@v2 with: From 1d22ffd26b7eff635c5abcc9bd04cb3c88629a1d Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 17:58:34 +0200 Subject: [PATCH 06/16] fix git version incompability --- .github/workflows/build-wasms.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index a901a908e83f..770f7518c13f 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -14,7 +14,9 @@ jobs: PACKAGE: polkadot-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - - uses: actions/checkout@v2 + # Force use of checkout@v1 due to srtool not having git v2.18 + # https://github.com/actions/checkout/issues/238 + - uses: actions/checkout@v1 - name: Cache target dir uses: actions/cache@v2 with: From 16c860c13acb2c322a0c4d43922a2920667ab3ae Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 18:09:13 +0200 Subject: [PATCH 07/16] attempt to fix caching --- .github/workflows/build-wasms.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index 770f7518c13f..06c3cbc0cc06 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -20,7 +20,7 @@ jobs: - name: Cache target dir uses: actions/cache@v2 with: - path: '/build/target' + path: '${{ github.workspace }}/target' key: srtool-target-polkadot-${{ github.sha }} restore-keys: | srtool-target-polkadot- From 128c571a609c21f8df2761b2be286135977569a0 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 18:11:21 +0200 Subject: [PATCH 08/16] Revert "fix git version incompability" This reverts commit 1d22ffd26b7eff635c5abcc9bd04cb3c88629a1d. --- .github/workflows/build-wasms.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index 06c3cbc0cc06..034a8196a730 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -14,9 +14,7 @@ jobs: PACKAGE: polkadot-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - # Force use of checkout@v1 due to srtool not having git v2.18 - # https://github.com/actions/checkout/issues/238 - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Cache target dir uses: actions/cache@v2 with: From 609d596bb46d9ee3f4d7554db12a1a663f33d3cf Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Wed, 29 Jul 2020 19:21:39 +0200 Subject: [PATCH 09/16] add kusama job --- .github/workflows/build-wasms.yml | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index 034a8196a730..529cf4cedc48 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -23,7 +23,7 @@ jobs: restore-keys: | srtool-target-polkadot- srtool-target - - name: Build polkadot runtime + - name: Build polkadot runtime id: build-runtime shell: bash run: | @@ -39,3 +39,38 @@ jobs: with: name: polkadot-runtime path: "${{ steps.build-runtime.outputs.wasm }}" + build-kusama-runtime: + runs-on: ubuntu-latest + container: + image: chevdor/srtool:nightly-2020-07-20 + volumes: + - ${{ github.workspace }}:/build + env: + PACKAGE: kusama-runtime + RUSTC_VERSION: nightly-2020-07-20 + steps: + - uses: actions/checkout@v2 + - name: Cache target dir + uses: actions/cache@v2 + with: + path: '${{ github.workspace }}/target' + key: srtool-target-kusama-${{ github.sha }} + restore-keys: | + srtool-target-kusama- + srtool-target + - name: Build kusama runtime + id: build-runtime + shell: bash + run: | + cd /build + pwd + ls -la + build --json | tee srtool_output.json + while IFS= read -r line; do + echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" + done <<< "$(jq -r 'keys[]' < srtool_output.json)" + - name: Upload kusama runtime + uses: actions/upload-artifact@v2 + with: + name: kusama-runtime + path: "${{ steps.build-runtime.outputs.wasm }}" From 20423651696c51be05b093ef48579016d823a814 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 15:09:23 +0200 Subject: [PATCH 10/16] use a build matrix for building runtimes --- .github/workflows/build-wasms.yml | 54 +++++++------------------------ 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml index 529cf4cedc48..e602ce848f21 100644 --- a/.github/workflows/build-wasms.yml +++ b/.github/workflows/build-wasms.yml @@ -4,14 +4,17 @@ name: Build runtime WASMS on: push jobs: - build-polkadot-runtime: + build-runtimes: runs-on: ubuntu-latest + strategy: + matrix: + runtime: ['polkadot', 'kusama'] container: image: chevdor/srtool:nightly-2020-07-20 volumes: - ${{ github.workspace }}:/build env: - PACKAGE: polkadot-runtime + PACKAGE: ${{ matrix.runtime }}-runtime RUSTC_VERSION: nightly-2020-07-20 steps: - uses: actions/checkout@v2 @@ -19,11 +22,11 @@ jobs: uses: actions/cache@v2 with: path: '${{ github.workspace }}/target' - key: srtool-target-polkadot-${{ github.sha }} + key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} restore-keys: | - srtool-target-polkadot- - srtool-target - - name: Build polkadot runtime + srtool-target-${{ matrix.runtime }}- + srtool-target- + - name: Build ${{ matrix.runtime }} runtime id: build-runtime shell: bash run: | @@ -34,43 +37,8 @@ jobs: while IFS= read -r line; do echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" done <<< "$(jq -r 'keys[]' < srtool_output.json)" - - name: Upload polkadot runtime + - name: Upload ${{ matrix.runtime }} runtime uses: actions/upload-artifact@v2 with: - name: polkadot-runtime - path: "${{ steps.build-runtime.outputs.wasm }}" - build-kusama-runtime: - runs-on: ubuntu-latest - container: - image: chevdor/srtool:nightly-2020-07-20 - volumes: - - ${{ github.workspace }}:/build - env: - PACKAGE: kusama-runtime - RUSTC_VERSION: nightly-2020-07-20 - steps: - - uses: actions/checkout@v2 - - name: Cache target dir - uses: actions/cache@v2 - with: - path: '${{ github.workspace }}/target' - key: srtool-target-kusama-${{ github.sha }} - restore-keys: | - srtool-target-kusama- - srtool-target - - name: Build kusama runtime - id: build-runtime - shell: bash - run: | - cd /build - pwd - ls -la - build --json | tee srtool_output.json - while IFS= read -r line; do - echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" - done <<< "$(jq -r 'keys[]' < srtool_output.json)" - - name: Upload kusama runtime - uses: actions/upload-artifact@v2 - with: - name: kusama-runtime + name: ${{ matrix.runtime }}-runtime path: "${{ steps.build-runtime.outputs.wasm }}" From 1f5ec2997fd1a9416363e51810a08c47b67750d8 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 15:35:36 +0200 Subject: [PATCH 11/16] combine build-wasms and publish draft release --- .github/workflows/build-wasms.yml | 44 -------------- .github/workflows/publish-draft-release.yml | 64 +++++++++++++++++++++ 2 files changed, 64 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/build-wasms.yml diff --git a/.github/workflows/build-wasms.yml b/.github/workflows/build-wasms.yml deleted file mode 100644 index e602ce848f21..000000000000 --- a/.github/workflows/build-wasms.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build runtime WASMS - -# TODO: Change this to be tag-restricted before submitting PR -on: push - -jobs: - build-runtimes: - runs-on: ubuntu-latest - strategy: - matrix: - runtime: ['polkadot', 'kusama'] - container: - image: chevdor/srtool:nightly-2020-07-20 - volumes: - - ${{ github.workspace }}:/build - env: - PACKAGE: ${{ matrix.runtime }}-runtime - RUSTC_VERSION: nightly-2020-07-20 - steps: - - uses: actions/checkout@v2 - - name: Cache target dir - uses: actions/cache@v2 - with: - path: '${{ github.workspace }}/target' - key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} - restore-keys: | - srtool-target-${{ matrix.runtime }}- - srtool-target- - - name: Build ${{ matrix.runtime }} runtime - id: build-runtime - shell: bash - run: | - cd /build - pwd - ls -la - build --json | tee srtool_output.json - while IFS= read -r line; do - echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" - done <<< "$(jq -r 'keys[]' < srtool_output.json)" - - name: Upload ${{ matrix.runtime }} runtime - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.runtime }}-runtime - path: "${{ steps.build-runtime.outputs.wasm }}" diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index c7cc8d441b37..cdf2acf7fe43 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -24,6 +24,7 @@ jobs: needs: get-rust-versions outputs: release_url: ${{ steps.create-release.outputs.html_url }} + asset_upload_url: ${{ steps.create-release.outputs.upload_url }} steps: - uses: actions/checkout@v2 with: @@ -66,3 +67,66 @@ jobs: access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} message: "**New version of polkadot tagged**: ${{ github.ref }}
Gav: Draft release created: ${{ needs.publish-draft-release.outputs.release_url }}" server: "matrix.parity.io" + + build-runtimes: + runs-on: ubuntu-latest + strategy: + matrix: + runtime: ['polkadot', 'kusama'] + container: + image: chevdor/srtool:nightly-2020-07-20 + volumes: + - ${{ github.workspace }}:/build + env: + PACKAGE: ${{ matrix.runtime }}-runtime + RUSTC_VERSION: nightly-2020-07-20 + steps: + - uses: actions/checkout@v2 + - name: Cache target dir + uses: actions/cache@v2 + with: + path: '${{ github.workspace }}/target' + key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} + restore-keys: | + srtool-target-${{ matrix.runtime }}- + srtool-target- + - name: Build ${{ matrix.runtime }} runtime + id: build-runtime + shell: bash + run: | + cd /build + pwd + ls -la + build --json | tee srtool_output.json + while IFS= read -r line; do + echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" + done <<< "$(jq -r 'keys[]' < srtool_output.json)" + - name: Upload ${{ matrix.runtime }} runtime + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.runtime }}-runtime + path: "${{ steps.build-runtime.outputs.wasm }}" + + # Have publishing the runtimes to the release as a separate job for 2 reasons + # 1. It allows us to start building the runtimes before the draft release is created + # 2. We don't have to run it in the srtool container, thus avoiding compatibility issues + # Sadly it means we need to recreate the same matrix as the build-runtimes job + publish-runtimes: + runs-on: ubuntu-latest + needs: ['build-runtimes', 'publish-draft-release'] + strategy: + matrix: + runtime: ['polkadot', 'kusama'] + steps: + - uses: actions/download-artifact@v2 + with: + name: ${{ matrix.runtime }}-runtime + - name: Upload ${{ matrix.runtime }} wasm + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }} + asset_path: ./${{ matrix.runtime }}_runtime.compact.wasm + asset_name: ${{ matrix.runtime }} runtime + asset_content_type: application/wasm From 82f7b4dc0aea995f2599293bba9f11b879f459e5 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 16:54:28 +0200 Subject: [PATCH 12/16] attempt to name runtimes according to version --- .github/workflows/publish-draft-release.yml | 12 ++++++++++-- scripts/github/generate_release_text.rb | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index cdf2acf7fe43..43d704b1489e 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -23,8 +23,12 @@ jobs: runs-on: ubuntu-latest needs: get-rust-versions outputs: + release_id: ${{ steps.create-release.outputs.id }} release_url: ${{ steps.create-release.outputs.html_url }} asset_upload_url: ${{ steps.create-release.outputs.upload_url }} + polkadot_runtime_version: ${{ steps.generate-release-text.polkadot_runtime }} + kusama_runtime_version: ${{ steps.generate-release-text.kusama_runtime }} + westend_runtime_version: ${{ steps.generate-release-text.westend_runtime }} steps: - uses: actions/checkout@v2 with: @@ -35,12 +39,13 @@ jobs: with: ruby-version: 2.7 - name: Generate release text + id: generate-release-text env: RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }} RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }} run: | gem install changelogerator git toml - ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb > release_text.md + ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb - uses: actions/upload-artifact@v2 with: name: release_text @@ -121,12 +126,15 @@ jobs: - uses: actions/download-artifact@v2 with: name: ${{ matrix.runtime }}-runtime + - name: Rename asset according to runtime version + run: | + mv ./${{ matrix.runtime }}_runtime.compact-wasm ./${{ matrix.runtime }}-${{ needs.publish-draft-release.outputs.${{ matrix.runtime }}_runtime_version }}_runtime.compact.wasm - name: Upload ${{ matrix.runtime }} wasm uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }} - asset_path: ./${{ matrix.runtime }}_runtime.compact.wasm + asset_path: ./${{ matrix.runtime }}-${{ needs.publish-draft-release.outputs.${{ matrix.runtime }}_runtime_version}}_runtime.compact.wasm asset_name: ${{ matrix.runtime }} runtime asset_content_type: application/wasm diff --git a/scripts/github/generate_release_text.rb b/scripts/github/generate_release_text.rb index ad06a5f794ae..d7c36229fce8 100644 --- a/scripts/github/generate_release_text.rb +++ b/scripts/github/generate_release_text.rb @@ -64,11 +64,17 @@ polkadot_runtime = File.open(polkadot_path + '/runtime/polkadot/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end +puts "::set-output name=polkadot_runtime::#{polkadot_runtime}" kusama_runtime = File.open(polkadot_path + '/runtime/kusama/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end +puts "::set-output name=kusama_runtime::#{kusama_runtime}" westend_runtime = File.open(polkadot_path + '/runtime/westend/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end +puts "::set-output name=westend_runtime::#{westend_runtime}" +puts '========' puts renderer.result + +File.open('release_text.md', 'w') { |f| f.write(renderer.result) } From c6e731247ec0e166edf285f8e807c664b22f8282 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 17:00:41 +0200 Subject: [PATCH 13/16] Revert "attempt to name runtimes according to version" This reverts commit 82f7b4dc0aea995f2599293bba9f11b879f459e5. Failed experiment --- .github/workflows/publish-draft-release.yml | 12 ++---------- scripts/github/generate_release_text.rb | 6 ------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index 43d704b1489e..cdf2acf7fe43 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -23,12 +23,8 @@ jobs: runs-on: ubuntu-latest needs: get-rust-versions outputs: - release_id: ${{ steps.create-release.outputs.id }} release_url: ${{ steps.create-release.outputs.html_url }} asset_upload_url: ${{ steps.create-release.outputs.upload_url }} - polkadot_runtime_version: ${{ steps.generate-release-text.polkadot_runtime }} - kusama_runtime_version: ${{ steps.generate-release-text.kusama_runtime }} - westend_runtime_version: ${{ steps.generate-release-text.westend_runtime }} steps: - uses: actions/checkout@v2 with: @@ -39,13 +35,12 @@ jobs: with: ruby-version: 2.7 - name: Generate release text - id: generate-release-text env: RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }} RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }} run: | gem install changelogerator git toml - ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb + ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb > release_text.md - uses: actions/upload-artifact@v2 with: name: release_text @@ -126,15 +121,12 @@ jobs: - uses: actions/download-artifact@v2 with: name: ${{ matrix.runtime }}-runtime - - name: Rename asset according to runtime version - run: | - mv ./${{ matrix.runtime }}_runtime.compact-wasm ./${{ matrix.runtime }}-${{ needs.publish-draft-release.outputs.${{ matrix.runtime }}_runtime_version }}_runtime.compact.wasm - name: Upload ${{ matrix.runtime }} wasm uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }} - asset_path: ./${{ matrix.runtime }}-${{ needs.publish-draft-release.outputs.${{ matrix.runtime }}_runtime_version}}_runtime.compact.wasm + asset_path: ./${{ matrix.runtime }}_runtime.compact.wasm asset_name: ${{ matrix.runtime }} runtime asset_content_type: application/wasm diff --git a/scripts/github/generate_release_text.rb b/scripts/github/generate_release_text.rb index d7c36229fce8..ad06a5f794ae 100644 --- a/scripts/github/generate_release_text.rb +++ b/scripts/github/generate_release_text.rb @@ -64,17 +64,11 @@ polkadot_runtime = File.open(polkadot_path + '/runtime/polkadot/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end -puts "::set-output name=polkadot_runtime::#{polkadot_runtime}" kusama_runtime = File.open(polkadot_path + '/runtime/kusama/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end -puts "::set-output name=kusama_runtime::#{kusama_runtime}" westend_runtime = File.open(polkadot_path + '/runtime/westend/src/lib.rs') do |f| f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] end -puts "::set-output name=westend_runtime::#{westend_runtime}" -puts '========' puts renderer.result - -File.open('release_text.md', 'w') { |f| f.write(renderer.result) } From d18c3c2b1340921ad4658c262a81047d7aa5478e Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 17:34:31 +0200 Subject: [PATCH 14/16] name runtimes according to version #2 --- .github/workflows/publish-draft-release.yml | 15 +++++++++++++-- scripts/github/generate_release_text.rb | 13 ++++--------- scripts/github/lib.rb | 12 ++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 scripts/github/lib.rb diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index cdf2acf7fe43..6b6fe17efcc1 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -40,7 +40,7 @@ jobs: RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }} run: | gem install changelogerator git toml - ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb > release_text.md + ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb | tee release_text.md - uses: actions/upload-artifact@v2 with: name: release_text @@ -118,15 +118,26 @@ jobs: matrix: runtime: ['polkadot', 'kusama'] steps: + - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 with: name: ${{ matrix.runtime }}-runtime + - name: Set up Ruby 2.7 + uses: actions/setup-ruby@v1 + with: + ruby-version: 2.7 + - name: Set filename + id: set-filename + run: | + runtime_ver="$(ruby -e 'require "./scripts/github/lib.rb"; puts get_runtime("${{ matrix.runtime }}")')" + mv ./${{ matrix.runtime }}_runtime.compact.wasm ./${{ matrix.runtime }}_runtime-v$runtime_ver.compact.wasm + echo "::set-output name=runtime_ver::$runtime_ver" - name: Upload ${{ matrix.runtime }} wasm uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }} - asset_path: ./${{ matrix.runtime }}_runtime.compact.wasm + asset_path: ./${{ matrix.runtime }}_runtime-v${{ steps.set-filename.outputs.runtime_ver }}.compact.wasm asset_name: ${{ matrix.runtime }} runtime asset_content_type: application/wasm diff --git a/scripts/github/generate_release_text.rb b/scripts/github/generate_release_text.rb index ad06a5f794ae..f0b4b37e594a 100644 --- a/scripts/github/generate_release_text.rb +++ b/scripts/github/generate_release_text.rb @@ -4,6 +4,7 @@ require 'git' require 'erb' require 'toml' +require_relative './lib.rb' version = ENV['GITHUB_REF'] token = ENV['GITHUB_TOKEN'] @@ -61,14 +62,8 @@ rustc_stable = ENV['RUSTC_STABLE'] rustc_nightly = ENV['RUSTC_NIGHTLY'] -polkadot_runtime = File.open(polkadot_path + '/runtime/polkadot/src/lib.rs') do |f| - f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] -end -kusama_runtime = File.open(polkadot_path + '/runtime/kusama/src/lib.rs') do |f| - f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] -end -westend_runtime = File.open(polkadot_path + '/runtime/westend/src/lib.rs') do |f| - f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] -end +polkadot_runtime = get_runtime('polkadot', polkadot_path) +kusama_runtime = get_runtime('kusama', polkadot_path) +westend_runtime = get_runtime('westend', polkadot_path) puts renderer.result diff --git a/scripts/github/lib.rb b/scripts/github/lib.rb new file mode 100644 index 000000000000..35ebd3b6e7a9 --- /dev/null +++ b/scripts/github/lib.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# A collection of helper functions that might be useful for various scripts + +# Gets the runtime version for a given runtime. +# Optionally accepts a path that is the root of the project which defaults to +# the current working directory +def get_runtime(runtime, path = '.') + File.open(path + "/runtime/#{runtime}/src/lib.rs") do |f| + f.find { |l| l =~ /spec_version/ }.match(/[0-9]+/)[0] + end +end From 0aff90e4f2a58eaba43bab13cea7362c3203feee Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 19:23:11 +0200 Subject: [PATCH 15/16] fix asset path and name --- .github/workflows/publish-draft-release.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index 6b6fe17efcc1..059f7f77e757 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -126,11 +126,10 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: 2.7 - - name: Set filename - id: set-filename + - name: Get runtime version + id: get-runtime-ver run: | runtime_ver="$(ruby -e 'require "./scripts/github/lib.rb"; puts get_runtime("${{ matrix.runtime }}")')" - mv ./${{ matrix.runtime }}_runtime.compact.wasm ./${{ matrix.runtime }}_runtime-v$runtime_ver.compact.wasm echo "::set-output name=runtime_ver::$runtime_ver" - name: Upload ${{ matrix.runtime }} wasm uses: actions/upload-release-asset@v1 @@ -138,6 +137,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.publish-draft-release.outputs.asset_upload_url }} - asset_path: ./${{ matrix.runtime }}_runtime-v${{ steps.set-filename.outputs.runtime_ver }}.compact.wasm - asset_name: ${{ matrix.runtime }} runtime + asset_path: ./${{ matrix.runtime }}_runtime.compact.wasm + asset_name: ${{ matrix.runtime }}_runtime-v${{ steps.get-runtime-ver.outputs.runtime_ver }}.compact.wasm asset_content_type: application/wasm From 4440b44f0d48c28ebe15f098cf0cb9bc08222e18 Mon Sep 17 00:00:00 2001 From: Martin Pugh Date: Thu, 30 Jul 2020 20:00:27 +0200 Subject: [PATCH 16/16] build wasms first, include prop hash --- .github/workflows/publish-draft-release.yml | 98 ++++++++++----------- scripts/github/generate_release_text.rb | 16 ++++ scripts/github/polkadot_release.erb | 6 ++ 3 files changed, 71 insertions(+), 49 deletions(-) diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml index 059f7f77e757..6922c238b583 100644 --- a/.github/workflows/publish-draft-release.yml +++ b/.github/workflows/publish-draft-release.yml @@ -6,6 +6,51 @@ on: - v**.**.** jobs: + build-runtimes: + runs-on: ubuntu-latest + strategy: + matrix: + runtime: ['polkadot', 'kusama'] + container: + image: chevdor/srtool:nightly-2020-07-20 + volumes: + - ${{ github.workspace }}:/build + env: + PACKAGE: ${{ matrix.runtime }}-runtime + RUSTC_VERSION: nightly-2020-07-20 + steps: + - uses: actions/checkout@v2 + - name: Cache target dir + uses: actions/cache@v2 + with: + path: '${{ github.workspace }}/target' + key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} + restore-keys: | + srtool-target-${{ matrix.runtime }}- + srtool-target- + - name: Build ${{ matrix.runtime }} runtime + id: build-runtime + shell: bash + run: | + cd /build + pwd + ls -la + build --json | tee srtool_output.json + cat srtool_output.json + while IFS= read -r line; do + echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" + done <<< "$(jq -r 'keys[]' < srtool_output.json)" + - name: Upload ${{ matrix.runtime }} srtool json + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.runtime }}-srtool-json + path: srtool_output.json + - name: Upload ${{ matrix.runtime }} runtime + uses: actions/upload-artifact@v2 + with: + name: ${{ matrix.runtime }}-runtime + path: "${{ steps.build-runtime.outputs.wasm }}" + get-rust-versions: runs-on: ubuntu-latest container: @@ -21,7 +66,7 @@ jobs: publish-draft-release: runs-on: ubuntu-latest - needs: get-rust-versions + needs: ['get-rust-versions', 'build-runtimes'] outputs: release_url: ${{ steps.create-release.outputs.html_url }} asset_upload_url: ${{ steps.create-release.outputs.upload_url }} @@ -34,6 +79,8 @@ jobs: uses: actions/setup-ruby@v1 with: ruby-version: 2.7 + - name: Download srtool json output + uses: actions/download-artifact@v2 - name: Generate release text env: RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }} @@ -41,10 +88,6 @@ jobs: run: | gem install changelogerator git toml ruby $GITHUB_WORKSPACE/polkadot/scripts/github/generate_release_text.rb | tee release_text.md - - uses: actions/upload-artifact@v2 - with: - name: release_text - path: release_text.md - name: Create draft release id: create-release uses: actions/create-release@v1 @@ -68,52 +111,9 @@ jobs: message: "**New version of polkadot tagged**: ${{ github.ref }}
Gav: Draft release created: ${{ needs.publish-draft-release.outputs.release_url }}" server: "matrix.parity.io" - build-runtimes: - runs-on: ubuntu-latest - strategy: - matrix: - runtime: ['polkadot', 'kusama'] - container: - image: chevdor/srtool:nightly-2020-07-20 - volumes: - - ${{ github.workspace }}:/build - env: - PACKAGE: ${{ matrix.runtime }}-runtime - RUSTC_VERSION: nightly-2020-07-20 - steps: - - uses: actions/checkout@v2 - - name: Cache target dir - uses: actions/cache@v2 - with: - path: '${{ github.workspace }}/target' - key: srtool-target-${{ matrix.runtime }}-${{ github.sha }} - restore-keys: | - srtool-target-${{ matrix.runtime }}- - srtool-target- - - name: Build ${{ matrix.runtime }} runtime - id: build-runtime - shell: bash - run: | - cd /build - pwd - ls -la - build --json | tee srtool_output.json - while IFS= read -r line; do - echo "::set-output name=$line::$(jq -r ".$line" < srtool_output.json)" - done <<< "$(jq -r 'keys[]' < srtool_output.json)" - - name: Upload ${{ matrix.runtime }} runtime - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.runtime }}-runtime - path: "${{ steps.build-runtime.outputs.wasm }}" - - # Have publishing the runtimes to the release as a separate job for 2 reasons - # 1. It allows us to start building the runtimes before the draft release is created - # 2. We don't have to run it in the srtool container, thus avoiding compatibility issues - # Sadly it means we need to recreate the same matrix as the build-runtimes job publish-runtimes: runs-on: ubuntu-latest - needs: ['build-runtimes', 'publish-draft-release'] + needs: ['publish-draft-release'] strategy: matrix: runtime: ['polkadot', 'kusama'] diff --git a/scripts/github/generate_release_text.rb b/scripts/github/generate_release_text.rb index f0b4b37e594a..bb08f0820b4a 100644 --- a/scripts/github/generate_release_text.rb +++ b/scripts/github/generate_release_text.rb @@ -4,6 +4,7 @@ require 'git' require 'erb' require 'toml' +require 'json' require_relative './lib.rb' version = ENV['GITHUB_REF'] @@ -66,4 +67,19 @@ kusama_runtime = get_runtime('kusama', polkadot_path) westend_runtime = get_runtime('westend', polkadot_path) +# These json files should have been downloaded as part of the build-runtimes +# github action + +polkadot_json = JSON.parse( + File.read( + ENV['GITHUB_WORKSPACE'] + '/polkadot-srtool-json/srtool_output.json' + ) +) + +kusama_json = JSON.parse( + File.read( + ENV['GITHUB_WORKSPACE'] + '/kusama-srtool-json/srtool_output.json' + ) +) + puts renderer.result diff --git a/scripts/github/polkadot_release.erb b/scripts/github/polkadot_release.erb index f9c76d582a24..dde7165e92ef 100644 --- a/scripts/github/polkadot_release.erb +++ b/scripts/github/polkadot_release.erb @@ -11,6 +11,12 @@ This release was tested against the following versions of `rustc`. Other version - <%= rustc_stable %> - <%= rustc_nightly %> +WASM runtimes built with [srtool](https://gitlab.com/chevdor/srtool) using `<%= polkadot_json['rustc'] %>`. + +Proposal hashes: +* `polkadot_runtime-v<%= polkadot_runtime %>.compact.wasm - <%= polkadot_json['prop'] %>` +* `kusama_runtime-v<%= kusama_runtime %>.compact.wasm - <%= kusama_json['prop'] %>` + <% unless misc_changes.empty? %> ## Changes