mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
0c93011760
* 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
74 lines
2.4 KiB
Bash
Executable File
74 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
api_base="https://api.github.com/repos"
|
|
|
|
# Function to take 2 git tags/commits and get any lines from commit messages
|
|
# that contain something that looks like a PR reference: e.g., (#1234)
|
|
sanitised_git_logs(){
|
|
git --no-pager log --pretty=format:"%s" "$1..$2" |
|
|
# Only find messages referencing a PR
|
|
grep -E '\(#[0-9]+\)' |
|
|
# Strip any asterisks
|
|
sed 's/^* //g' |
|
|
# And add them all back
|
|
sed 's/^/* /g'
|
|
}
|
|
|
|
# Checks whether a tag on github has been verified
|
|
# repo: 'organization/repo'
|
|
# tagver: 'v1.2.3'
|
|
# Usage: check_tag $repo $tagver
|
|
check_tag () {
|
|
repo=$1
|
|
tagver=$2
|
|
tag_out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/git/refs/tags/$tagver")
|
|
tag_sha=$(echo "$tag_out" | jq -r .object.sha)
|
|
object_url=$(echo "$tag_out" | jq -r .object.url)
|
|
if [ "$tag_sha" = "null" ]; then
|
|
return 2
|
|
fi
|
|
verified_str=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$object_url" | jq -r .verification.verified)
|
|
if [ "$verified_str" = "true" ]; then
|
|
# Verified, everything is good
|
|
return 0
|
|
else
|
|
# Not verified. Bad juju.
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Checks whether a given PR has a given label.
|
|
# repo: 'organization/repo'
|
|
# pr_id: 12345
|
|
# label: B1-silent
|
|
# Usage: has_label $repo $pr_id $label
|
|
has_label(){
|
|
repo="$1"
|
|
pr_id="$2"
|
|
label="$3"
|
|
out=$(curl -H "Authorization: token $GITHUB_RELEASE_TOKEN" -s "$api_base/$repo/pulls/$pr_id")
|
|
[ -n "$(echo "$out" | tr -d '\r\n' | jq ".labels | .[] | select(.name==\"$label\")")" ]
|
|
}
|
|
|
|
# Formats a message into a JSON string for posting to Matrix
|
|
# message: 'any plaintext message'
|
|
# formatted_message: '<strong>optional message formatted in <em>html</em></strong>'
|
|
# Usage: structure_message $content $formatted_content (optional)
|
|
structure_message() {
|
|
if [ -z "$2" ]; then
|
|
body=$(jq -Rs --arg body "$1" '{"msgtype": "m.text", $body}' < /dev/null)
|
|
else
|
|
body=$(jq -Rs --arg body "$1" --arg formatted_body "$2" '{"msgtype": "m.text", $body, "format": "org.matrix.custom.html", $formatted_body}' < /dev/null)
|
|
fi
|
|
echo "$body"
|
|
}
|
|
|
|
# Post a message to a matrix room
|
|
# body: '{body: "JSON string produced by structure_message"}'
|
|
# room_id: !fsfSRjgjBWEWffws:matrix.parity.io
|
|
# access_token: see https://matrix.org/docs/guides/client-server-api/
|
|
# Usage: send_message $body (json formatted) $room_id $access_token
|
|
send_message() {
|
|
curl -XPOST -d "$1" "https://matrix.parity.io/_matrix/client/r0/rooms/$2/send/m.room.message?access_token=$3"
|
|
}
|