aerc/contrib/release.sh
Robin Jarry df1a0fff33 contrib: add git-stats.sh
git shortlog -sn is nice but it does not display the number of changed
files and the amount of changed lines.

  $ git shortlog -sn 0.12.0..
      46  Tim Culverhouse
      28  Robin Jarry
      14  Koni Marti
       9  Moritz Poldrack
       2  Ben Cohen
       2  Bence Ferdinandy
       2  Julian Pidancet
       2  inwit
       1  Jason Cox
       1  Jason Stewart
       1  John Gebbie
       1  Tobias Wölfel
       1  kt programs

Add a simple bash script that adds extra information:

  $ ./contrib/git-stats.sh 0.12.0..
  Author            Commits  Changed Files  Insertions  Deletions
  Tim Culverhouse        46            134        +973      -1090
  Robin Jarry            28             70        +671       -358
  Koni Marti             14             47        +437       -205
  Moritz Poldrack         9             18        +178        -44
  Ben Cohen               2              2         +16         -2
  Bence Ferdinandy        2              6        +104         +0
  Julian Pidancet         2              9        +149         -2
  inwit                   2              3         +11         -1
  Jason Cox               1              7        +106         -6
  Jason Stewart           1              1          +4         -2
  John Gebbie             1              3        +118         -1
  Tobias Wölfel           1              3          +3         -3
  kt programs             1              3         +37         -6

Use the script to generate the release tag and email.

Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-on-irc-by: Tim Culverhouse <tim@timculverhouse.com>
2022-10-20 00:29:16 +02:00

60 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
set -e
echo "======= Determining next version..."
prev_tag=$(git describe --tags --abbrev=0)
next_tag=$(echo $prev_tag | awk -F. -v OFS=. '{$(NF-1) += 1; print}')
read -rp "next tag ($next_tag)? " n
if [ -n "$n" ]; then
next_tag="$n"
fi
tag_url="https://git.sr.ht/~rjarry/aerc/refs/$next_tag"
echo "======= Creating release commit..."
sed -i Makefile -e "s/$prev_tag/$next_tag/g"
sed -i CHANGELOG.md -e "s|^## \[Unreleased\].*|&\n\n## [$next_tag]($tag_url) - $(date +%Y-%m-%d)|"
git add Makefile CHANGELOG.md
git commit -sm "Release version $next_tag"
echo "======= Creating tag..."
changes=$(sed -n "/^## \[$next_tag\].*/,/^## \[$prev_tag\].*/{//!p;}" \
CHANGELOG.md | sed '1d;$d;s/^#\+/#/' )
git -c core.commentchar='%' tag --edit --sign \
-m "Release $next_tag highlights:" \
-m "$changes" \
-m "Thanks to all contributors!" \
-m "~\$ contrib/git-stats.sh $prev_tag..$next_tag
$(contrib/git-stats.sh $prev_tag..)" \
"$next_tag"
echo "======= Pushing to remote..."
git push origin master "$next_tag"
echo "======= Sending release email..."
email=$(mktemp aerc-release-XXXXXXXX.eml)
trap "rm -f -- $email" EXIT
cat >"$email" <<EOF
To: aerc-annouce <~rjarry/aerc-announce@lists.sr.ht>
Cc: aerc-devel <~rjarry/aerc-devel@lists.sr.ht>
Bcc: aerc <~sircmpwn/aerc@lists.sr.ht>,
$(git config user.name) <$(git config user.email)>
Reply-To: aerc-devel <~rjarry/aerc-devel@lists.sr.ht>
Subject: aerc $next_tag
User-Agent: aerc/$next_tag
Message-ID: <$(date +%Y%m%d%H%M%S).$(base32 -w12 < /dev/urandom | head -n1)@$(hostname)>
Hi all,
I am glad to announce the release of aerc $next_tag.
$tag_url
$(git tag -l --format='%(contents)' "$next_tag" | sed -n '/BEGIN PGP SIGNATURE/q;p')
EOF
${EDITOR:-vi} "$email"
/usr/sbin/sendmail -t < "$email"