blob: 7e81907e074ce60414321143ecdb8629336ae525 [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:"
127 echo "# mutt -i <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEW\" haproxy@formilux.org"
128) >> "$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 Tarreau62b71ee2016-05-10 12:04:13 +0200168 echo " Sources : http://www.haproxy.org/download/${BRANCH}/src/"
169 echo " Git repository : http://git.haproxy.org/git/${gitdir}/"
170 echo " Git Web browsing : http://git.haproxy.org/?p=${gitdir}"
171 echo " Changelog : http://www.haproxy.org/download/${BRANCH}/src/CHANGELOG"
172 echo " Cyril's HTML doc : http://cbonte.github.io/haproxy-dconv/"
173) >> "$OUTPUT"
174
175# sign
176(echo
177 echo "${GIT_COMMITTER_NAME% *}"
178) >> "$OUTPUT"
179
180(echo "---"
181 echo "Complete changelog :"
Willy Tarreau6a375ef2017-03-27 19:32:24 +0200182 git shortlog "v$OLD".."v$NEW^"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200183 echo "---"
184) >> "$OUTPUT"
185
186
187# prepare the HTML update
188set -- $(date +%e -d "$DATE")
189case "$1" in
190 11|12|13) day="${1}th" ;;
191 *1) day="${1}st" ;;
192 *2) day="${2}nd" ;;
193 *3) day="${1}rd" ;;
194 *) day="${1}th" ;;
195esac
196
197humandate=$(date "+%B, $day, %Y" -d "$DATE")
198(echo "$humandate</b> : <i>$NEW</i>"
199 echo " <p>"
200 echo " <ul>"
201 echo "<--------------------------- edit contents below --------------------------->"
202 echo "- per tag :"
203 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f1 -d':' | sort | uniq -c
204 echo
205 echo "- per topic :"
206 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
207 echo
208 echo "major commits :"
209 git log --oneline --reverse --format=" - %s" "v$OLD".."v$NEW^" | grep MAJOR
210 echo
211 echo "<--------------------------------------------------------------------------->"
212 echo " Code and changelog are available <a href=\"/download/${BRANCH}/src/\">here</a> as usual."
213 echo " </ul>"
214 echo " <p>"
215 echo " <b>"
216) >> "$HTML"
217
218echo "The announce was emitted into file $OUTPUT."
219echo "You can edit it and send it this way :"
220echo
Willy Tarreau84f6dca2020-02-07 08:10:06 +0100221echo " mutt -i <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEW\" haproxy@formilux.org"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200222echo
223echo "The HTML block was emitted into $HTML and needs to be finished by hand."
224echo