do-release.sh is now being turned into more of a real pipeline
[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.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
36 echo -e ''
37 echo -e '\033[37m\033[1mUpdating header files to reflect the new version number\033[0m'
38 echo -e ''
39
40 # Edit libcitadel.h to make it the new version
41 sed \
42         -i s/\#define.\*LIBCITADEL_VERSION_NUMBER.\*${libcitadel_version}/\#define\ LIBCITADEL_VERSION_NUMBER\ ${NEW_VERSION}/g \
43         libcitadel/lib/libcitadel.h
44
45 # Edit citadel.h to make it the new version
46 sed \
47         -i s/\#define.\*REV_LEVEL.\*${citserver_version}/\#define\ REV_LEVEL\ ${NEW_VERSION}/g \
48         citadel/server/citadel.h
49
50 # Edit webcit.h to make it the new version
51 sed \
52         -i s/\#define.\*CLIENT_VERSION.\*${webcit_version}/\#define\ CLIENT_VERSION\ ${NEW_VERSION}/g \
53         webcit/webcit.h
54
55 # Edit textclient.h to make it the new version
56 sed \
57         -i s/\#define.\*CLIENT_VERSION.\*${textclient_version}/\#define\ CLIENT_VERSION\ ${NEW_VERSION}/g \
58         textclient/textclient.h
59
60 libcitadel_version=`grep LIBCITADEL_VERSION_NUMBER  libcitadel/lib/libcitadel.h | sed s/"[^0-9.]"/""/g`
61 citserver_version=`grep REV_LEVEL citadel/server/citadel.h | sed s/"[^0-9.]"/""/g`
62 webcit_version=`grep CLIENT_VERSION webcit/webcit.h | sed s/"[^0-9.]"/""/g`
63 textclient_version=`grep CLIENT_VERSION textclient/textclient.h | sed s/"[^0-9.]"/""/g`
64
65 echo -e '\033[33m\033[1mlibcitadel \033[32m is now version  \033[33m'$libcitadel_version'\033[0m'
66 echo -e '\033[33m\033[1mcitserver  \033[32m is now version  \033[33m'$citserver_version'\033[0m'
67 echo -e '\033[33m\033[1mwebcit     \033[32m is now version  \033[33m'$webcit_version'\033[0m'
68 echo -e '\033[33m\033[1mtextclient \033[32m is now version  \033[33m'$textclient_version'\033[0m'
69
70 echo $NEW_VERSION >release_version.txt
71 git add release_version.txt
72 echo -e ''
73 echo -e '\033[37m\033[1mUpdating release_version.txt to indicate version '${NEW_VERSION}'\033[0m'
74 echo -e '\033[37m\033[1mGenerating a commit\033[0m'
75 echo -e ''
76 git commit -a -m "Release version ${NEW_VERSION} generated by do-release.sh"
77 git tag -a v${NEW_VERSION} -m "Version ${NEW_VERSION} release"
78
79 echo -n 'git push...'
80 git push
81 echo
82
83 echo -n 'git push --tags...'
84 git push --tags
85 echo
86
87 echo -e ''
88 echo -e '\033[37mFinished.\033[0m'
89 echo -e ''