Fix insertion/ordering of refs in refs_by_id map.
[tig.git] / tools / release.sh
blob3002dd88f07fe0d82415a2d412311f845e9f5fa8
1 #!/bin/sh
3 # Script for preparing a release or updating the release branch.
4 # Usage: $0 version
6 # Copyright (c) 2009-2014 Jonas Fonseca <jonas.fonseca@gmail.com>
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of
11 # the License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 set -e
19 set -x
21 VERSION="$1"
23 TAG="tig-$VERSION"
24 TITLE="$TAG\n$(echo "$TAG" | sed 's/./-/g')"
25 NEWS="NEWS.adoc"
27 # Require a clean repository.
28 git update-index --refresh
29 git diff-index --quiet HEAD
31 if test -n "$VERSION"; then
32 # Get a sane starting point.
33 test "$(git symbolic-ref HEAD)" = "refs/heads/master" ||
34 git checkout master
36 # Update files which should reference the version.
37 sed -i "s/VERSION\s*=\s*[0-9.]\+/VERSION = $VERSION/" Makefile
38 perl -pi -e 's/^master$/RELEASE_TITLE/ms' "$NEWS"
39 perl -pi -e 's/^RELEASE_TITLE.*/RELEASE_TITLE/ms' "$NEWS"
40 perl -pi -e "s/^RELEASE_TITLE.*/$TITLE/" "$NEWS"
42 # Check for typos.
43 make spell-check
45 # Last review.
46 $EDITOR "$NEWS"
48 # Create release commit and tag.
49 git commit -a -m "$TAG"
50 git tag -s -m "tig version $VERSION" "$TAG"
52 # Prepare release announcement file.
53 ./tools/announcement.sh "$TAG" > "$TAG.txt"
55 # Set version for the Makefile
56 export DIST_VERSION="$VERSION"
57 else
58 # Get meaningful version for the update message.
59 TAG="$(git describe)"
62 # Update the release branch.
63 git checkout release
64 HEAD="$(git rev-parse release)"
65 git merge master
66 if test -n "$(git rev-list -1 release ^$HEAD)"; then
67 make distclean doc-man doc-html sysconfdir=++SYSCONFDIR++
68 git commit -a -m "Update for version $TAG"
71 if test -n "$VERSION"; then
72 # Create the tarball.
73 make dist
76 # Done.
77 git checkout master