[bc308eb] | 1 | #!/bin/bash |
---|
| 2 | set -eu |
---|
[5319565] | 3 | |
---|
| 4 | die() { |
---|
| 5 | echo "$@" >&2 |
---|
| 6 | exit 1 |
---|
| 7 | } |
---|
| 8 | |
---|
[51dbfb5] | 9 | usage() { |
---|
| 10 | cat >&2 <<EOF |
---|
[afaef6e] | 11 | Usage: $0 [options] |
---|
[b8a3e00] | 12 | Generate a BarnOwl release tarball. |
---|
[51dbfb5] | 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 | |
---|
[b9df757] | 21 | force= |
---|
[168f8a9] | 22 | no_tag= |
---|
[01846ce] | 23 | git= |
---|
[b9df757] | 24 | |
---|
[168f8a9] | 25 | for arg; do |
---|
| 26 | case $arg in |
---|
| 27 | -f) force=1 ;; |
---|
| 28 | --no-tag) no_tag=1 ;; |
---|
[01846ce] | 29 | --git) git=1 ;; |
---|
[51dbfb5] | 30 | -h|--help) usage ;; |
---|
[168f8a9] | 31 | esac |
---|
| 32 | done |
---|
[b9df757] | 33 | |
---|
[01846ce] | 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) \ |
---|
[b8a3e00] | 40 | || die "Unable to parse BarnOwl version" |
---|
[01846ce] | 41 | fi |
---|
[5319565] | 42 | TAG=barnowl-$VERS |
---|
| 43 | TGZ="$TAG-src" |
---|
| 44 | |
---|
[b9df757] | 45 | if [ ! "$force" ] && [ "$VERS" != "$(head -1 ChangeLog)" ]; then |
---|
[bff8f9f] | 46 | die "No ChangeLog entry for version $VERS, aborting." |
---|
| 47 | fi |
---|
| 48 | |
---|
[d771d1b] | 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 | |
---|
[bc308eb] | 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 | |
---|
[168f8a9] | 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 |
---|
[5319565] | 81 | fi |
---|
| 82 | |
---|
[bc308eb] | 83 | echo "Created release tarball for BarnOwl $VERS at $(pwd)/$TGZ.tgz" |
---|
[5319565] | 84 | echo "Remember to bump OWL_VERSION_STRING for future development." |
---|
[11b9017] | 85 | |
---|
| 86 | COMMIT=$(git rev-parse "$TAG") |
---|
| 87 | NOW=$(date +"%B %d, %Y") |
---|
| 88 | cat <<EOF |
---|
[74312ad] | 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]. |
---|
[11b9017] | 90 | EOF |
---|