2020-02-05 03:45:18 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-05-10 10:04:13 +00:00
|
|
|
# prepares a template e-mail and HTML file to announce a new release
|
|
|
|
# Copyright (c) 2006-2016 Willy Tarreau <w@1wt.eu>
|
|
|
|
#
|
|
|
|
# In short :
|
|
|
|
# - requires git
|
|
|
|
# - wants that last commit is a release/tag
|
|
|
|
# - no restriction to master, uses last tag
|
|
|
|
# - creates mail-$version.txt
|
|
|
|
# - creates web-$version.html
|
|
|
|
# - indicates how to edit the mail and how to send it
|
|
|
|
|
2021-01-06 14:46:33 +00:00
|
|
|
USAGE="Usage: ${0##*/} [-f] [-p] [-b branch] [-d date] [-o oldver] [-n newver]
|
2021-01-06 14:16:46 +00:00
|
|
|
-f: force to overwrite existing files and ignore local changes
|
2021-01-08 04:36:27 +00:00
|
|
|
-p: prepare future release (skip branch and tags existence checks)
|
2021-01-06 14:16:46 +00:00
|
|
|
-b: force the project branch name to this (def: inherited from the version)
|
|
|
|
-d: force the release date (e.g. to rework a failed announce)
|
|
|
|
-o: previous version (def: newver-1)
|
|
|
|
-n: new version (if not last tag)
|
|
|
|
"
|
|
|
|
PREPARE=
|
2020-02-07 07:11:45 +00:00
|
|
|
FORCE=
|
2016-05-10 10:04:13 +00:00
|
|
|
OUTPUT=
|
|
|
|
BRANCH=
|
|
|
|
HTML=
|
|
|
|
DATE=
|
|
|
|
YEAR=
|
|
|
|
OLD=
|
2021-01-06 14:16:46 +00:00
|
|
|
LASTCOM=
|
|
|
|
NEWVER=
|
|
|
|
NEWTAG=
|
2016-05-10 10:04:13 +00:00
|
|
|
DIR=
|
|
|
|
|
|
|
|
die() {
|
|
|
|
[ "$#" -eq 0 ] || echo "$*" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
err() {
|
|
|
|
echo "$*" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
quit() {
|
|
|
|
[ "$#" -eq 0 ] || echo "$*"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
while [ -n "$1" -a -z "${1##-*}" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-d) DATE="$2" ; shift 2 ;;
|
|
|
|
-b) BRANCH="$2" ; shift 2 ;;
|
2020-02-07 07:11:45 +00:00
|
|
|
-f) FORCE=1 ; shift ;;
|
2021-01-06 14:46:33 +00:00
|
|
|
-p) PREPARE=1 ; shift ;;
|
2016-05-10 10:04:13 +00:00
|
|
|
-o) OLD="$2" ; shift 2 ;;
|
2021-01-06 14:16:46 +00:00
|
|
|
-n) NEWVER="$2" ; shift 2 ;;
|
2016-05-10 10:04:13 +00:00
|
|
|
-h|--help) quit "$USAGE" ;;
|
|
|
|
*) die "$USAGE" ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
die "$USAGE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! git rev-parse --verify -q HEAD >/dev/null; then
|
|
|
|
die "Failed to check git HEAD."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we want to go to the git root dir
|
|
|
|
DIR="$PWD"
|
|
|
|
cd $(git rev-parse --show-toplevel)
|
|
|
|
|
2021-01-06 14:16:46 +00:00
|
|
|
if [ -z "$FORCE" -a "$(git diff HEAD|wc -c)" != 0 ]; then
|
|
|
|
err "You appear to have uncommitted local changes, please commit them first :"
|
|
|
|
git status -s -uno >&2
|
|
|
|
die
|
|
|
|
fi
|
|
|
|
|
2021-01-06 14:46:33 +00:00
|
|
|
if [ -z "$PREPARE" -a "$(git rev-parse --verify -q HEAD)" != "$(git rev-parse --verify -q master)" ]; then
|
2016-05-10 10:04:13 +00:00
|
|
|
die "git HEAD doesn't match master branch."
|
|
|
|
fi
|
|
|
|
|
2021-01-06 14:16:46 +00:00
|
|
|
if [ -n "$NEWVER" ]; then
|
|
|
|
if git show-ref --tags "v$NEWVER" >/dev/null; then
|
|
|
|
NEWTAG="v$NEWVER"
|
|
|
|
else
|
|
|
|
echo "Note: no matching tag v$NEWVER, using HEAD".
|
|
|
|
fi
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
2021-01-06 14:16:46 +00:00
|
|
|
# version unspecified or no existing tag for it
|
|
|
|
if [ -z "$NEWTAG" ]; then
|
|
|
|
NEWTAG="$(git describe --tags HEAD --abbrev=0)"
|
|
|
|
|
|
|
|
if [ -z "$NEWTAG" ]; then
|
2016-05-10 10:04:13 +00:00
|
|
|
die "Fatal: cannot determine new version, please specify it."
|
2021-01-06 14:46:33 +00:00
|
|
|
elif [ -n "$PREPARE" ] && ! git show-ref --tags HEAD >/dev/null; then
|
|
|
|
# HEAD not tagged, hence we have to pretend we're on one version
|
|
|
|
# after the current tag
|
|
|
|
echo "Current version not tagged, trying to determine next one."
|
|
|
|
NEWTAG="${NEWTAG#v}"
|
|
|
|
if [ -z "$OLD" ]; then
|
|
|
|
OLD="$NEWTAG"
|
|
|
|
fi
|
|
|
|
radix="$NEWTAG"
|
|
|
|
while [ -n "$radix" -a -z "${radix%%*[0-9]}" ]; do
|
|
|
|
radix="${radix%[0-9]}"
|
|
|
|
done
|
|
|
|
|
|
|
|
number=${NEWTAG#$radix}
|
|
|
|
if [ -z "$number" -o "$radix" = "$NEWTAG" ]; then
|
|
|
|
die "Fatal: cannot determine new version, please specify it."
|
|
|
|
fi
|
|
|
|
NEWTAG="${radix}$((number+1))"
|
|
|
|
if [ -z "$NEWVER" ]; then
|
|
|
|
NEWVER="${NEWTAG}"
|
|
|
|
fi
|
|
|
|
NEWTAG="v$NEWTAG"
|
|
|
|
LASTCOM="$(git rev-parse --short HEAD)"
|
|
|
|
echo "Next version expected to be $NEWVER and next tag $NEWTAG based on commit $LASTCOM"
|
2021-01-06 14:16:46 +00:00
|
|
|
elif [ "$(git describe --tags HEAD)" != "$NEWTAG" ]; then
|
|
|
|
die "About to use current HEAD which doesn't seem tagged, it reports '$(git describe --tags HEAD 2>/dev/null)'. Did you release it ?"
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
2021-01-06 14:16:46 +00:00
|
|
|
elif ! git show-ref --tags "$NEWTAG" >/dev/null 2>&1; then
|
|
|
|
die "git tag $NEWTAG doesn't exist, did you create the release ?"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$NEWVER" ]; then
|
|
|
|
NEWVER="${NEWTAG#v}"
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
2021-01-06 14:16:46 +00:00
|
|
|
if [ -z "$LASTCOM" ]; then
|
|
|
|
LASTCOM="$(git rev-parse --short ${NEWTAG}^)"
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$OLD" ]; then
|
2021-01-06 14:16:46 +00:00
|
|
|
OLD="$(git describe --tags ${LASTCOM} --abbrev=0)"
|
2016-05-10 10:04:13 +00:00
|
|
|
OLD="${OLD#v}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! git rev-parse --verify -q "v$OLD" >/dev/null; then
|
|
|
|
die "git tag v$OLD doesn't exist."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# determine the product branch from the new release
|
|
|
|
if [ -z "$BRANCH" ]; then
|
2021-01-06 14:16:46 +00:00
|
|
|
subvers=${NEWVER#[0-9]*.[0-9]*[-.]*[0-9].}
|
|
|
|
[ "${subvers}" = "${NEWVER}" ] && subvers=""
|
|
|
|
major=${NEWVER%.$subvers}
|
2016-05-10 10:04:13 +00:00
|
|
|
branch_ext=${major#*[0-9].*[0-9]}
|
|
|
|
BRANCH=${major%${branch_ext}}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# determine the release date
|
|
|
|
if [ -z "$DATE" ]; then
|
2021-01-06 14:16:46 +00:00
|
|
|
DATE="$(git log -1 --pretty=fuller ${NEWTAG} 2>/dev/null | sed -ne '/^CommitDate:/{s/\(^[^ ]*:\)\|\( [-+].*\)//gp;q}')"
|
2016-05-10 10:04:13 +00:00
|
|
|
DATE="$(date +%Y/%m/%d -d "$DATE")"
|
|
|
|
fi
|
|
|
|
YEAR="${DATE%%/*}"
|
|
|
|
|
2021-01-06 14:16:46 +00:00
|
|
|
OUTPUT="$DIR/mail-haproxy-$NEWVER.txt"
|
|
|
|
HTML="$DIR/web-haproxy-$NEWVER.html"
|
2020-02-07 07:11:45 +00:00
|
|
|
|
|
|
|
[ -z "$FORCE" ] || rm -f "${OUTPUT}" "${HTML}"
|
|
|
|
|
2016-05-10 10:04:13 +00:00
|
|
|
if [ -e "$OUTPUT" ]; then
|
2020-02-07 07:11:45 +00:00
|
|
|
die "${OUTPUT##*/} already exists, please remove it or retry with -f."
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e "$HTML" ]; then
|
2020-02-07 07:11:45 +00:00
|
|
|
die "$HTML already exists, please remove it or retry with -f."
|
2016-05-10 10:04:13 +00:00
|
|
|
fi
|
|
|
|
|
2020-02-07 07:10:06 +00:00
|
|
|
(
|
|
|
|
echo "# Send this using:"
|
2021-01-06 14:16:46 +00:00
|
|
|
echo "# mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEWVER\" haproxy@formilux.org"
|
2020-02-07 07:10:06 +00:00
|
|
|
) >> "$OUTPUT"
|
|
|
|
|
|
|
|
(echo
|
2016-05-10 10:04:13 +00:00
|
|
|
echo "Hi,"
|
|
|
|
echo
|
2021-01-06 14:16:46 +00:00
|
|
|
echo -n "HAProxy $NEWVER was released on $DATE. It added "
|
|
|
|
echo -n $(git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | wc -l)
|
2016-05-10 10:04:13 +00:00
|
|
|
echo " new commits"
|
|
|
|
echo "after version $OLD."
|
|
|
|
echo
|
|
|
|
echo "- per tag :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f1 -d':' | sort | uniq -c
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "major commits :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format=" - %s" "v$OLD".."$LASTCOM" | grep MAJOR
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "- per file :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git show "v$OLD".."$LASTCOM" -- src/ | grep ^diff | awk '{ print substr($3,7)}' | sort | uniq -c | sort -nr | head -15
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "- per topic :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "- sorted changelog :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | sort
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "#############################################################################################"
|
|
|
|
) >> "$OUTPUT"
|
|
|
|
|
|
|
|
# report the download paths
|
2021-01-06 14:16:46 +00:00
|
|
|
if [ -z "${NEWVER##*-dev*}" ]; then
|
2016-05-10 10:04:13 +00:00
|
|
|
gitdir="haproxy.git"
|
|
|
|
else
|
|
|
|
gitdir="haproxy-$BRANCH.git"
|
|
|
|
fi
|
|
|
|
|
|
|
|
(echo "Please find the usual URLs below :"
|
|
|
|
echo " Site index : http://www.haproxy.org/"
|
2022-04-16 05:57:15 +00:00
|
|
|
echo " Documentation : http://docs.haproxy.org/"
|
|
|
|
echo " Wiki : https://github.com/haproxy/wiki/wiki"
|
2016-05-10 10:04:13 +00:00
|
|
|
echo " Discourse : http://discourse.haproxy.org/"
|
2018-12-19 17:59:51 +00:00
|
|
|
echo " Slack channel : https://slack.haproxy.org/"
|
2019-01-29 05:51:16 +00:00
|
|
|
echo " Issue tracker : https://github.com/haproxy/haproxy/issues"
|
2016-05-10 10:04:13 +00:00
|
|
|
echo " Sources : http://www.haproxy.org/download/${BRANCH}/src/"
|
|
|
|
echo " Git repository : http://git.haproxy.org/git/${gitdir}/"
|
|
|
|
echo " Git Web browsing : http://git.haproxy.org/?p=${gitdir}"
|
|
|
|
echo " Changelog : http://www.haproxy.org/download/${BRANCH}/src/CHANGELOG"
|
2022-04-16 10:06:07 +00:00
|
|
|
echo " Pending bugs : http://www.haproxy.org/l/pending-bugs"
|
|
|
|
echo " Reviewed bugs : http://www.haproxy.org/l/reviewed-bugs"
|
|
|
|
echo " Code reports : http://www.haproxy.org/l/code-reports"
|
2016-05-10 10:04:13 +00:00
|
|
|
) >> "$OUTPUT"
|
|
|
|
|
|
|
|
# sign
|
|
|
|
(echo
|
|
|
|
echo "${GIT_COMMITTER_NAME% *}"
|
|
|
|
) >> "$OUTPUT"
|
|
|
|
|
|
|
|
(echo "---"
|
|
|
|
echo "Complete changelog :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git shortlog "v$OLD".."$LASTCOM"
|
2016-05-10 10:04:13 +00:00
|
|
|
echo "---"
|
|
|
|
) >> "$OUTPUT"
|
|
|
|
|
|
|
|
|
|
|
|
# prepare the HTML update
|
|
|
|
set -- $(date +%e -d "$DATE")
|
|
|
|
case "$1" in
|
|
|
|
11|12|13) day="${1}th" ;;
|
|
|
|
*1) day="${1}st" ;;
|
|
|
|
*2) day="${2}nd" ;;
|
|
|
|
*3) day="${1}rd" ;;
|
|
|
|
*) day="${1}th" ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
humandate=$(date "+%B, $day, %Y" -d "$DATE")
|
2021-01-06 14:16:46 +00:00
|
|
|
(echo "$humandate</b> : <i>$NEWVER</i>"
|
2016-05-10 10:04:13 +00:00
|
|
|
echo " <p>"
|
|
|
|
echo " <ul>"
|
|
|
|
echo "<--------------------------- edit contents below --------------------------->"
|
|
|
|
echo "- per tag :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f1 -d':' | sort | uniq -c
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "- per topic :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format="%s" "v$OLD".."$LASTCOM" | cut -f2 -d':' | awk '{sub("s$","",$1); print $1}' | sort | uniq -c
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "major commits :"
|
2021-01-06 14:16:46 +00:00
|
|
|
git log --oneline --reverse --format=" - %s" "v$OLD".."$LASTCOM" | grep MAJOR
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "<--------------------------------------------------------------------------->"
|
|
|
|
echo " Code and changelog are available <a href=\"/download/${BRANCH}/src/\">here</a> as usual."
|
|
|
|
echo " </ul>"
|
|
|
|
echo " <p>"
|
|
|
|
echo " <b>"
|
|
|
|
) >> "$HTML"
|
|
|
|
|
|
|
|
echo "The announce was emitted into file $OUTPUT."
|
|
|
|
echo "You can edit it and send it this way :"
|
|
|
|
echo
|
2021-01-06 14:16:46 +00:00
|
|
|
echo " mutt -H <(tail -n +4 ${OUTPUT##*/}) -s \"[ANNOUNCE] haproxy-$NEWVER\" haproxy@formilux.org"
|
2016-05-10 10:04:13 +00:00
|
|
|
echo
|
|
|
|
echo "The HTML block was emitted into $HTML and needs to be finished by hand."
|
|
|
|
echo
|