| 1 |
#!/bin/bash |
| 2 |
set -eu |
| 3 |
|
| 4 |
die() { |
| 5 |
echo "$@" >&2 |
| 6 |
exit 1 |
| 7 |
} |
| 8 |
|
| 9 |
usage() { |
| 10 |
cat >&2 <<EOF |
| 11 |
Usage: $0 [options] |
| 12 |
Generate a BarnOwl release tarball. |
| 13 |
|
| 14 |
OPTIONS: |
| 15 |
-f Don't require a changelog entry for the new release. |
| 16 |
--no-tag Don't create and sign a git tag for the new release |
| 17 |
--git Do a beta release for the current git revision. |
| 18 |
EOF |
| 19 |
} |
| 20 |
|
| 21 |
force= |
| 22 |
no_tag= |
| 23 |
git= |
| 24 |
|
| 25 |
for arg; do |
| 26 |
case $arg in |
| 27 |
-f) force=1 ;; |
| 28 |
--no-tag) no_tag=1 ;; |
| 29 |
--git) git=1 ;; |
| 30 |
-h|--help) usage ;; |
| 31 |
esac |
| 32 |
done |
| 33 |
|
| 34 |
if [ "$git" ]; then |
| 35 |
force=1 |
| 36 |
no_tag=1 |
| 37 |
VERS=$(git describe --match='barnowl-*' HEAD | sed s,^barnowl-,,) |
| 38 |
else |
| 39 |
VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac) \ |
| 40 |
|| die "Unable to parse BarnOwl version" |
| 41 |
fi |
| 42 |
TAG=barnowl-$VERS |
| 43 |
TGZ="$TAG-src" |
| 44 |
|
| 45 |
if [ ! "$force" ] && [ "$VERS" != "$(head -1 ChangeLog)" ]; then |
| 46 |
die "No ChangeLog entry for version $VERS, aborting." |
| 47 |
fi |
| 48 |
|
| 49 |
head=$(git symbolic-ref HEAD) |
| 50 |
head=${head#refs/heads/} |
| 51 |
|
| 52 |
git rev-parse --verify -q $head >/dev/null 2>&1 |
| 53 |
git rev-parse --verify -q origin/$head >/dev/null 2>&1 |
| 54 |
if [ -n "$(git rev-list $head..origin/$head)" ]; then |
| 55 |
die "$head is not up to date. Aborting." |
| 56 |
fi |
| 57 |
|
| 58 |
[ -e Makefile.in ] || autoreconf -fvi |
| 59 |
[ -e config.status ] || ./configure |
| 60 |
make -j4 distcheck VERSION="$VERS" |
| 61 |
|
| 62 |
echo 'Checking distributed files against Git:' |
| 63 |
if comm -3 <(tar -tzf "$TAG.tar.gz" | grep -v '/$' | sed "s%^$TAG/%%" | sort) \ |
| 64 |
<(git ls-files | sort) | grep -vxf scripts/dist-ignore; then |
| 65 |
echo |
| 66 |
echo 'Error: Please fix Makefile.am and/or scripts/dist-ignore.' |
| 67 |
exit 1 |
| 68 |
fi |
| 69 |
echo 'ok' |
| 70 |
|
| 71 |
mv "$TAG.tar.gz" "$TGZ.tgz" |
| 72 |
|
| 73 |
if ! [ "$no_tag" ]; then |
| 74 |
if git cat-file -t "$TAG" > /dev/null 2>&1; then |
| 75 |
die "Error: Object $TAG already exists." |
| 76 |
fi |
| 77 |
|
| 78 |
git tag -s -m "BarnOwl $VERS" "$TAG" |
| 79 |
else |
| 80 |
TAG=HEAD |
| 81 |
fi |
| 82 |
|
| 83 |
echo "Created release tarball for BarnOwl $VERS at $(pwd)/$TGZ.tgz" |
| 84 |
echo "Remember to bump OWL_VERSION_STRING for future development." |
| 85 |
|
| 86 |
COMMIT=$(git rev-parse "$TAG") |
| 87 |
NOW=$(date +"%B %d, %Y") |
| 88 |
cat <<EOF |
| 89 |
* '''$NOW''': BarnOwl $VERS released. [wiki:Download] it here, or read the [wiki:release-notes/$VERS release notes] or [/browser/ChangeLog?rev=barnowl-$VERS ChangeLog]. |
| 90 |
EOF |