blob: aa0dd83317088a77b2715617562322332b807b49 [file] [log] [blame]
Willy Tarreau62b71ee2016-05-10 12:04:13 +02001#!/bin/bash
2# prepares a template e-mail and HTML file to announce a new release
3# Copyright (c) 2006-2016 Willy Tarreau <w@1wt.eu>
4#
5# In short :
6# - requires git
7# - wants that last commit is a release/tag
8# - no restriction to master, uses last tag
9# - creates mail-$version.txt
10# - creates web-$version.html
11# - indicates how to edit the mail and how to send it
12
Willy Tarreau7dc322d2020-02-07 08:11:45 +010013USAGE="Usage: ${0##*/} [-f] [-b branch] [-d date] [-o oldver] [-n newver]"
14FORCE=
Willy Tarreau62b71ee2016-05-10 12:04:13 +020015OUTPUT=
16BRANCH=
17HTML=
18DATE=
19YEAR=
20OLD=
21NEW=
22DIR=
23
24die() {
25 [ "$#" -eq 0 ] || echo "$*" >&2
26 exit 1
27}
28
29err() {
30 echo "$*" >&2
31}
32
33quit() {
34 [ "$#" -eq 0 ] || echo "$*"
35 exit 0
36}
37
38while [ -n "$1" -a -z "${1##-*}" ]; do
39 case "$1" in
40 -d) DATE="$2" ; shift 2 ;;
41 -b) BRANCH="$2" ; shift 2 ;;
Willy Tarreau7dc322d2020-02-07 08:11:45 +010042 -f) FORCE=1 ; shift ;;
Willy Tarreau62b71ee2016-05-10 12:04:13 +020043 -o) OLD="$2" ; shift 2 ;;
44 -n) NEW="$2" ; shift 2 ;;
45 -h|--help) quit "$USAGE" ;;
46 *) die "$USAGE" ;;
47 esac
48done
49
50if [ $# -gt 0 ]; then
51 die "$USAGE"
52fi
53
54if ! git rev-parse --verify -q HEAD >/dev/null; then
55 die "Failed to check git HEAD."
56fi
57
58# we want to go to the git root dir
59DIR="$PWD"
60cd $(git rev-parse --show-toplevel)
61
62if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then
63 die "git HEAD doesn't match master branch."
64fi
65
66if [ "$(git diff HEAD|wc -c)" != 0 ]; then
67 err "You appear to have uncommitted local changes, please commit them first :"
68 git status -s -uno >&2
69 die
70fi
71
72if [ -z "$NEW" ]; then
73 NEW="$(git describe --tags HEAD --abbrev=0)"
74 NEW="${NEW#v}"
75 if [ -z "$NEW" ]; then
76 die "Fatal: cannot determine new version, please specify it."
77 fi
78 if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then
79 die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?"
80 fi
81fi
82
83if ! git show-ref --tags "v$NEW" >/dev/null; then
Willy Tarreau827385f2017-03-27 19:36:45 +020084 die "git tag v$NEW doesn't exist, did you create the release ?"
Willy Tarreau62b71ee2016-05-10 12:04:13 +020085fi
86
87if [ -z "$OLD" ]; then
88 OLD="$(git describe --tags v${NEW}^ --abbrev=0)"
89 OLD="${OLD#v}"
90fi
91
92if ! git rev-parse --verify -q "v$OLD" >/dev/null; then
93 die "git tag v$OLD doesn't exist."
94fi
95
96# determine the product branch from the new release
97if [ -z "$BRANCH" ]; then
98 subvers=${NEW#[0-9]*.[0-9]*[-.]*[0-9].}
99 [ "${subvers}" = "${NEW}" ] && subvers=""
100 major=${NEW%.$subvers}
101 branch_ext=${major#*[0-9].*[0-9]}
102 BRANCH=${major%${branch_ext}}
103fi
104
105# determine the release date
106if [ -z "$DATE" ]; then
107 DATE="$(git log -1 --pretty=fuller v${NEW} 2>/dev/null | sed -ne '/^CommitDate:/{s/\(^[^ ]*:\)\|\( [-+].*\)//gp;q}')"
108 DATE="$(date +%Y/%m/%d -d "$DATE")"
109fi
110YEAR="${DATE%%/*}"
111
112OUTPUT="$DIR/mail-haproxy-$NEW.txt"
Willy Tarreau7dc322d2020-02-07 08:11:45 +0100113HTML="$DIR/web-haproxy-$NEW.html"
114
115[ -z "$FORCE" ] || rm -f "${OUTPUT}" "${HTML}"
116
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200117if [ -e "$OUTPUT" ]; then
Willy Tarreau7dc322d2020-02-07 08:11:45 +0100118 die "${OUTPUT##*/} already exists, please remove it or retry with -f."
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200119fi
120
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200121if [ -e "$HTML" ]; then
Willy Tarreau7dc322d2020-02-07 08:11:45 +0100122 die "$HTML already exists, please remove it or retry with -f."
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200123fi
124
Willy Tarreau84f6dca2020-02-07 08:10:06 +0100125(
126 echo "# Send this using:"
Willy Tarreau164d0092020-02-15 15:24:28 +0100127 echo "# mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEW\" haproxy@formilux.org"
Willy Tarreau84f6dca2020-02-07 08:10:06 +0100128) >> "$OUTPUT"
129
130(echo
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200131 echo "Hi,"
132 echo
133 echo -n "HAProxy $NEW was released on $DATE. It added "
134 echo -n $(git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | wc -l)
135 echo " new commits"
136 echo "after version $OLD."
137 echo
138 echo "- per tag :"
139 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f1 -d':' | sort | uniq -c
140 echo
141 echo "major commits :"
142 git log --oneline --reverse --format=" - %s" "v$OLD".."v$NEW^" | grep MAJOR
143 echo
144 echo "- per file :"
145 git show "v$OLD".."v$NEW^" -- src/ | grep ^diff | awk '{ print substr($3,7)}' | sort | uniq -c | sort -nr | head -15
146 echo
147 echo "- per topic :"
148 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
149 echo
150 echo "- sorted changelog :"
151 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | sort
152 echo
153 echo "#############################################################################################"
154) >> "$OUTPUT"
155
156# report the download paths
157if [ -z "${NEW##*-dev*}" ]; then
158 gitdir="haproxy.git"
159else
160 gitdir="haproxy-$BRANCH.git"
161fi
162
163(echo "Please find the usual URLs below :"
164 echo " Site index : http://www.haproxy.org/"
165 echo " Discourse : http://discourse.haproxy.org/"
Willy Tarreaud6cad122018-12-19 18:59:51 +0100166 echo " Slack channel : https://slack.haproxy.org/"
Willy Tarreau9589c3b2019-01-29 06:51:16 +0100167 echo " Issue tracker : https://github.com/haproxy/haproxy/issues"
Willy Tarreau36787f52020-07-30 17:41:42 +0200168 echo " Wiki : https://github.com/haproxy/wiki/wiki"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200169 echo " Sources : http://www.haproxy.org/download/${BRANCH}/src/"
170 echo " Git repository : http://git.haproxy.org/git/${gitdir}/"
171 echo " Git Web browsing : http://git.haproxy.org/?p=${gitdir}"
172 echo " Changelog : http://www.haproxy.org/download/${BRANCH}/src/CHANGELOG"
173 echo " Cyril's HTML doc : http://cbonte.github.io/haproxy-dconv/"
174) >> "$OUTPUT"
175
176# sign
177(echo
178 echo "${GIT_COMMITTER_NAME% *}"
179) >> "$OUTPUT"
180
181(echo "---"
182 echo "Complete changelog :"
Willy Tarreau6a375ef2017-03-27 19:32:24 +0200183 git shortlog "v$OLD".."v$NEW^"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200184 echo "---"
185) >> "$OUTPUT"
186
187
188# prepare the HTML update
189set -- $(date +%e -d "$DATE")
190case "$1" in
191 11|12|13) day="${1}th" ;;
192 *1) day="${1}st" ;;
193 *2) day="${2}nd" ;;
194 *3) day="${1}rd" ;;
195 *) day="${1}th" ;;
196esac
197
198humandate=$(date "+%B, $day, %Y" -d "$DATE")
199(echo "$humandate</b> : <i>$NEW</i>"
200 echo " <p>"
201 echo " <ul>"
202 echo "<--------------------------- edit contents below --------------------------->"
203 echo "- per tag :"
204 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f1 -d':' | sort | uniq -c
205 echo
206 echo "- per topic :"
207 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
208 echo
209 echo "major commits :"
210 git log --oneline --reverse --format=" - %s" "v$OLD".."v$NEW^" | grep MAJOR
211 echo
212 echo "<--------------------------------------------------------------------------->"
213 echo " Code and changelog are available <a href=\"/download/${BRANCH}/src/\">here</a> as usual."
214 echo " </ul>"
215 echo " <p>"
216 echo " <b>"
217) >> "$HTML"
218
219echo "The announce was emitted into file $OUTPUT."
220echo "You can edit it and send it this way :"
221echo
Willy Tarreau164d0092020-02-15 15:24:28 +0100222echo " mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEW\" haproxy@formilux.org"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200223echo
224echo "The HTML block was emitted into $HTML and needs to be finished by hand."
225echo