-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
show_drafts.sh
executable file
·51 lines (40 loc) · 1.59 KB
/
show_drafts.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
rstrip_ver() {
if [ -z "$1" ]; then
grep -Po "^.*?(?=(\.0\.0\.0|\.0\.0|\.0)?$)"
else
echo $1 | grep -Po "^.*?(?=(\.0\.0\.0|\.0\.0|\.0)?$)"
fi
}
esc=$(printf '\033')
colorize_changelog() {
#1 pr number
#2 list char
#3 pr submitter
sed -r -e "s/\\((#[0-9]+)\)/(${esc}[32m\1${esc}[0m)/g" \
-e "s/^\s*[*+-]\s*/ ${esc}[1;30m-${esc}[0m /g" \
-e "s/@([^ ]+)$/${esc}[1;30m@${esc}[0;36m\1${esc}[0m/gi"
}
IFS=$'\n'
for name in $(git submodule foreach --quiet 'basename $PWD'); do
pushd $name > /dev/null
draft="$(hub release --include-drafts -L2 -f 'SOF:%S%n%T%n%t%n%U%n%b%nEOF%n' --color=always | sed -n -e '/SOF:draft/,/EOF/p' | sed -e '1d' -e '$d')"
if [ ! -z "$draft" ]; then
IFS=$'\n' parts=(${draft})
tag="${parts[0]}"
title="${parts[1]}"
url="${parts[2]}"
IFS=$'\n' description="${parts[*]:3}"
echo
echo -e "\e[1m$name\e[0m: $title\n \e[34m$url\e[0m"
changes=$(echo "$description" | grep -Po '^\s*\K\*.*$' )
meta_version=$(grep -Po "version: ?[\"']?\K.*(?=[\"']$)" build.yaml | rstrip_ver)
draft_version=$(echo $tag | grep -Po 'v\K.*' | rstrip_ver)
if [ "$meta_version" != "$draft_version" ]; then
echo -e " \e[1;31mVersion bump needed!"
echo -e " \e[0;31mDraft is for v\e[0m\e[1m$draft_version\e[0;31m, but build.yaml specifies v\e[0m\e[1m$meta_version\e[0m"
fi
echo "$changes" | colorize_changelog
fi
popd > /dev/null
done