Willy Tarreau | be9b00f | 2020-02-05 04:45:18 +0100 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 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 Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 13 | USAGE="Usage: ${0##*/} [-f] [-b branch] [-d date] [-o oldver] [-n newver] |
| 14 | -f: force to overwrite existing files and ignore local changes |
| 15 | -b: force the project branch name to this (def: inherited from the version) |
| 16 | -d: force the release date (e.g. to rework a failed announce) |
| 17 | -o: previous version (def: newver-1) |
| 18 | -n: new version (if not last tag) |
| 19 | " |
| 20 | PREPARE= |
Willy Tarreau | 3823408 | 2020-02-07 08:11:45 +0100 | [diff] [blame] | 21 | FORCE= |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 22 | OUTPUT= |
| 23 | BRANCH= |
| 24 | HTML= |
| 25 | DATE= |
| 26 | YEAR= |
| 27 | OLD= |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 28 | LASTCOM= |
| 29 | NEWVER= |
| 30 | NEWTAG= |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 31 | DIR= |
| 32 | |
| 33 | die() { |
| 34 | [ "$#" -eq 0 ] || echo "$*" >&2 |
| 35 | exit 1 |
| 36 | } |
| 37 | |
| 38 | err() { |
| 39 | echo "$*" >&2 |
| 40 | } |
| 41 | |
| 42 | quit() { |
| 43 | [ "$#" -eq 0 ] || echo "$*" |
| 44 | exit 0 |
| 45 | } |
| 46 | |
| 47 | while [ -n "$1" -a -z "${1##-*}" ]; do |
| 48 | case "$1" in |
| 49 | -d) DATE="$2" ; shift 2 ;; |
| 50 | -b) BRANCH="$2" ; shift 2 ;; |
Willy Tarreau | 3823408 | 2020-02-07 08:11:45 +0100 | [diff] [blame] | 51 | -f) FORCE=1 ; shift ;; |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 52 | -o) OLD="$2" ; shift 2 ;; |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 53 | -n) NEWVER="$2" ; shift 2 ;; |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 54 | -h|--help) quit "$USAGE" ;; |
| 55 | *) die "$USAGE" ;; |
| 56 | esac |
| 57 | done |
| 58 | |
| 59 | if [ $# -gt 0 ]; then |
| 60 | die "$USAGE" |
| 61 | fi |
| 62 | |
| 63 | if ! git rev-parse --verify -q HEAD >/dev/null; then |
| 64 | die "Failed to check git HEAD." |
| 65 | fi |
| 66 | |
| 67 | # we want to go to the git root dir |
| 68 | DIR="$PWD" |
| 69 | cd $(git rev-parse --show-toplevel) |
| 70 | |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 71 | if [ -z "$FORCE" -a "$(git diff HEAD|wc -c)" != 0 ]; then |
| 72 | err "You appear to have uncommitted local changes, please commit them first :" |
| 73 | git status -s -uno >&2 |
| 74 | die |
| 75 | fi |
| 76 | |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 77 | if [ "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then |
| 78 | die "git HEAD doesn't match master branch." |
| 79 | fi |
| 80 | |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 81 | if [ -n "$NEWVER" ]; then |
| 82 | if git show-ref --tags "v$NEWVER" >/dev/null; then |
| 83 | NEWTAG="v$NEWVER" |
| 84 | else |
| 85 | echo "Note: no matching tag v$NEWVER, using HEAD". |
| 86 | fi |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 87 | fi |
| 88 | |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 89 | # version unspecified or no existing tag for it |
| 90 | if [ -z "$NEWTAG" ]; then |
| 91 | NEWTAG="$(git describe --tags HEAD --abbrev=0)" |
| 92 | |
| 93 | if [ -z "$NEWTAG" ]; then |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 94 | die "Fatal: cannot determine new version, please specify it." |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 95 | |
| 96 | elif [ "$(git describe --tags HEAD)" != "$NEWTAG" ]; then |
| 97 | die "About to use current HEAD which doesn't seem tagged, it reports '$(git describe --tags HEAD 2>/dev/null)'. Did you release it ?" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 98 | fi |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 99 | elif ! git show-ref --tags "$NEWTAG" >/dev/null 2>&1; then |
| 100 | die "git tag $NEWTAG doesn't exist, did you create the release ?" |
| 101 | fi |
| 102 | |
| 103 | if [ -z "$NEWVER" ]; then |
| 104 | NEWVER="${NEWTAG#v}" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 105 | fi |
| 106 | |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 107 | if [ -z "$LASTCOM" ]; then |
| 108 | LASTCOM="$(git rev-parse --short ${NEWTAG}^)" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 109 | fi |
| 110 | |
| 111 | if [ -z "$OLD" ]; then |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 112 | OLD="$(git describe --tags ${LASTCOM} --abbrev=0)" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 113 | OLD="${OLD#v}" |
| 114 | fi |
| 115 | |
| 116 | if ! git rev-parse --verify -q "v$OLD" >/dev/null; then |
| 117 | die "git tag v$OLD doesn't exist." |
| 118 | fi |
| 119 | |
| 120 | # determine the product branch from the new release |
| 121 | if [ -z "$BRANCH" ]; then |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 122 | subvers=${NEWVER#[0-9]*.[0-9]*[-.]*[0-9].} |
| 123 | [ "${subvers}" = "${NEWVER}" ] && subvers="" |
| 124 | major=${NEWVER%.$subvers} |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 125 | branch_ext=${major#*[0-9].*[0-9]} |
| 126 | BRANCH=${major%${branch_ext}} |
| 127 | fi |
| 128 | |
| 129 | # determine the release date |
| 130 | if [ -z "$DATE" ]; then |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 131 | DATE="$(git log -1 --pretty=fuller ${NEWTAG} 2>/dev/null | sed -ne '/^CommitDate:/{s/\(^[^ ]*:\)\|\( [-+].*\)//gp;q}')" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 132 | DATE="$(date +%Y/%m/%d -d "$DATE")" |
| 133 | fi |
| 134 | YEAR="${DATE%%/*}" |
| 135 | |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 136 | OUTPUT="$DIR/mail-haproxy-$NEWVER.txt" |
| 137 | HTML="$DIR/web-haproxy-$NEWVER.html" |
Willy Tarreau | 3823408 | 2020-02-07 08:11:45 +0100 | [diff] [blame] | 138 | |
| 139 | [ -z "$FORCE" ] || rm -f "${OUTPUT}" "${HTML}" |
| 140 | |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 141 | if [ -e "$OUTPUT" ]; then |
Willy Tarreau | 3823408 | 2020-02-07 08:11:45 +0100 | [diff] [blame] | 142 | die "${OUTPUT##*/} already exists, please remove it or retry with -f." |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 143 | fi |
| 144 | |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 145 | if [ -e "$HTML" ]; then |
Willy Tarreau | 3823408 | 2020-02-07 08:11:45 +0100 | [diff] [blame] | 146 | die "$HTML already exists, please remove it or retry with -f." |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 147 | fi |
| 148 | |
Willy Tarreau | 0f5ce60 | 2020-02-07 08:10:06 +0100 | [diff] [blame] | 149 | ( |
| 150 | echo "# Send this using:" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 151 | echo "# mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEWVER\" haproxy@formilux.org" |
Willy Tarreau | 0f5ce60 | 2020-02-07 08:10:06 +0100 | [diff] [blame] | 152 | ) >> "$OUTPUT" |
| 153 | |
| 154 | (echo |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 155 | echo "Hi," |
| 156 | echo |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 157 | echo -n "HAProxy $NEWVER was released on $DATE. It added " |
| 158 | echo -n $(git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | wc -l) |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 159 | echo " new commits" |
| 160 | echo "after version $OLD." |
| 161 | echo |
| 162 | echo "- per tag :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 163 | git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f1 -d':' | sort | uniq -c |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 164 | echo |
| 165 | echo "major commits :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 166 | git log --oneline --reverse --format=" - %s" "v$OLD".."$LASTCOM" | grep MAJOR |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 167 | echo |
| 168 | echo "- per file :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 169 | git show "v$OLD".."$LASTCOM" -- src/ | grep ^diff | awk '{ print substr($3,7)}' | sort | uniq -c | sort -nr | head -15 |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 170 | echo |
| 171 | echo "- per topic :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 172 | git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 173 | echo |
| 174 | echo "- sorted changelog :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 175 | git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | sort |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 176 | echo |
| 177 | echo "#############################################################################################" |
| 178 | ) >> "$OUTPUT" |
| 179 | |
| 180 | # report the download paths |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 181 | if [ -z "${NEWVER##*-dev*}" ]; then |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 182 | gitdir="haproxy.git" |
| 183 | else |
| 184 | gitdir="haproxy-$BRANCH.git" |
| 185 | fi |
| 186 | |
| 187 | (echo "Please find the usual URLs below :" |
| 188 | echo " Site index : http://www.haproxy.org/" |
| 189 | echo " Discourse : http://discourse.haproxy.org/" |
Willy Tarreau | d6cad12 | 2018-12-19 18:59:51 +0100 | [diff] [blame] | 190 | echo " Slack channel : https://slack.haproxy.org/" |
Willy Tarreau | 9589c3b | 2019-01-29 06:51:16 +0100 | [diff] [blame] | 191 | echo " Issue tracker : https://github.com/haproxy/haproxy/issues" |
Willy Tarreau | be789df | 2020-07-30 17:41:42 +0200 | [diff] [blame] | 192 | echo " Wiki : https://github.com/haproxy/wiki/wiki" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 193 | echo " Sources : http://www.haproxy.org/download/${BRANCH}/src/" |
| 194 | echo " Git repository : http://git.haproxy.org/git/${gitdir}/" |
| 195 | echo " Git Web browsing : http://git.haproxy.org/?p=${gitdir}" |
| 196 | echo " Changelog : http://www.haproxy.org/download/${BRANCH}/src/CHANGELOG" |
| 197 | echo " Cyril's HTML doc : http://cbonte.github.io/haproxy-dconv/" |
| 198 | ) >> "$OUTPUT" |
| 199 | |
| 200 | # sign |
| 201 | (echo |
| 202 | echo "${GIT_COMMITTER_NAME% *}" |
| 203 | ) >> "$OUTPUT" |
| 204 | |
| 205 | (echo "---" |
| 206 | echo "Complete changelog :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 207 | git shortlog "v$OLD".."$LASTCOM" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 208 | echo "---" |
| 209 | ) >> "$OUTPUT" |
| 210 | |
| 211 | |
| 212 | # prepare the HTML update |
| 213 | set -- $(date +%e -d "$DATE") |
| 214 | case "$1" in |
| 215 | 11|12|13) day="${1}th" ;; |
| 216 | *1) day="${1}st" ;; |
| 217 | *2) day="${2}nd" ;; |
| 218 | *3) day="${1}rd" ;; |
| 219 | *) day="${1}th" ;; |
| 220 | esac |
| 221 | |
| 222 | humandate=$(date "+%B, $day, %Y" -d "$DATE") |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 223 | (echo "$humandate</b> : <i>$NEWVER</i>" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 224 | echo " <p>" |
| 225 | echo " <ul>" |
| 226 | echo "<--------------------------- edit contents below --------------------------->" |
| 227 | echo "- per tag :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 228 | git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f1 -d':' | sort | uniq -c |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 229 | echo |
| 230 | echo "- per topic :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 231 | git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 232 | echo |
| 233 | echo "major commits :" |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 234 | git log --oneline --reverse --format=" - %s" "v$OLD".."$LASTCOM" | grep MAJOR |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 235 | echo |
| 236 | echo "<--------------------------------------------------------------------------->" |
| 237 | echo " Code and changelog are available <a href=\"/download/${BRANCH}/src/\">here</a> as usual." |
| 238 | echo " </ul>" |
| 239 | echo " <p>" |
| 240 | echo " <b>" |
| 241 | ) >> "$HTML" |
| 242 | |
| 243 | echo "The announce was emitted into file $OUTPUT." |
| 244 | echo "You can edit it and send it this way :" |
| 245 | echo |
Willy Tarreau | d1754b6 | 2021-01-06 15:16:46 +0100 | [diff] [blame^] | 246 | echo " mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEWVER\" haproxy@formilux.org" |
Willy Tarreau | 62b71ee | 2016-05-10 12:04:13 +0200 | [diff] [blame] | 247 | echo |
| 248 | echo "The HTML block was emitted into $HTML and needs to be finished by hand." |
| 249 | echo |