From 35ff89aa98e0fa97a68e8a11867216392b17cfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bigna=20H=C3=A4rdi?= <73821294+haerdib@users.noreply.github.com> Date: Wed, 28 Sep 2022 13:54:32 +0200 Subject: [PATCH] [CI] add automatic draft release generation (#1022) * add test script * first try remove compiler temp change to haerdibg fix parsing fixes fix change.md Update README.md fixes (#3) remove pallet changes fix change.md fix printing changes remove docker image for now fix comments add global challenge level set min level fix gloabl challenge level update challenge sentence Update README.md (#4) fix variables fix meta.C -> meta.E fix misc - include all Update README.md (#5) fix prios Update README.md (#6) test modify readme maybe? test nr 2 test again try fix * change owner back to integritee * readd master branch * remove extra .yml file * remove outdated scripts * rename priority to challenge * fix readme.md * remove docker file --- .github/workflows/publish-draft-release.yml | 69 +++++++++++++++ scripts/changelog/.gitignore | 4 + scripts/changelog/Gemfile | 21 +++++ scripts/changelog/Gemfile.lock | 79 +++++++++++++++++ scripts/changelog/README.md | 3 + scripts/changelog/bin/changelog | 84 +++++++++++++++++++ scripts/changelog/digests/.gitignore | 1 + scripts/changelog/digests/.gitkeep | 0 scripts/changelog/lib/changelog.rb | 38 +++++++++ .../changelog/templates/_free_notes.md.tera | 10 +++ .../templates/challenge_level.md.tera | 37 ++++++++ scripts/changelog/templates/change.md.tera | 42 ++++++++++ scripts/changelog/templates/changes.md.tera | 24 ++++++ .../templates/changes_applibs.md.tera | 17 ++++ .../templates/changes_client.md.tera | 17 ++++ .../changelog/templates/changes_core.md.tera | 17 ++++ .../changelog/templates/changes_evm.md.tera | 17 ++++ .../changelog/templates/changes_misc.md.tera | 37 ++++++++ .../templates/changes_offchain.md.tera | 17 ++++ .../templates/changes_sidechain.md.tera | 17 ++++ .../templates/changes_teeracle.md.tera | 17 ++++ scripts/changelog/templates/debug.md.tera | 8 ++ .../templates/global_challenge_level.md.tera | 26 ++++++ .../templates/global_priority.md.tera | 27 ++++++ .../changelog/templates/high_priority.md.tera | 38 +++++++++ .../changelog/templates/pre_release.md.tera | 11 +++ scripts/changelog/templates/template.md.tera | 33 ++++++++ 27 files changed, 711 insertions(+) create mode 100644 .github/workflows/publish-draft-release.yml create mode 100644 scripts/changelog/.gitignore create mode 100644 scripts/changelog/Gemfile create mode 100644 scripts/changelog/Gemfile.lock create mode 100644 scripts/changelog/README.md create mode 100755 scripts/changelog/bin/changelog create mode 100644 scripts/changelog/digests/.gitignore create mode 100644 scripts/changelog/digests/.gitkeep create mode 100644 scripts/changelog/lib/changelog.rb create mode 100644 scripts/changelog/templates/_free_notes.md.tera create mode 100644 scripts/changelog/templates/challenge_level.md.tera create mode 100644 scripts/changelog/templates/change.md.tera create mode 100644 scripts/changelog/templates/changes.md.tera create mode 100644 scripts/changelog/templates/changes_applibs.md.tera create mode 100644 scripts/changelog/templates/changes_client.md.tera create mode 100644 scripts/changelog/templates/changes_core.md.tera create mode 100644 scripts/changelog/templates/changes_evm.md.tera create mode 100644 scripts/changelog/templates/changes_misc.md.tera create mode 100644 scripts/changelog/templates/changes_offchain.md.tera create mode 100644 scripts/changelog/templates/changes_sidechain.md.tera create mode 100644 scripts/changelog/templates/changes_teeracle.md.tera create mode 100644 scripts/changelog/templates/debug.md.tera create mode 100644 scripts/changelog/templates/global_challenge_level.md.tera create mode 100644 scripts/changelog/templates/global_priority.md.tera create mode 100644 scripts/changelog/templates/high_priority.md.tera create mode 100644 scripts/changelog/templates/pre_release.md.tera create mode 100644 scripts/changelog/templates/template.md.tera diff --git a/.github/workflows/publish-draft-release.yml b/.github/workflows/publish-draft-release.yml new file mode 100644 index 00000000..11ac50ea --- /dev/null +++ b/.github/workflows/publish-draft-release.yml @@ -0,0 +1,69 @@ +name: Release - Publish draft + +on: + push: + tags: + # Catches v1.2.3 and v1.2.3-rc1 + - v[0-9]+.[0-9]+.[0-9]+* + +jobs: + publish-draft-release: + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + fetch-depth: 0 + path: worker + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0.0 + + - name: Download srtool json output + uses: actions/download-artifact@v3 + + - name: Prepare tooling + run: | + cd worker/scripts/changelog + gem install bundler changelogerator:0.9.1 + 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: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DEBUG: 1 + PRE_RELEASE: ${{ github.event.inputs.pre_release }} + run: | + find ${{env.GITHUB_WORKSPACE}} -type f -name "*_srtool_output.json" + + cd worker/scripts/changelog + + ./bin/changelog ${GITHUB_REF} + ls -al release-notes.md + ls -al context.json + + - name: Archive artifact context.json + uses: actions/upload-artifact@v3 + with: + name: release-notes-context + path: | + worker/scripts/changelog/context.json + **/*_srtool_output.json + + - name: Create draft release + id: create-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: SDK ${{ github.ref }} + body_path: ./worker/scripts/changelog/release-notes.md + draft: true diff --git a/scripts/changelog/.gitignore b/scripts/changelog/.gitignore new file mode 100644 index 00000000..4fbcc523 --- /dev/null +++ b/scripts/changelog/.gitignore @@ -0,0 +1,4 @@ +changelog.md +*.json +release*.md +.env diff --git a/scripts/changelog/Gemfile b/scripts/changelog/Gemfile new file mode 100644 index 00000000..f2d7c3bd --- /dev/null +++ b/scripts/changelog/Gemfile @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } + +gem 'octokit', '~> 4' + +gem 'git_diff_parser', '~> 3' + +gem 'toml', '~> 0.3.0' + +gem 'rake', group: :dev + +gem 'optparse', '~> 0.1.1' + +gem 'logger', '~> 1.4' + +gem 'test-unit', group: :dev + +gem 'rubocop', group: :dev, require: false diff --git a/scripts/changelog/Gemfile.lock b/scripts/changelog/Gemfile.lock new file mode 100644 index 00000000..855d7f91 --- /dev/null +++ b/scripts/changelog/Gemfile.lock @@ -0,0 +1,79 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + ast (2.4.2) + faraday (1.8.0) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + multipart-post (>= 1.2, < 3) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + git_diff_parser (3.2.0) + logger (1.4.4) + multipart-post (2.1.1) + octokit (4.21.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + optparse (0.1.1) + parallel (1.21.0) + parser (3.0.2.0) + ast (~> 2.4.1) + parslet (2.0.0) + power_assert (2.0.1) + public_suffix (4.0.6) + rainbow (3.0.0) + rake (13.0.6) + regexp_parser (2.1.1) + rexml (3.2.5) + rubocop (1.23.0) + parallel (~> 1.10) + parser (>= 3.0.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.12.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.13.0) + parser (>= 3.0.1.1) + ruby-progressbar (1.11.0) + ruby2_keywords (0.0.5) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + test-unit (3.5.1) + power_assert + toml (0.3.0) + parslet (>= 1.8.0, < 3.0.0) + unicode-display_width (2.1.0) + +PLATFORMS + x86_64-darwin-20 + +DEPENDENCIES + git_diff_parser (~> 3) + logger (~> 1.4) + octokit (~> 4) + optparse (~> 0.1.1) + rake + rubocop + test-unit + toml (~> 0.3.0) + +BUNDLED WITH + 2.2.22 diff --git a/scripts/changelog/README.md b/scripts/changelog/README.md new file mode 100644 index 00000000..4776277e --- /dev/null +++ b/scripts/changelog/README.md @@ -0,0 +1,3 @@ +## License + +Everything in this folder is GPL 3.0 licensed. The original has been authored by parity and was taken from here: https://github.com/paritytech/polkadot/tree/master/scripts/ci/changelog. \ No newline at end of file diff --git a/scripts/changelog/bin/changelog b/scripts/changelog/bin/changelog new file mode 100755 index 00000000..15b17d61 --- /dev/null +++ b/scripts/changelog/bin/changelog @@ -0,0 +1,84 @@ +#!/usr/bin/env ruby + +# frozen_string_literal: true + +# call for instance as: +# ./bin/changelog [] [] +# for instance, for the release notes of v1.2.3: +# ./bin/changelog v1.2.3 +# or +# ./bin/changelog v1.2.3 v1.2.2 +# +# You may set the ENV NO_CACHE to force fetching from Github +# You should also ensure you set the ENV: GITHUB_TOKEN + +require_relative '../lib/changelog' +require 'logger' + +logger = Logger.new($stdout) +logger.level = Logger::DEBUG +logger.debug('Starting') + +owner = 'integritee-network' +repo = 'worker' + +gh_worker = SubRef.new(format('%s/%s', { owner: owner, repo: repo })) +last_release_ref = gh_worker.get_last_ref() + +worker_ref2 = ARGV[0] || 'HEAD' +worker_ref1 = ARGV[1] || last_release_ref + +output = ARGV[2] || 'release-notes.md' + +ENV['REF1'] = worker_ref1 +ENV['REF2'] = worker_ref2 + +pallets_ref1 = gh_worker.get_dependency_reference(worker_ref1, 'pallet-teerex') +pallets_ref2 = gh_worker.get_dependency_reference(worker_ref2, 'pallet-teerex') + +logger.debug("Worker from: #{worker_ref1}") +logger.debug("Worker to: #{worker_ref2}") + +logger.debug("Pallets from: #{pallets_ref1}") +logger.debug("Pallets to: #{pallets_ref2}") + +pallets_data = 'pallets.json' +worker_data = 'worker.json' + +logger.debug("Using PALLETS: #{pallets_data}") +logger.debug("Using WORKER: #{worker_data}") + +logger.warn('NO_CACHE set') if ENV['NO_CACHE'] + +if ENV['NO_CACHE'] || !File.file?(worker_data) + logger.debug(format('Fetching data for Worker into %s', worker_data)) + cmd = format('changelogerator %s/%s -f %s -t %s > %s', + { owner: owner, repo: 'worker', from: worker_ref1, to: worker_ref2, output: worker_data }) + system(cmd) +else + logger.debug("Re-using:#{worker_data}") +end + +if ENV['NO_CACHE'] || !File.file?(pallets_data) + logger.debug(format('Fetching data for Pallets into %s', pallets_data)) + cmd = format('changelogerator %s/%s -f %s -t %s > %s', + { owner: owner, repo: 'pallets', from: pallets_ref1, to: pallets_ref2, output: pallets_data }) + system(cmd) +else + logger.debug("Re-using:#{pallets_data}") +end + +# Here we compose all the pieces together into one +# single big json file. +cmd = format('jq \ + --slurpfile pallets %s \ + --slurpfile worker %s \ + -n \'{ + pallets: $pallets[0], + worker: $worker[0], + }\' > context.json', pallets_data, worker_data) +system(cmd) + +cmd = format('tera --env --env-key env --include-path templates \ + --template templates/template.md.tera context.json > %s', output) +system(cmd) diff --git a/scripts/changelog/digests/.gitignore b/scripts/changelog/digests/.gitignore new file mode 100644 index 00000000..a6c57f5f --- /dev/null +++ b/scripts/changelog/digests/.gitignore @@ -0,0 +1 @@ +*.json diff --git a/scripts/changelog/digests/.gitkeep b/scripts/changelog/digests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/scripts/changelog/lib/changelog.rb b/scripts/changelog/lib/changelog.rb new file mode 100644 index 00000000..d7cf92e7 --- /dev/null +++ b/scripts/changelog/lib/changelog.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +# A Class to find Substrate references +class SubRef + require 'octokit' + require 'toml' + + attr_reader :client, :repository + + def initialize(github_repo) + @client = Octokit::Client.new( + access_token: ENV['GITHUB_TOKEN'] + ) + @repository = @client.repository(github_repo) + end + + # This function checks the Cargo.lock of a given + # Rust project, for a given package, and fetches + # the dependency git ref. + def get_dependency_reference(ref, package) + cargo = TOML::Parser.new( + Base64.decode64( + @client.contents( + @repository.full_name, + path: 'Cargo.lock', + query: { ref: ref.to_s } + ).content + ) + ).parsed + cargo['package'].find { |p| p['name'] == package }['source'].split('#').last + end + + # Get the git ref of the last release for the repo. + # repo is given in the form integritee-network/worker + def get_last_ref() + 'refs/tags/' + @client.latest_release(@repository.full_name).tag_name + end +end diff --git a/scripts/changelog/templates/_free_notes.md.tera b/scripts/changelog/templates/_free_notes.md.tera new file mode 100644 index 00000000..c4a841a9 --- /dev/null +++ b/scripts/changelog/templates/_free_notes.md.tera @@ -0,0 +1,10 @@ + +{# This file uses the Markdown format with additional templating such as this comment. -#} +{# Such a comment will not show up in the rendered release notes. -#} +{# The content of this file (if any) will be inserted at the top of the release notes -#} +{# and generated for each new release candidate. -#} +{# Ensure you leave an empty line at both top and bottom of this file. -#} + + + + diff --git a/scripts/changelog/templates/challenge_level.md.tera b/scripts/changelog/templates/challenge_level.md.tera new file mode 100644 index 00000000..c4a8934f --- /dev/null +++ b/scripts/changelog/templates/challenge_level.md.tera @@ -0,0 +1,37 @@ +{%- import "change.md.tera" as m_c -%} + +{# This macro convert a merge challenge level into readable output #} +{%- macro challenge_level(e, changes) -%} + +{%- if e >= 5 -%} + {%- set level = "‼️ Breaking Changes" -%} + {%- set text = "This release contains **breaking changes**. Be sure to upgrade the affected interfaces." -%} +{%- elif e >= 3 -%} + {%- set level = "❗️ Attention" -%} + {%- set text = "This release contains some non-trivial updates. Be mindful when upgrading." -%} +{%- else -%} + {%- set level = "Trivial" -%} + {%- set text = "This release contains relatively small updates." -%} +{%- endif %} + + + + +{%- if level %} +{{level}}: {{text}} + +{% if e >= 3 %} +The changes motivating this challenge level are: +{% for pr in changes | sort(attribute="merged_at") -%} + {%- if pr.meta.E -%} + {%- if pr.meta.E.value == e %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {%- endif -%} +{%- endfor -%} +{%- else -%} + +{%- endif -%} +{%- endif -%} + +{%- endmacro level -%} diff --git a/scripts/changelog/templates/change.md.tera b/scripts/changelog/templates/change.md.tera new file mode 100644 index 00000000..25cc04ed --- /dev/null +++ b/scripts/changelog/templates/change.md.tera @@ -0,0 +1,42 @@ +{# This macro shows ONE change #} +{%- macro change(c, cml="[C]", pal="[P]", wor="[W]") -%} + +{%- if c.meta.C and c.meta.C.value >= 7 -%} +{%- set prio = " ‼️ HIGH" -%} +{%- elif c.meta.C and c.meta.C.value >= 3 -%} +{%- set prio = " ❗️ Medium" -%} +{%- elif c.meta.C and c.meta.C.value < 3 -%} +{%- set prio = " Low" -%} +{%- else -%} +{%- set prio = "" -%} +{%- endif -%} + + +{%- if c.html_url is containing("worker") -%} +{%- set repo = wor -%} +{%- elif c.html_url is containing("pallets") -%} +{%- set repo = pal -%} +{%- else -%} +{%- set repo = " " -%} +{%- endif -%} + +{# For now don't show pallets or worker #} +{%- set repo = " " -%} + +{%- if c.meta.E and c.meta.E.value >= 7 -%} +{%- set challenge = " 💥 breaking changes " -%} +{%- elif c.meta.E and c.meta.E.value == 6 -%} +{%- set challenge = " ⚡ breaks parentchain interface " -%} +{%- elif c.meta.E and c.meta.E.value == 5 -%} +{%- set challenge = " 🔥 breaks public rpc api " -%} +{%- elif c.meta.E and c.meta.E.value >= 3 -%} +{%- set challenge = " 📢 attention required " -%} +{%- elif c.meta.E and c.meta.E.value < 3 -%} +{%- set challenge = " ✅ easy merge " -%} +{%- else -%} +{%- set challenge = "" -%} +{%- endif -%} + + +{{- repo }} {{ challenge }}[`#{{c.number}}`]({{c.html_url}}) {{- prio }} - {{ c.title | capitalize | truncate(length=120, end="…") }} +{%- endmacro change -%} \ No newline at end of file diff --git a/scripts/changelog/templates/changes.md.tera b/scripts/changelog/templates/changes.md.tera new file mode 100644 index 00000000..571f2f4c --- /dev/null +++ b/scripts/changelog/templates/changes.md.tera @@ -0,0 +1,24 @@ +{# This include generates the section showing the changes #} +## Changes + +{# for not now printed until pallet is actually included #} +{# ### Legend #} + +{# - {{ WOR }} Worker #} +{# - {{ PAL }} Pallet #} + +{% include "changes_applibs.md.tera" %} + +{% include "changes_client.md.tera" %} + +{% include "changes_core.md.tera" %} + +{% include "changes_evm.md.tera" %} + +{% include "changes_offchain.md.tera" %} + +{% include "changes_sidechain.md.tera" %} + +{% include "changes_teeracle.md.tera" %} + +{% include "changes_misc.md.tera" %} diff --git a/scripts/changelog/templates/changes_applibs.md.tera b/scripts/changelog/templates/changes_applibs.md.tera new file mode 100644 index 00000000..db393f76 --- /dev/null +++ b/scripts/changelog/templates/changes_applibs.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### App-Libs + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 2 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_client.md.tera b/scripts/changelog/templates/changes_client.md.tera new file mode 100644 index 00000000..5e968618 --- /dev/null +++ b/scripts/changelog/templates/changes_client.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### Client + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 1 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_core.md.tera b/scripts/changelog/templates/changes_core.md.tera new file mode 100644 index 00000000..f88447b9 --- /dev/null +++ b/scripts/changelog/templates/changes_core.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### Core + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 0 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_evm.md.tera b/scripts/changelog/templates/changes_evm.md.tera new file mode 100644 index 00000000..92747435 --- /dev/null +++ b/scripts/changelog/templates/changes_evm.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### EVM Feature + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 6 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_misc.md.tera b/scripts/changelog/templates/changes_misc.md.tera new file mode 100644 index 00000000..1beb2efd --- /dev/null +++ b/scripts/changelog/templates/changes_misc.md.tera @@ -0,0 +1,37 @@ +{%- import "change.md.tera" as m_c -%} + +{%- set_global misc_count = 0 -%} +{#- First pass to count #} +{%- for pr in changes -%} + {%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 -%} + {#- We skip silent ones -#} + {%- else -%} +{%- set_global misc_count = misc_count + 1 -%} + {% endif -%} + {% endif -%} +{% endfor -%} + +### Misc + +{% if misc_count > 10 %} +There are other misc. changes. You can expand the list below to view them all. +
Other misc. changes +{% endif -%} + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + {%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + {%- if pr.meta.B.value >= 1 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} + +{% if misc_count > 10 %} +
+{% endif -%} diff --git a/scripts/changelog/templates/changes_offchain.md.tera b/scripts/changelog/templates/changes_offchain.md.tera new file mode 100644 index 00000000..d2987520 --- /dev/null +++ b/scripts/changelog/templates/changes_offchain.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### Offchain + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 4 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_sidechain.md.tera b/scripts/changelog/templates/changes_sidechain.md.tera new file mode 100644 index 00000000..f953cfbc --- /dev/null +++ b/scripts/changelog/templates/changes_sidechain.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### Sidechain + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 3 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/changes_teeracle.md.tera b/scripts/changelog/templates/changes_teeracle.md.tera new file mode 100644 index 00000000..6e94e88b --- /dev/null +++ b/scripts/changelog/templates/changes_teeracle.md.tera @@ -0,0 +1,17 @@ +{% import "change.md.tera" as m_c -%} +### Teeracle + +{#- The changes are sorted by merge date #} +{%- for pr in changes | sort(attribute="merged_at") %} + +{%- if pr.meta.B %} + {%- if pr.meta.B.value == 0 %} + {#- We skip silent ones -#} + {%- else -%} + + {%- if pr.meta.A.value == 5 %} +- {{ m_c::change(c=pr) }} + {%- endif -%} + {% endif -%} + {% endif -%} +{% endfor %} diff --git a/scripts/changelog/templates/debug.md.tera b/scripts/changelog/templates/debug.md.tera new file mode 100644 index 00000000..41f3702d --- /dev/null +++ b/scripts/changelog/templates/debug.md.tera @@ -0,0 +1,8 @@ +{%- set to_ignore = changes | filter(attribute="meta.B.value", value=0) %} + + diff --git a/scripts/changelog/templates/global_challenge_level.md.tera b/scripts/changelog/templates/global_challenge_level.md.tera new file mode 100644 index 00000000..d2108dce --- /dev/null +++ b/scripts/changelog/templates/global_challenge_level.md.tera @@ -0,0 +1,26 @@ +{% import "challenge_level.md.tera" as m_p -%} +## Upgrade Challenge Level + +{%- set worker_prio = 0 -%} +{%- set pallet_prio = 0 -%} + +{# We fetch the various levels #} +{%- if worker.meta.E -%} +{%- set worker_level = worker.meta.E.max -%} +{%- else -%} +{%- set worker_level = 0 -%} +{%- endif -%} +{%- if pallet.meta.E -%} +{%- set pallet_level = pallet.meta.E.max -%} +{%- else -%} +{%- set pallet_level = 0 -%} +{%- endif -%} + +{# We compute the global level #} +{%- set global_level = worker_level -%} +{%- if pallet_level > global_level -%} +{%- set global_level = pallet_level -%} +{%- endif -%} + +{#- We show the result #} +{{ m_p::challenge_level(e=global_level, changes=changes) }} diff --git a/scripts/changelog/templates/global_priority.md.tera b/scripts/changelog/templates/global_priority.md.tera new file mode 100644 index 00000000..87a6d52a --- /dev/null +++ b/scripts/changelog/templates/global_priority.md.tera @@ -0,0 +1,27 @@ +{% import "high_priority.md.tera" as m_p -%} +## Upgrade Priority + +{%- set worker_prio = 0 -%} +{%- set pallet_prio = 0 -%} + +{# We fetch the various priorities #} +{%- if worker.meta.C -%} +{%- set worker_prio = worker.meta.C.max -%} +{%- else -%} +{%- set worker_prio = 0 -%} +{%- endif -%} +{%- if pallet.meta.C -%} +{%- set pallet_prio = pallet.meta.C.max -%} +{%- else -%} +{%- set pallet_prio = 0 -%} +{%- endif -%} + +{# We compute the global priority #} +{%- set global_prio = worker_prio -%} +{%- if pallet_prio > global_prio -%} +{%- set global_prio = pallet_prio -%} +{%- endif -%} + + +{#- We show the result #} +{{ m_p::high_priority(p=global_prio, changes=changes) }} diff --git a/scripts/changelog/templates/high_priority.md.tera b/scripts/changelog/templates/high_priority.md.tera new file mode 100644 index 00000000..117d335e --- /dev/null +++ b/scripts/changelog/templates/high_priority.md.tera @@ -0,0 +1,38 @@ +{%- import "change.md.tera" as m_c -%} + +{# This macro convert a priority level into readable output #} +{%- macro high_priority(p, changes) -%} + +{%- if p >= 7 -%} + {%- set prio = "‼️ HIGH" -%} + {%- set text = "This is a **high priority** release and you must upgrade as as soon as possible." -%} +{%- elif p >= 3 -%} + {%- set prio = "❗️ Medium" -%} + {%- set text = "This is a medium priority release and you should upgrade in a timely manner." -%} +{%- else -%} + {%- set prio = "Low" -%} + {%- set text = "This is a low priority release and you may upgrade at your convenience." -%} +{%- endif %} + + + +{%- if prio %} +{{prio}}: {{text}} + +{% if p >= 3 %} +The changes motivating this priority level are: +{% for pr in changes | sort(attribute="merged_at") -%} + {%- if pr.meta.C -%} + {%- if pr.meta.C.value == p %} +- {{ m_c::change(c=pr) }} +{%- if pr.meta.B and pr.meta.B.value == 7 %} (RUNTIME) +{% endif %} + {%- endif -%} + {%- endif -%} +{%- endfor -%} +{%- else -%} + +{%- endif -%} +{%- endif -%} + +{%- endmacro priority -%} diff --git a/scripts/changelog/templates/pre_release.md.tera b/scripts/changelog/templates/pre_release.md.tera new file mode 100644 index 00000000..7d4ad42d --- /dev/null +++ b/scripts/changelog/templates/pre_release.md.tera @@ -0,0 +1,11 @@ +{%- if env.PRE_RELEASE == "true" -%} +
⚠️ This is a pre-release + +**Release candidates** are **pre-releases** and may not be final. +Although they are reasonably tested, there may be additional changes or issues +before an official release is tagged. Use at your own discretion, and consider +only using final releases on critical production infrastructure. +
+{% else -%} + +{%- endif %} diff --git a/scripts/changelog/templates/template.md.tera b/scripts/changelog/templates/template.md.tera new file mode 100644 index 00000000..2c61f3d5 --- /dev/null +++ b/scripts/changelog/templates/template.md.tera @@ -0,0 +1,33 @@ +{# This is the entry point of the template -#} + +{% include "pre_release.md.tera" -%} + +{% if env.PRE_RELEASE == "true" -%} +This pre-release contains the changes from `{{ env.REF1 | replace(from="refs/tags/", to="") }}` to `{{ env.REF2 | +replace(from="refs/tags/", to="") }}`. +{%- else -%} +This release contains the changes from `{{ env.REF1 | replace(from="refs/tags/", to="") }}` to `{{ env.REF2 | +replace(from="refs/tags/", to="") }}`. +{% endif -%} + +{# -- For now no pallet changes included -- #} +{# {%- set changes = worker.changes | concat(with=pallet.changes) -%}##} +{%- set changes = worker.changes -%} +{%- include "debug.md.tera" -%} + +{%- set CML = "[C]" -%} +{%- set WOR = "[W]" -%} +{%- set PAL = "[P]" -%} + +{# -- Manual free notes section -- #} +{% include "_free_notes.md.tera" -%} + +{# -- Important automatic section -- #} +{% include "global_priority.md.tera" -%} + +{# -- Important automatic section -- #} +{% include "global_challenge_level.md.tera" -%} + +{# --------------------------------- #} + +{% include "changes.md.tera" -%}