Merge branch 'master' of ssh://trebb@git.berlios.de/gitroot/monikop
[monikop.git] / doc / tag-and-release.sh
blobd9b7a301ed59bb9d00af14f70a63581f2be1197e
1 #! /bin/bash
3 # Make a new git tag and upload a new release.
4 ######################################################################
5 # The tag's name (a version string like `v1.2.3') and the commit
6 # message come from the topmost entry of ../NEWS. Headlines of those
7 # entries are supposed to start with `* ' and must contain the version
8 # string unquoted and surrounded by whitespace.
10 workdir=`pwd`
12 function latest_NEWS_section {
13 # Extract topmost section from NEWS.
14 sed -nr \
15 -e '/^\* .*v[0-9]+\.[0-9]+\.[0-9]+.*$/,/(^\* .*v[0-9]+\.[0-9]+\.[0-9]+.*$)|(^; .*$)/{H}' \
16 -e '${g; s/(\n\* .*v[0-9]+\.[0-9]+\.[0-9]+.*$)|(\n; .*$)//m2; s/^\n//m1; p}' \
17 $workdir/../NEWS
20 function latest_version_number {
21 # Extract version string from topmost headline in NEWS.
22 latest_NEWS_section | \
23 grep -Eom 1 -e 'v[0-9]+\.[0-9]+\.[0-9]+'
26 function naked_version_number {
27 # Version string without the leading `v'.
28 version=`latest_version_number`
29 echo ${version#v}
32 # program_version_number <program_file>
33 function program_version_number {
34 grep -Em 1 -e '\$version *=.*v[0-9]+\.[0-9]+\.?[0-9]*.*;' $1 | \
35 grep -Eom 1 -e 'v[0-9]+\.[0-9]+\.?[0-9]*'
38 echo "Tagging `latest_version_number`"
40 if [[ -n `git-diff` ]]; then
41 echo "We have uncommitted changes."
42 git-status
43 echo "Aborting."
44 exit
45 fi;
47 if [[ `program_version_number ../monikop` != `latest_version_number` ]]; then
48 echo "Version number mismatch between monikop and NEWS. Aborting."
49 exit
50 elif [[ `program_version_number ../pokinom` != `latest_version_number` ]]; then
51 echo "Version number mismatch between pokinom and NEWS. Aborting."
52 exit
55 if ! git-tag -a -m "`latest_NEWS_section`" `latest_version_number`; then
56 echo "Setting tag `latest_version_number` failed. But maybe things are already in place."
57 else
58 echo "Tagging `latest_version_number` successful."
61 if [[ `git-describe $(latest_version_number)` != `latest_version_number` ]]; then
62 echo "Tag `latest_version_number` missing. Aborting."
63 exit
66 echo "Writing archive ../monikop-`naked_version_number`.tar.gz."
67 if ! (
68 cd ..
69 git-archive \
70 --format=tar \
71 --prefix=monikop-`naked_version_number`/ `latest_version_number` | \
72 gzip > monikop-`naked_version_number`.tar.gz
74 then
75 echo "Unsuccessful. Aborting."
76 exit
79 echo "Writing instruct-ohloh-`naked_version_number`.xml."
80 if ! cat > instruct-ohloh-`naked_version_number`.xml <<EOF
81 <packages>
82 <package name="Monikop">
83 <releases>
84 <release name="`latest_version_number`">
85 <files>
86 <file name="monikop-`naked_version_number`.tar.gz"/>
87 </files>
88 </release>
89 </releases>
90 </package>
91 </packages>
92 EOF
93 then
94 echo "Unsuccessful. Aborting."
95 exit
98 echo "Uploading to upload.ohloh.net."
99 scp ../monikop-`naked_version_number`.tar.gz trebb@upload.ohloh.net:monikop/files &&
100 scp instruct-ohloh-`naked_version_number`.xml trebb@upload.ohloh.net:monikop/instructs
102 exit