Add changelog generation (#761)

* WIP Release notes generation and templates

* WIP Add new sections to the template

* WIP renaming and wip

* Fix runtime template

* Add doc, NO_CACHE and tweaking of the templates

* Renaming cl into cumulus to make room for the polkadot and substrate

* Fetch data from Substrate and Polkadot

* WIP convert bash script to ruby

* Convert to Ruby

* Fix host function delection

* Extract priority to a macro

* Fix misc changes

* Draft release workflow

* Fix runtime dir

* Add ENV to ignore runtimes

* Install tooling separately

* WIP troubleshooting - remove sudo

* Minor formatting fixes

* Fix workflow

* Add missing dep

* Linting

* Fix changelog script

* Add missing tera install

* Use absolute paths

* Fix path + cleanup

* Fix changelog generation

* Add missing pre-release ENV

* Fix rust version ENV

* Fix release notes path

* Fix output

* Fix runtime_dir for cumulus

* Fix ENV substitutions

* Fix styling

* Debugging

* Styling

* Fix call to fetch the runtime version

* Cleanup and doc

* Delete sample .env

* Update scripts/changelog/templates/change.md.tera

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Change XCM emoji marker for a ✉️

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Chevdor
2021-11-19 17:30:05 +01:00
committed by GitHub
parent 4a559a5872
commit ce2403808b
28 changed files with 897 additions and 15 deletions
+207
View File
@@ -0,0 +1,207 @@
name: Publish draft release
on:
workflow_dispatch:
inputs:
ref1:
description: The 'from' tag to use for the diff
default: statemine-v5.0.0
required: true
ref2:
description: The 'to' tag to use for the diff
default: HEAD
required: true
pre_release:
description: For pre-releases
default: "true"
required: true
jobs:
get-rust-versions:
runs-on: ubuntu-latest
container:
image: paritytech/ci-linux:production
outputs:
rustc-stable: ${{ steps.get-rust-versions.outputs.stable }}
rustc-nightly: ${{ steps.get-rust-versions.outputs.nightly }}
steps:
- id: get-rust-versions
run: |
echo "::set-output name=stable::$(rustc +stable --version)"
echo "::set-output name=nightly::$(rustc +nightly --version)"
build-runtimes:
runs-on: ubuntu-latest
strategy:
matrix:
runtime: ["shell", "statemine", "statemint", "westmint", "rococo"]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache target dir
uses: actions/cache@v2
with:
path: "${{ github.workspace }}/runtime/${{ matrix.runtime }}/target"
key: srtool-target-${{ matrix.runtime }}-${{ github.sha }}
restore-keys: |
srtool-target-${{ matrix.runtime }}-
srtool-target-
- name: Build ${{ matrix.runtime }} runtime
id: srtool_build
uses: chevdor/srtool-actions@v0.3.0
with:
image: paritytech/srtool
chain: ${{ matrix.runtime }}
runtime_dir: polkadot-parachains/${{ matrix.runtime }}
- name: Store srtool digest to disk
run: |
echo '${{ steps.srtool_build.outputs.json }}' | \
jq > ${{ matrix.runtime }}_srtool_output.json
- name: Upload ${{ matrix.runtime }} srtool json
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.runtime }}-srtool-json
path: ${{ matrix.runtime }}_srtool_output.json
- name: Upload ${{ matrix.runtime }} runtime
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.runtime }}-runtime
path: |
${{ steps.srtool_build.outputs.wasm_compressed }}
publish-draft-release:
runs-on: ubuntu-latest
needs: ["get-rust-versions", "build-runtimes"]
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@v2
with:
fetch-depth: 0
path: cumulus
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
- name: Download srtool json output
uses: actions/download-artifact@v2
- name: Prepare tooling
run: |
cd cumulus/scripts/changelog
gem install bundler changelogerator
bundle install
changelogerator --help
URL=https://github.com/chevdor/tera-cli/releases/download/v0.2.1/tera-cli_linux_amd64.deb
wget $URL -O tera.deb
sudo dpkg -i tera.deb
tera --version
- name: Generate release notes
env:
RUSTC_STABLE: ${{ needs.get-rust-versions.outputs.rustc-stable }}
RUSTC_NIGHTLY: ${{ needs.get-rust-versions.outputs.rustc-nightly }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NO_CACHE: 1
DEBUG: 1
SHELL_DIGEST: ${{ github.workspace}}/shell-srtool-json/shell_srtool_output.json
WESTMINT_DIGEST: ${{ github.workspace}}/westmint-srtool-json/westmint_srtool_output.json
STATEMINE_DIGEST: ${{ github.workspace}}/statemine-srtool-json/statemine_srtool_output.json
STATEMINT_DIGEST: ${{ github.workspace}}/statemint-srtool-json/statemint_srtool_output.json
ROCOCO_DIGEST: ${{ github.workspace}}/rococo-srtool-json/rococo_srtool_output.json
REF1: ${{ github.event.inputs.ref1 }}
REF2: ${{ github.event.inputs.ref2 }}
PRE_RELEASE: ${{ github.event.inputs.pre_release }}
HIDE_SRTOOL_ROCOCO: false
HIDE_SRTOOL_SHELL: false
run: |
find ${{env.GITHUB_WORKSPACE}} -type f -name "*_srtool_output.json"
ls -al $SHELL_DIGEST
ls -al $WESTMINT_DIGEST
ls -al $STATEMINE_DIGEST
ls -al $STATEMINT_DIGEST
ls -al $ROCOCO_DIGEST
echo "The diff will be computed from $REF1 to $REF2"
cd cumulus/scripts/changelog
./bin/changelog $REF1 $REF2 release-notes.md
ls -al release-notes.md
- name: Create draft release
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: parachains-${{ github.ref }}
release_name: Parachains ${{ github.ref }}
body_path: ./cumulus/scripts/changelog/release-notes.md
draft: true
publish-runtimes:
runs-on: ubuntu-latest
needs: ["publish-draft-release"]
env:
RUNTIME_DIR: polkadot-parachains
strategy:
matrix:
runtime: ["shell", "statemine", "statemint", "westmint", "rococo"]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.0
- name: Get runtime version for ${{ matrix.runtime }}
id: get-runtime-ver
run: |
echo "require './scripts/github/runtime-version.rb'" > script.rb
echo "puts get_runtime(runtime: \"${{ matrix.runtime }}\", runtime_dir: \"$RUNTIME_DIR\")" >> script.rb
echo "Current folder: $PWD"
ls "$RUNTIME_DIR/${{ matrix.runtime }}"
runtime_ver=$(ruby script.rb)
echo "Found version: >$runtime_ver<"
echo "::set-output name=runtime_ver::$runtime_ver"
- name: Upload compressed ${{ 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/${{ matrix.runtime }}_runtime.compact.compressed.wasm"
asset_name: ${{ matrix.runtime }}_runtime-v${{ steps.get-runtime-ver.outputs.runtime_ver }}.compact.compressed.wasm
asset_content_type: application/wasm
post_to_matrix:
runs-on: ubuntu-latest
needs: publish-draft-release
steps:
- name: Internal polkadot channel
uses: s3krit/matrix-message-action@v0.0.3
with:
room_id: ${{ secrets.INTERNAL_POLKADOT_MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
message: |
**New draft for ${{ github.repository }}**: ${{ github.ref }}<br/>
Draft release created: [draft](${{ needs.publish-draft-release.outputs.release_url }})
NOTE: The link above will no longer be valid if the draft is edited. You can then use the following link:
[${{ github.server_url }}/${{ github.repository }}/releases](${{ github.server_url }}/${{ github.repository }}/releases)
server: "matrix.parity.io"