Unverified Commit 853b8d3e authored by s3krit's avatar s3krit Committed by GitHub
Browse files

CI: Label PRs with B2-breaksapi if substrate changes are labelled B2-breaksapi (#862)

* CI: Split common functions into lib.sh and make...

... alert_pending_release.sh check the substrate changes for various
labels. If labelled, will be included in the changelog, otherwise will
silently be left out.

* replace non-standard /bin/bash with /usr/bin/env bash

* CI: make lib.sh /bin/sh-compatible

* lib.sh: fix newline chars sometimes breaking has_label()

* check_runtime.sh: tag change with 'B2-breaksapi'...

... if any substrate changes are also labelled 'B2-breaksapi'

* Remove debug exits and uncomment labelling

* exit early if we label with breaksapi

* fix publish_draft_release.sh
parent b94febb1
Pipeline #80677 passed with stages
in 25 minutes and 55 seconds
......@@ -16,13 +16,16 @@
set -e # fail on any error
#Include the common functions library
#shellcheck source=lib.sh
. "$(dirname "${0}")/lib.sh"
boldprint () { printf "|\n| \033[1m${@}\033[0m\n|\n" ; }
boldcat () { printf "|\n"; while read l; do printf "| \033[1m${l}\033[0m\n"; done; printf "|\n" ; }
boldprint () { printf "|\n| \033[1m%s\033[0m\n|\n" "${@}"; }
boldcat () { printf "|\n"; while read -r l; do printf "| \033[1m%s\033[0m\n" "${l}"; done; printf "|\n" ; }
# figure out the latest release tag
......@@ -31,7 +34,7 @@ boldprint "latest release tag ${LATEST_TAG}"
boldprint "latest 10 commits of ${CI_COMMIT_REF_NAME}"
git log --graph --oneline --decorate=short -n 10
git --no-pager log --graph --oneline --decorate=short -n 10
boldprint "make sure the master branch is available in shallow clones"
git fetch --depth=${GIT_DEPTH:-100} origin master
......@@ -106,6 +109,22 @@ then
spec_version or or impl_version have changed in substrate after updating Cargo.lock
please make sure versions are bumped in polkadot accordingly
# Now check if any of the substrate changes have been tagged B2-breaksapi
substrate_changes="$(sanitised_git_logs "${SUBSTRATE_PREV_REF}" "${SUBSTRATE_NEW_REF}")"
echo "$substrate_changes" | while read -r line; do
pr_id=$(echo "$line" | sed -E 's/.*#([0-9]+)\)$/\1/')
if has_label 'paritytech/substrate' "$pr_id" 'B2-breaksapi'; then
boldprint "Substrate change labelled with B2-breaksapi. Labelling..."
github_label "B2-breaksapi"
exit 1
......@@ -47,7 +47,7 @@ has_label(){
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
[ -n "$(echo "$out" | jq ".labels | .[] | select(.name==\"$label\")")" ]
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
# Formats a message into a JSON string for posting to Matrix
......@@ -129,6 +129,6 @@ formatted_msg_body=$(cat <<EOF
Draft release created: $html_url
send_message "$(structure_message "$msg_body" "$formatted_msg_body")" "$MATRIX_ACCESS_TOKEN"
send_message "$(structure_message "$msg_body" "$formatted_msg_body")" "$MATRIX_ROOM_ID" "$MATRIX_ACCESS_TOKEN"
echo "[+] Done! Maybe the release worked..."
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment