blob: 490680e791614c609ddabbeb49f21aa7dd5e550c [file] [log] [blame]
Andrey Andreeve02ebab2016-10-28 16:35:12 +03001#!/usr/bin/env bash
2
3cd $(dirname $BASH_SOURCE)
4
5if [ $# -eq 0 ]; then
6 echo 'Usage: '$BASH_SOURCE' <version_number>'
7 exit 1
8fi
9
10version_number=$1
11
12if [ ${#version_number} -lt 5 ]
13then
14 echo "Provided version number is too short"
15 exit 1
16elif [ ${version_number: -4} == "-dev" ]
17then
18 echo "'-dev' releases are not allowed"
19 exit 1
20fi
21
22version_id=${version_number:0:5}
23version_id=${version_id//./}
24upgrade_rst='user_guide_src/source/installation/upgrade_'$version_id'.rst'
25
26if [ ${#version_id} -ne 3 ]
27then
28 echo "Invalid version number format"
29 exit 1
30elif [ `grep -c -F --regexp="'$version_number'" system/core/CodeIgniter.php` -ne 1 ]
31then
32 echo "Provided version number doesn't match in system/core/CodeIgniter.php"
33 exit 1
34elif [ `grep -c -F --regexp="'$version_number'" user_guide_src/source/conf.py` -ne 2 ]
35then
36 echo "Provided version number doesn't match in user_guide_src/source/conf.py"
37 exit 1
38elif [ ! -f "$upgrade_rst" ]
39then
40 echo "${upgrade_rst} doesn't exist"
41 exit 1
42fi
43
44echo "Running tests ..."
45
46cd tests/
47phpunit
48
49if [ $? -ne 0 ]
50then
51 echo "Build FAILED!"
52 exit 1
53fi
54
55cd ..
56cd user_guide_src/
57
58echo ""
59echo "Building HTML docs; please check output for warnings ..."
60echo ""
61
62make html
63
64echo ""
65
66if [ $? -ne 0 ]
67then
68 echo "Build FAILED!"
69 exit 1
70fi
71
72echo "Building EPUB docs; please check output for warnings ..."
73echo ""
74
75make epub
76
77echo ""
78
79if [ $? -ne 0 ]
80then
81 echo "Build FAILED!"
82 exit 1
83fi
84
85cd ..
86
87if [ -d user_guide/ ]
88then
89 rm -r user_guide/
90fi
91
92cp -r user_guide_src/build/html/ user_guide/
93cp user_guide_src/build/epub/CodeIgniter.epub "CodeIgniter ${version_number}.epub"
94
95echo "Build complete."