blob: 972d6ea937dfb65328ff11261817d0db38b6e4b7 [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
13USAGE="Usage: ${0##*/} [-b branch] [-d date] [-o oldver] [-n newver]"
14OUTPUT=
15BRANCH=
16HTML=
17DATE=
18YEAR=
19OLD=
20NEW=
21DIR=
22
23die() {
24 [ "$#" -eq 0 ] || echo "$*" >&2
25 exit 1
26}
27
28err() {
29 echo "$*" >&2
30}
31
32quit() {
33 [ "$#" -eq 0 ] || echo "$*"
34 exit 0
35}
36
37while [ -n "$1" -a -z "${1##-*}" ]; do
38 case "$1" in
39 -d) DATE="$2" ; shift 2 ;;
40 -b) BRANCH="$2" ; shift 2 ;;
41 -o) OLD="$2" ; shift 2 ;;
42 -n) NEW="$2" ; shift 2 ;;
43 -h|--help) quit "$USAGE" ;;
44 *) die "$USAGE" ;;
45 esac
46done
47
48if [ $# -gt 0 ]; then
49 die "$USAGE"
50fi
51
52if ! git rev-parse --verify -q HEAD >/dev/null; then
53 die "Failed to check git HEAD."
54fi
55
56# we want to go to the git root dir
57DIR="$PWD"
58cd $(git rev-parse --show-toplevel)
59
60if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then
61 die "git HEAD doesn't match master branch."
62fi
63
64if [ "$(git diff HEAD|wc -c)" != 0 ]; then
65 err "You appear to have uncommitted local changes, please commit them first :"
66 git status -s -uno >&2
67 die
68fi
69
70if [ -z "$NEW" ]; then
71 NEW="$(git describe --tags HEAD --abbrev=0)"
72 NEW="${NEW#v}"
73 if [ -z "$NEW" ]; then
74 die "Fatal: cannot determine new version, please specify it."
75 fi
76 if [ "$(git describe --tags HEAD)" != "v$NEW" ]; then
77 die "Current version doesn't seem tagged, it reports $(git describe --tags "v$NEW"). Did you release it ?"
78 fi
79fi
80
81if ! git show-ref --tags "v$NEW" >/dev/null; then
Willy Tarreau827385f2017-03-27 19:36:45 +020082 die "git tag v$NEW doesn't exist, did you create the release ?"
Willy Tarreau62b71ee2016-05-10 12:04:13 +020083fi
84
85if [ -z "$OLD" ]; then
86 OLD="$(git describe --tags v${NEW}^ --abbrev=0)"
87 OLD="${OLD#v}"
88fi
89
90if ! git rev-parse --verify -q "v$OLD" >/dev/null; then
91 die "git tag v$OLD doesn't exist."
92fi
93
94# determine the product branch from the new release
95if [ -z "$BRANCH" ]; then
96 subvers=${NEW#[0-9]*.[0-9]*[-.]*[0-9].}
97 [ "${subvers}" = "${NEW}" ] && subvers=""
98 major=${NEW%.$subvers}
99 branch_ext=${major#*[0-9].*[0-9]}
100 BRANCH=${major%${branch_ext}}
101fi
102
103# determine the release date
104if [ -z "$DATE" ]; then
105 DATE="$(git log -1 --pretty=fuller v${NEW} 2>/dev/null | sed -ne '/^CommitDate:/{s/\(^[^ ]*:\)\|\( [-+].*\)//gp;q}')"
106 DATE="$(date +%Y/%m/%d -d "$DATE")"
107fi
108YEAR="${DATE%%/*}"
109
110OUTPUT="$DIR/mail-haproxy-$NEW.txt"
111if [ -e "$OUTPUT" ]; then
112 die "$OUTPUT already exists, please remove it."
113fi
114
115HTML="$DIR/web-haproxy-$NEW.html"
116if [ -e "$HTML" ]; then
117 die "$HTML already exists, please remove it."
118fi
119
120(echo "Subject: [ANNOUNCE] haproxy-$NEW"
121 echo "To: haproxy@formilux.org"
122 echo
123 echo "Hi,"
124 echo
125 echo -n "HAProxy $NEW was released on $DATE. It added "
126 echo -n $(git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | wc -l)
127 echo " new commits"
128 echo "after version $OLD."
129 echo
130 echo "- per tag :"
131 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f1 -d':' | sort | uniq -c
132 echo
133 echo "major commits :"
134 git log --oneline --reverse --format=" - %s" "v$OLD".."v$NEW^" | grep MAJOR
135 echo
136 echo "- per file :"
137 git show "v$OLD".."v$NEW^" -- src/ | grep ^diff | awk '{ print substr($3,7)}' | sort | uniq -c | sort -nr | head -15
138 echo
139 echo "- per topic :"
140 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
141 echo
142 echo "- sorted changelog :"
143 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | sort
144 echo
145 echo "#############################################################################################"
146) >> "$OUTPUT"
147
148# report the download paths
149if [ -z "${NEW##*-dev*}" ]; then
150 gitdir="haproxy.git"
151else
152 gitdir="haproxy-$BRANCH.git"
153fi
154
155(echo "Please find the usual URLs below :"
156 echo " Site index : http://www.haproxy.org/"
157 echo " Discourse : http://discourse.haproxy.org/"
Willy Tarreaud6cad122018-12-19 18:59:51 +0100158 echo " Slack channel : https://slack.haproxy.org/"
Willy Tarreau9589c3b2019-01-29 06:51:16 +0100159 echo " Issue tracker : https://github.com/haproxy/haproxy/issues"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200160 echo " Sources : http://www.haproxy.org/download/${BRANCH}/src/"
161 echo " Git repository : http://git.haproxy.org/git/${gitdir}/"
162 echo " Git Web browsing : http://git.haproxy.org/?p=${gitdir}"
163 echo " Changelog : http://www.haproxy.org/download/${BRANCH}/src/CHANGELOG"
164 echo " Cyril's HTML doc : http://cbonte.github.io/haproxy-dconv/"
165) >> "$OUTPUT"
166
167# sign
168(echo
169 echo "${GIT_COMMITTER_NAME% *}"
170) >> "$OUTPUT"
171
172(echo "---"
173 echo "Complete changelog :"
Willy Tarreau6a375ef2017-03-27 19:32:24 +0200174 git shortlog "v$OLD".."v$NEW^"
Willy Tarreau62b71ee2016-05-10 12:04:13 +0200175 echo "---"
176) >> "$OUTPUT"
177
178
179# prepare the HTML update
180set -- $(date +%e -d "$DATE")
181case "$1" in
182 11|12|13) day="${1}th" ;;
183 *1) day="${1}st" ;;
184 *2) day="${2}nd" ;;
185 *3) day="${1}rd" ;;
186 *) day="${1}th" ;;
187esac
188
189humandate=$(date "+%B, $day, %Y" -d "$DATE")
190(echo "$humandate</b> : <i>$NEW</i>"
191 echo " <p>"
192 echo " <ul>"
193 echo "<--------------------------- edit contents below --------------------------->"
194 echo "- per tag :"
195 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f1 -d':' | sort | uniq -c
196 echo
197 echo "- per topic :"
198 git log --oneline --reverse --format="%s" "v$OLD".."v$NEW^" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
199 echo
200 echo "major commits :"
201 git log --oneline --reverse --format=" - %s" "v$OLD".."v$NEW^" | grep MAJOR
202 echo
203 echo "<--------------------------------------------------------------------------->"
204 echo " Code and changelog are available <a href=\"/download/${BRANCH}/src/\">here</a> as usual."
205 echo " </ul>"
206 echo " <p>"
207 echo " <b>"
208) >> "$HTML"
209
210echo "The announce was emitted into file $OUTPUT."
211echo "You can edit it and send it this way :"
212echo
213echo " mutt -i ${OUTPUT##*/} -s \"[ANNOUNCE] haproxy-$NEW\" haproxy@formilux.org"
214echo
215echo "The HTML block was emitted into $HTML and needs to be finished by hand."
216echo