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