mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 16:57:58 +00:00
[CI] Refactor publish_draft_release.sh (#1289)
* Refactor publish_draft_release.sh * Switch to using arrays for storing labelled changes * Combine changes for Polkadot and Substrate * Change sanitised_git_logs in `lib.sh` to drop `*`s at the start * Only look for priorities of medium or above (presence of one or more C1 label is enforeced by check-labels anyway, saves us some API calls) * Ensure priorities >C1-low aren't labelled B0-silent
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
#shellcheck source=lib.sh
|
||||
source "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/lib.sh"
|
||||
|
||||
repo='paritytech/polkadot'
|
||||
|
||||
ensure_labels() {
|
||||
for label in "$@"; do
|
||||
if has_label 'paritytech/polkadot' "$CI_COMMIT_BRANCH" "$label"; then
|
||||
if has_label "$repo" "$CI_COMMIT_BRANCH" "$label"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@@ -19,7 +21,7 @@ releasenotes_labels=(
|
||||
'B2-runtimenoteworthy'
|
||||
)
|
||||
|
||||
criticality_labels=(
|
||||
priority_labels=(
|
||||
'C1-low'
|
||||
'C3-medium'
|
||||
'C7-high'
|
||||
@@ -34,11 +36,19 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[+] Checking release criticality (C) labels for $CI_COMMIT_BRANCH"
|
||||
if ensure_labels "${criticality_labels[@]}"; then
|
||||
echo "[+] Release criticality label detected. All is well."
|
||||
echo "[+] Checking release priority (C) labels for $CI_COMMIT_BRANCH"
|
||||
if ensure_labels "${priority_labels[@]}"; then
|
||||
echo "[+] Release priority label detected. All is well."
|
||||
else
|
||||
echo "[!] Release criticality label not detected. Please add one of: ${criticality_labels[*]}"
|
||||
echo "[!] Release priority label not detected. Please add one of: ${priority_labels[*]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If the priority is anything other than C1-low, we *must not* have a B0-silent
|
||||
# label
|
||||
if has_label "$repo" "$CI_COMMIT_BRANCH" 'B0-silent' &&
|
||||
! has_label "$repo" "$CI_COMMIT_BRANCH" 'C1-low' ; then
|
||||
echo "[!] Changes with a priority higher than C1-low *MUST* have a B- label that is not B0-Silent"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ sanitised_git_logs(){
|
||||
# Only find messages referencing a PR
|
||||
grep -E '\(#[0-9]+\)' |
|
||||
# Strip any asterisks
|
||||
sed 's/^* //g' |
|
||||
# And add them all back
|
||||
sed 's/^/* /g'
|
||||
sed 's/^* //g'
|
||||
}
|
||||
|
||||
# Checks whether a tag on github has been verified
|
||||
|
||||
@@ -50,7 +50,9 @@ This release was built with the following versions of \`rustc\`. Other versions
|
||||
- $nightly_rustc
|
||||
"
|
||||
|
||||
runtime_changes=""
|
||||
declare -a misc_changes
|
||||
declare -a runtime_changes
|
||||
declare -a client_changes
|
||||
|
||||
# Following variables are for tracking the priority of the release (i.e.,
|
||||
# how important it is for the user to upgrade).
|
||||
@@ -72,7 +74,9 @@ declare -A priority_descriptions=(
|
||||
['C9-critical']="Upgrade priority: ❗❗ **URGENT** ❗❗ PLEASE UPGRADE IMMEDIATELY"
|
||||
)
|
||||
|
||||
max_label=-1
|
||||
# We don't actually take any action on C1-low, so we can start at medium
|
||||
# But set C1-low as the default
|
||||
max_label=1
|
||||
priority="${priority_descriptions['C1-low']}"
|
||||
declare -a priority_changes
|
||||
|
||||
@@ -93,6 +97,7 @@ while IFS= read -r line; do
|
||||
prev_label="$max_label"
|
||||
max_label="$index"
|
||||
priority="${priority_descriptions[$cur_label]}"
|
||||
|
||||
# If it's not an increase in priority, we just append the PR to the list
|
||||
if [ "$prev_label" == "$max_label" ]; then
|
||||
priority_changes+=("${line/\* /}")
|
||||
@@ -101,6 +106,12 @@ while IFS= read -r line; do
|
||||
if [ "$prev_label" != "$max_label" ]; then
|
||||
priority_changes=("${line/\* /}")
|
||||
fi
|
||||
|
||||
# Append priority to change
|
||||
# Skip first 3 chars
|
||||
note=${cur_label:3}
|
||||
# And capitalise
|
||||
line=" \`${note^}\` $line"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -111,26 +122,16 @@ while IFS= read -r line; do
|
||||
|
||||
# If the PR has a runtimenoteworthy label, add to the runtime_changes section
|
||||
if has_label 'paritytech/polkadot' "$pr_id" 'B2-runtimenoteworthy'; then
|
||||
runtime_changes="$runtime_changes
|
||||
$line"
|
||||
runtime_changes+=("$line")
|
||||
fi
|
||||
# If the PR has a releasenotes label, add to the release section
|
||||
if has_label 'paritytech/polkadot' "$pr_id" 'B1-releasenotes'; then
|
||||
release_text="$release_text
|
||||
$line"
|
||||
misc_changes+=("$line")
|
||||
fi
|
||||
done <<< "$(sanitised_git_logs "$last_version" "$version" | \
|
||||
sed '/^\[contracts\].*/d' | \
|
||||
sed '/^contracts:.*/d' )"
|
||||
|
||||
if [ -n "$runtime_changes" ]; then
|
||||
release_text="$release_text
|
||||
|
||||
## Runtime
|
||||
$runtime_changes"
|
||||
fi
|
||||
echo "$release_text"
|
||||
|
||||
# Get substrate changes between last polkadot version and current
|
||||
# By grepping the Cargo.lock for a substrate crate, and grepping out the commit hash
|
||||
cur_substrate_commit=$(grep -A 2 'name = "sc-cli"' Cargo.lock | grep -E -o '[a-f0-9]{40}')
|
||||
@@ -140,10 +141,6 @@ pushd $substrate_dir || exit
|
||||
git checkout master > /dev/null
|
||||
git pull > /dev/null
|
||||
all_substrate_changes="$(sanitised_git_logs "$old_substrate_commit" "$cur_substrate_commit" | sed 's/(#/(paritytech\/substrate#/')"
|
||||
substrate_runtime_changes=""
|
||||
substrate_api_changes=""
|
||||
substrate_client_changes=""
|
||||
substrate_changes=""
|
||||
|
||||
echo "[+] Iterating through substrate changes to find labelled PRs"
|
||||
while IFS= read -r line; do
|
||||
@@ -159,6 +156,7 @@ pushd $substrate_dir || exit
|
||||
prev_label="$max_label"
|
||||
max_label="$index"
|
||||
priority="${priority_descriptions[$cur_label]}"
|
||||
|
||||
# If it's not an increase in priority, we just append
|
||||
if [ "$prev_label" == "$max_label" ]; then
|
||||
priority_changes+=("${line/\* /}")
|
||||
@@ -167,6 +165,12 @@ pushd $substrate_dir || exit
|
||||
if [ "$prev_label" != "$max_label" ]; then
|
||||
priority_changes=("${line/\* /}")
|
||||
fi
|
||||
|
||||
# Append priority to change
|
||||
# Skip first 3 chars
|
||||
note=${cur_label:3}
|
||||
# And capitalise
|
||||
line=" \`${note^}\` $line"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -174,55 +178,17 @@ pushd $substrate_dir || exit
|
||||
if has_label 'paritytech/substrate' "$pr_id" 'B0-silent'; then
|
||||
continue
|
||||
fi
|
||||
if has_label 'paritytech/substrate' "$pr_id" 'B3-apinoteworthy' ; then
|
||||
substrate_api_changes="$substrate_api_changes
|
||||
$line"
|
||||
continue
|
||||
fi
|
||||
if has_label 'paritytech/substrate' "$pr_id" 'B5-clientnoteworthy'; then
|
||||
substrate_client_changes="$substrate_client_changes
|
||||
$line"
|
||||
client_changes+=("$line")
|
||||
fi
|
||||
if has_label 'paritytech/substrate' "$pr_id" 'B7-runtimenoteworthy'; then
|
||||
substrate_runtime_changes="$substrate_runtime_changes
|
||||
$line"
|
||||
runtime_changes+=("$line")
|
||||
fi
|
||||
done <<< "$all_substrate_changes"
|
||||
popd || exit
|
||||
|
||||
# Make the substrate section if there are any substrate changes
|
||||
if [ -n "$substrate_runtime_changes" ] ||
|
||||
[ -n "$substrate_api_changes" ] ||
|
||||
[ -n "$substrate_client_changes" ]; then
|
||||
substrate_changes=$(cat << EOF
|
||||
# Substrate changes
|
||||
|
||||
EOF
|
||||
)
|
||||
if [ -n "$substrate_runtime_changes" ]; then
|
||||
substrate_changes="$substrate_changes
|
||||
|
||||
## Runtime
|
||||
$substrate_runtime_changes"
|
||||
fi
|
||||
if [ -n "$substrate_client_changes" ]; then
|
||||
substrate_changes="$substrate_changes
|
||||
|
||||
## Client
|
||||
$substrate_client_changes"
|
||||
fi
|
||||
if [ -n "$substrate_api_changes" ]; then
|
||||
substrate_changes="$substrate_changes
|
||||
|
||||
## API
|
||||
$substrate_api_changes"
|
||||
fi
|
||||
release_text="$release_text
|
||||
|
||||
$substrate_changes"
|
||||
fi
|
||||
|
||||
# Finally, add the priorities to the *start* of the release notes
|
||||
# Add the priorities to the *start* of the release notes
|
||||
# If polkadot and substrate priority = low, no need for list of changes
|
||||
if [ "$priority" == "${priority_descriptions['C1-low']}" ]; then
|
||||
release_text="$priority
|
||||
@@ -234,6 +200,29 @@ else
|
||||
$release_text"
|
||||
fi
|
||||
|
||||
# Append all notable changes to the release notes
|
||||
|
||||
if [ "${#misc_changes[*]}" -gt 0 ] ; then
|
||||
release_text="$release_text
|
||||
|
||||
## Changes
|
||||
$(printf '* %s\n' "${misc_changes[@]}")"
|
||||
fi
|
||||
|
||||
if [ "${#client_changes[*]}" -gt 0 ] ; then
|
||||
release_text="$release_text
|
||||
|
||||
## Client
|
||||
$(printf '* %s\n' "${client_changes[@]}")"
|
||||
fi
|
||||
|
||||
if [ "${#runtime_changes[*]}" -gt 0 ] ; then
|
||||
release_text="$release_text
|
||||
|
||||
## Runtime
|
||||
$(printf '* %s\n' "${runtime_changes[@]}")"
|
||||
fi
|
||||
|
||||
echo "[+] Release text generated: "
|
||||
echo "$release_text"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user