[5319565] | 1 | #!/bin/sh -e |
---|
| 2 | |
---|
| 3 | die() { |
---|
| 4 | echo "$@" >&2 |
---|
| 5 | exit 1 |
---|
| 6 | } |
---|
| 7 | |
---|
[51dbfb5] | 8 | usage() { |
---|
| 9 | cat >&2 <<EOF |
---|
[afaef6e] | 10 | Usage: $0 [options] |
---|
[b8a3e00] | 11 | Generate a BarnOwl release tarball. |
---|
[51dbfb5] | 12 | |
---|
| 13 | OPTIONS: |
---|
| 14 | -f Don't require a changelog entry for the new release. |
---|
| 15 | --no-tag Don't create and sign a git tag for the new release |
---|
| 16 | --git Do a beta release for the current git revision. |
---|
| 17 | EOF |
---|
| 18 | } |
---|
| 19 | |
---|
[b9df757] | 20 | force= |
---|
[168f8a9] | 21 | no_tag= |
---|
[01846ce] | 22 | git= |
---|
[b9df757] | 23 | |
---|
[168f8a9] | 24 | for arg; do |
---|
| 25 | case $arg in |
---|
| 26 | -f) force=1 ;; |
---|
| 27 | --no-tag) no_tag=1 ;; |
---|
[01846ce] | 28 | --git) git=1 ;; |
---|
[51dbfb5] | 29 | -h|--help) usage ;; |
---|
[168f8a9] | 30 | esac |
---|
| 31 | done |
---|
[b9df757] | 32 | |
---|
[01846ce] | 33 | if [ "$git" ]; then |
---|
| 34 | force=1 |
---|
| 35 | no_tag=1 |
---|
| 36 | VERS=$(git describe --match='barnowl-*' HEAD | sed s,^barnowl-,,) |
---|
| 37 | else |
---|
| 38 | VERS=$(perl -ne 'print $1 if m{^AC_INIT\(\[[^\]]+\],\s*\[([^\]]+)\]}' configure.ac) \ |
---|
[b8a3e00] | 39 | || die "Unable to parse BarnOwl version" |
---|
[01846ce] | 40 | fi |
---|
[5319565] | 41 | TAG=barnowl-$VERS |
---|
| 42 | TGZ="$TAG-src" |
---|
| 43 | |
---|
[b9df757] | 44 | if [ ! "$force" ] && [ "$VERS" != "$(head -1 ChangeLog)" ]; then |
---|
[bff8f9f] | 45 | die "No ChangeLog entry for version $VERS, aborting." |
---|
| 46 | fi |
---|
| 47 | |
---|
[d771d1b] | 48 | head=$(git symbolic-ref HEAD) |
---|
| 49 | head=${head#refs/heads/} |
---|
| 50 | |
---|
| 51 | git rev-parse --verify -q $head >/dev/null 2>&1 |
---|
| 52 | git rev-parse --verify -q origin/$head >/dev/null 2>&1 |
---|
| 53 | if [ -n "$(git rev-list $head..origin/$head)" ]; then |
---|
| 54 | die "$head is not up to date. Aborting." |
---|
| 55 | fi |
---|
| 56 | |
---|
[168f8a9] | 57 | if ! [ "$no_tag" ]; then |
---|
| 58 | if git cat-file -t "$TAG" > /dev/null 2>&1; then |
---|
| 59 | die "Error: Object $TAG already exists." |
---|
| 60 | fi |
---|
| 61 | |
---|
| 62 | git tag -s -m "BarnOwl $VERS" "$TAG" |
---|
| 63 | else |
---|
| 64 | TAG=HEAD |
---|
[5319565] | 65 | fi |
---|
| 66 | |
---|
| 67 | exittrap() { :; } |
---|
| 68 | for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done |
---|
| 69 | trap 'exittrap' EXIT |
---|
| 70 | |
---|
| 71 | TMPDIR=$(mktemp -d /tmp/barnowl.XXXXXX) |
---|
| 72 | |
---|
| 73 | exittrap() { rm -rf "$TMPDIR"; } |
---|
| 74 | |
---|
| 75 | git archive --format=tar --prefix="$TGZ/" "$TAG" | tar -x -C "$TMPDIR" |
---|
| 76 | |
---|
| 77 | CODIR=$(pwd) |
---|
| 78 | cd "$TMPDIR/$TGZ" |
---|
[01846ce] | 79 | [ "$git" ] && perl -i -pe 's{^(AC_INIT\(\[[^\]]+\],\s*)\[([^\]]+)\]}{${1}['$VERS']}' configure.ac |
---|
[db98968] | 80 | autoreconf -fvi |
---|
[86f740e] | 81 | rm -r autom4te.cache/ |
---|
[5319565] | 82 | cd "$TMPDIR" |
---|
| 83 | tar czvf "$TGZ.tgz" "$TGZ" |
---|
| 84 | cd "$CODIR" |
---|
| 85 | |
---|
| 86 | mv "$TMPDIR/$TGZ.tgz" . |
---|
| 87 | rm -rf "$TMPDIR" |
---|
| 88 | |
---|
| 89 | exittrap() { :; } |
---|
| 90 | |
---|
| 91 | echo "Created release tarball for BarnOwl $VERS in $(pwd)" |
---|
| 92 | echo "Remember to bump OWL_VERSION_STRING for future development." |
---|
[11b9017] | 93 | |
---|
| 94 | COMMIT=$(git rev-parse "$TAG") |
---|
| 95 | NOW=$(date +"%B %d, %Y") |
---|
| 96 | cat <<EOF |
---|
[74312ad] | 97 | * '''$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] | 98 | EOF |
---|