Mailing list header changes (fuck you Google)
[citadel.git] / do-release.sh
1 #!/bin/bash
2
3 # Find the highest version number used in any component, increment it by one, and update
4 # all components to use the new version number.  Then generate a commit and a tag.
5
6 echo -e '\033[2J\033[H'
7 echo -e '\033[34m\033[1m'
8 echo -e '╔════════════════════════════════════════╗'
9 echo -e '║      PIPELINE-O-MATIC FOR CITADEL      ║'
10 echo -e '╚════════════════════════════════════════╝'
11 echo -e '\033[0m'
12
13 libcitadel_version=`grep LIBCITADEL_VERSION_NUMBER  libcitadel/lib/libcitadel.h | sed s/"[^0-9.]"/""/g`
14 citserver_version=`grep REV_LEVEL citadel/server/citadel_defs.h | sed s/"[^0-9.]"/""/g`
15 webcit_version=`grep CLIENT_VERSION webcit/webcit.h | sed s/"[^0-9.]"/""/g`
16 textclient_version=`grep CLIENT_VERSION textclient/textclient.h | sed s/"[^0-9.]"/""/g`
17
18 NEW_VERSION=${libcitadel_version}
19 if [ ${citserver_version} -gt ${NEW_VERSION} ] ; then
20         NEW_VERSION=${citserver_version}
21 fi
22 if [ ${webcit_version} -gt ${NEW_VERSION} ] ; then
23         NEW_VERSION=${webcit_version}
24 fi
25 if [ ${textclient_version} -gt ${NEW_VERSION} ] ; then
26         NEW_VERSION=${textclient_version}
27 fi
28 NEW_VERSION=`expr ${NEW_VERSION} + 1`
29
30 echo -e '\033[33m\033[1mlibcitadel \033[32m was version     \033[33m'$libcitadel_version'\033[0m'
31 echo -e '\033[33m\033[1mcitserver  \033[32m was version     \033[33m'$citserver_version'\033[0m'
32 echo -e '\033[33m\033[1mwebcit     \033[32m was version     \033[33m'$webcit_version'\033[0m'
33 echo -e '\033[33m\033[1mtextclient \033[32m was version     \033[33m'$textclient_version'\033[0m'
34 echo -e '\033[33m\033[1mnew release\033[32m will be version \033[33m'$NEW_VERSION'\033[0m'
35 echo -e ''
36 #echo -e '\033[41m\033[37m\033[1m THIS WILL INITIATE THE RELEASE PIPELINE. \033[0m'
37 echo -n 'Proceed (y/n) ? '
38 read x
39
40 if echo ${x} | egrep -i '^y' ; then
41         echo -e ''
42         echo -e '\033[37m\033[1mUpdating header files to reflect the new version number\033[0m'
43         echo -e ''
44 else
45         echo 'Exiting'
46         exit 0
47 fi
48
49 # Edit libcitadel.h to make it the new version
50 sed \
51         -i s/\#define.\*LIBCITADEL_VERSION_NUMBER.\*${libcitadel_version}/\#define\ LIBCITADEL_VERSION_NUMBER\ ${NEW_VERSION}/g \
52         libcitadel/lib/libcitadel.h
53
54 # Edit citadel.h to make it the new version
55 sed \
56         -i s/\#define.\*REV_LEVEL.\*${citserver_version}/\#define\ REV_LEVEL\ ${NEW_VERSION}/g \
57         citadel/server/citadel_defs.h
58
59 # Edit webcit.h to make it the new version
60 sed \
61         -i s/\#define.\*CLIENT_VERSION.\*${webcit_version}/\#define\ CLIENT_VERSION\ ${NEW_VERSION}/g \
62         webcit/webcit.h
63
64 # Edit textclient.h to make it the new version
65 sed \
66         -i s/\#define.\*CLIENT_VERSION.\*${textclient_version}/\#define\ CLIENT_VERSION\ ${NEW_VERSION}/g \
67         textclient/textclient.h
68
69 libcitadel_version=`grep LIBCITADEL_VERSION_NUMBER  libcitadel/lib/libcitadel.h | sed s/"[^0-9.]"/""/g`
70 citserver_version=`grep REV_LEVEL citadel/server/citadel_defs.h | sed s/"[^0-9.]"/""/g`
71 webcit_version=`grep CLIENT_VERSION webcit/webcit.h | sed s/"[^0-9.]"/""/g`
72 textclient_version=`grep CLIENT_VERSION textclient/textclient.h | sed s/"[^0-9.]"/""/g`
73
74 echo -e '\033[33m\033[1mlibcitadel \033[32m is now version  \033[33m'$libcitadel_version'\033[0m'
75 echo -e '\033[33m\033[1mcitserver  \033[32m is now version  \033[33m'$citserver_version'\033[0m'
76 echo -e '\033[33m\033[1mwebcit     \033[32m is now version  \033[33m'$webcit_version'\033[0m'
77 echo -e '\033[33m\033[1mtextclient \033[32m is now version  \033[33m'$textclient_version'\033[0m'
78
79 echo $NEW_VERSION >release_version.txt
80 git add release_version.txt
81 echo -e ''
82 echo -e '\033[37m\033[1mUpdating release_version.txt to indicate version '${NEW_VERSION}'\033[0m'
83 echo -e '\033[37m\033[1mGenerating a commit\033[0m'
84 echo -e ''
85 git commit -a -m "Release version ${NEW_VERSION} generated by do-release.sh"
86 git tag -a v${NEW_VERSION} -m "Version ${NEW_VERSION} release"
87
88 echo -n 'git push...'
89 git push
90 echo
91
92 echo -n 'git push --tags...'
93 git push --tags
94 echo
95
96 echo -e ''
97 echo -e '\033[37mFinished.\033[0m'
98 echo -e ''
99