]> git.notmuchmail.org Git - notmuch/blob - devel/release-checks.sh
bump versions to 0.15.2
[notmuch] / devel / release-checks.sh
1 #!/usr/bin/env bash
2
3 set -eu
4 #set -x # or enter bash -x ... on command line
5
6 if [ x"${BASH_VERSION-}" = x ]
7 then    echo
8         echo "Please execute this script using 'bash' interpreter"
9         echo
10         exit 1
11 fi
12
13 set -o posix
14 set -o pipefail # bash feature
15
16 # Avoid locale-specific differences in output of executed commands
17 LANG=C LC_ALL=C; export LANG LC_ALL
18
19 readonly PV_FILE='bindings/python/notmuch/version.py'
20
21 # Using array here turned out to be unnecessarily complicated
22 emsgs=''
23 append_emsg ()
24 {
25         emsgs="${emsgs:+$emsgs\n}  $1"
26 }
27
28 for f in ./version debian/changelog NEWS "$PV_FILE"
29 do
30         if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
31         elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
32         elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
33         fi
34 done
35
36 if [ -n "$emsgs" ]
37 then
38         echo 'Release files problems; fix these and try again:'
39         echo -e "$emsgs"
40         exit 1
41 fi
42
43 if read VERSION
44 then
45         if read rest
46         then    echo "'version' file contains more than one line"
47                 exit 1
48         fi
49 else
50         echo "Reading './version' file failed (suprisingly!)"
51         exit 1
52 fi < ./version
53
54 readonly VERSION
55
56 verfail ()
57 {
58         echo No.
59         echo "$@"
60         echo "Please follow the instructions in RELEASING to choose a version"
61         exit 1
62 }
63
64 echo -n "Checking that '$VERSION' is good with digits and periods... "
65 case $VERSION in
66         *[^0-9.]*)
67                 verfail "'$VERSION' contains other characters than digits and periods" ;;
68         .*)     verfail "'$VERSION' begins with a period" ;;
69         *.)     verfail "'$VERSION' ends with a period" ;;
70         *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
71         *.*)    echo Yes. ;;
72         *)      verfail "'$VERSION' is a single number" ;;
73 esac
74
75
76 # In the rest of this file, tests collect list of errors to be fixed
77
78 echo -n "Checking that this is Debian package for notmuch... "
79 read deb_notmuch deb_version rest < debian/changelog
80 if [ "$deb_notmuch" = 'notmuch' ]
81 then
82         echo Yes.
83 else
84         echo No.
85         append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"
86 fi
87
88 echo -n "Checking that Debian package version is $VERSION-1... "
89
90 if [ "$deb_version" = "($VERSION-1)" ]
91 then
92         echo Yes.
93 else
94         echo No.
95         append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"
96 fi
97
98 echo -n "Checking that python bindings version is $VERSION... "
99 py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`
100 if [ "$py_version" = "$VERSION" ]
101 then
102         echo Yes.
103 else
104         echo No.
105         append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
106 fi
107
108 echo -n "Checking that this is Notmuch NEWS... "
109 read news_notmuch news_version news_date < NEWS
110 if [ "$news_notmuch" = "Notmuch" ]
111 then
112         echo Yes.
113 else
114         echo No.
115         append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
116 fi
117
118 echo -n "Checking that NEWS version is $VERSION... "
119 if [ "$news_version" = "$VERSION" ]
120 then
121         echo Yes.
122 else
123         echo No.
124         append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
125 fi
126
127 #eval `date '+year=%Y mon=%m day=%d'`
128 today0utc=`date --date=0Z +%s` # gnu date feature
129
130 echo -n "Checking that NEWS date is right... "
131 case $news_date in
132  '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
133         newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
134         ddiff=$((newsdate0utc - today0utc))
135         if [ $ddiff -lt -86400 ] # since beginning of yesterday...
136         then
137                 echo No.
138                 append_emsg "Date $news_date in NEWS file is too much in the past"
139         elif [ $ddiff -gt 172800 ] # up to end of tomorrow...
140         then
141                 echo No.
142                 append_emsg "Date $news_date in NEWS file is too much in the future"
143         else
144                 echo Yes.
145         fi ;;
146  *)
147         echo No.
148         append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"
149 esac
150
151 readonly DATE=${news_date//[()]/} # bash feature
152 manthdata ()
153 {
154         set x $*
155         if [ $# != 7 ]
156         then
157                 append_emsg "'$mp' has too many '.TH' lines"
158                 man_mismatch=1
159         fi
160         man_date=${5-} man_version=${7-}
161 }
162
163 echo -n "Checking that manual page dates and versions are $DATE and $VERSION... "
164 manfiles=`find man -type f | sort`
165 man_pages_ok=Yes
166 for mp in $manfiles
167 do
168         case $mp in
169                 *.[0-9]) ;; # fall below this 'case ... esac'
170
171                 */Makefile.local | */Makefile ) continue ;;
172                 */.gitignore)   continue ;;
173                 *.bak)          continue ;;
174
175                 *)      append_emsg "'$mp': extra file"
176                         man_pages_ok=No
177                         continue
178         esac
179         manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`
180         if [ "$man_version" != "$VERSION" ]
181         then    append_emsg "Version '$man_version' is not '$VERSION' in $mp"
182                 mman_pages_ok=No
183         fi
184         if [ "$man_date" != "$DATE" ]
185         then    append_emsg "DATE '$man_date' is not '$DATE' in $mp"
186                 man_pages_ok=No
187         fi
188 done
189 echo $man_pages_ok.
190
191 if [ -n "$emsgs" ]
192 then
193         echo
194         echo 'Release check failed; check these issues:'
195         echo -e "$emsgs"
196         exit 1
197 fi
198
199 echo 'All checks this script executed completed successfully.'
200 echo 'Make sure that everything else mentioned in RELEASING'
201 echo 'file is in order, too.'
202
203
204 # Local variables:
205 # mode: shell-script
206 # sh-basic-offset: 8
207 # tab-width: 8
208 # End:
209 # vi: set sw=8 ts=8