forked from kubernetes-sigs/controller-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release-notes.sh
executable file
·118 lines (104 loc) · 3.12 KB
/
release-notes.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env bash
set -e
set -o pipefail
# import our common stuff
source "$(dirname ${BASH_SOURCE})/common.sh"
# TODO: work with both release branch and major release
git::ensure-release-branch
git::export-current-version
# check the next version
next_ver=$(git::next-version)
features=""
bugfixes=""
breaking=""
unknown=""
MERGE_PR="Merge pull request #([[:digit:]]+) from ([[:alnum:]-]+)/.+"
NEWLINE="
"
head_commit=$(git rev-parse HEAD)
while read commit_word commit; do
if [[ -z ${commit_word} ]]; then
# skip terminating blank lines
continue
fi
read title
if [[ ${title} == "Merge branch '"*"' into"* ]]; then
# skip temporary merge commits and accidental merge commit inclusion
# for calcuating release notes.
continue
elif [[ ${title} == "Merge branch '"*"'"* ]]; then
# skip for accidental merge commit inclusion for calculating release notes
# NB(directxman12): it's not clear what tool generates this style, but we've
# got some now, so tolerate them.
continue
fi
read # skip the blank line
read prefix body
if [[ ${prefix} == v*.*.* && ( ${commit} == ${head_commit} || $(git tag --points-at ${commit}) == v*.*.* ) ]]; then
# skip version merges
continue
fi
set +x
if [[ ! ${title} =~ ${MERGE_PR} ]]; then
echo "Unable to determine PR number for merge ${commit} with title '${title}', aborting." >&2
exit 1
fi
pr_number=${BASH_REMATCH[1]}
pr_type=$(cr::symbol-type ${prefix})
pr_title=${body}
if [[ ${pr_type} == "unknown" ]]; then
pr_title="${prefix} ${pr_title}"
fi
case ${pr_type} in
major)
breaking="${breaking}- ${pr_title} (#${pr_number})${NEWLINE}"
;;
minor)
features="${features}- ${pr_title} (#${pr_number})${NEWLINE}"
;;
patch)
bugfixes="${bugfixes}- ${pr_title} (#${pr_number})${NEWLINE}"
;;
docs|no_release_note|other)
# skip non-code-changes
;;
unknown)
unknown="${unknown}- ${pr_title} (#${pr_number})${NEWLINE}"
;;
*)
echo "unknown PR type '${pr_type}' on PR '${pr_title}'" >&2
exit 1
esac
done <<<$(git rev-list ${last_tag}..HEAD --merges --pretty=format:%B)
# TODO: sort non merge commits with tags
[[ -n "${breaking}" ]] && printf '\e[1;31mbreaking changes this version\e[0m\n' >&2
[[ -n "${unknown}" ]] && printf '\e[1;35munknown changes in this release -- categorize manually\e[0m\n' >&2
echo "" >&2
echo "" >&2
echo "# ${next_ver}"
if [[ -n ${breaking} ]]; then
echo ""
echo "## :warning: Breaking Changes"
echo ""
echo "${breaking}"
fi
if [[ -n ${features} ]]; then
echo ""
echo "## :sparkles: New Features"
echo ""
echo "${features}"
fi
if [[ -n ${bugfixes} ]]; then
echo ""
echo "## :bug: Bug Fixes"
echo ""
echo "${bugfixes}"
fi
if [[ -n ${unknown} ]]; then
echo ""
echo "## :question: *categorize these manually*"
echo ""
echo "${unknown}"
fi
echo ""
echo "*Thanks to all our contributors!*"