#!/bin/sh

# Copyright © 2016 Jakub Wilk <jwilk@jwilk.net>
#
# This file is part of pdf2djvu.
#
# pdf2djvu is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# pdf2djvu is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

set -e -u

export LC_ALL=C

version=$(grep -m1 '^[^ ].*) [a-z]' doc/changelog | cut -d' ' -f2 | tr -d '()')

cat <<EOF
Subject: ANN: pdf2djvu $version
To: pdf2djvu@groups.io

I am pleased to announce that pdf2djvu $version has been just released.

The most important end-user visible changes are:

...

Downloads:

  * source:
    https://github.com/jwilk/pdf2djvu/releases/download/$version/pdf2djvu-$version.tar.xz

  * Windows distribution:
    https://github.com/jwilk/pdf2djvu/releases/download/$version/pdf2djvu-win32-$version.zip

  * source for the Windows distribution:
    https://github.com/jwilk/pdf2djvu/releases/download/$version/pdf2djvu-win32-source-$version.tar.xz

All files are cryptographically signed.
Append ".asc" to the URL to get the OpenPGP signature.

Complete changelog:
EOF

sed -n -e '/) [a-z]/,$p' doc/changelog \
| sed -n -e '1d; /^ --/q; p'

# vim:ts=4 sts=4 sw=4 et
