blob: 6b3b31d1228da574a0a1843f674d189a191b39c3 [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
Andrey Andreevc877ac52016-10-28 17:56:50 +030038elif [ `grep -c -F --regexp="$version_number (Current version) <https://codeload.github.com/bcit-ci/CodeIgniter/zip/$version_number>" user_guide_src/source/installation/downloads.rst` -ne 1 ]
39then
40 echo "user_guide_src/source/installation/downloads.rst doesn't appear to contain a link for this version"
41 exit 1
Andrey Andreeve02ebab2016-10-28 16:35:12 +030042elif [ ! -f "$upgrade_rst" ]
43then
44 echo "${upgrade_rst} doesn't exist"
45 exit 1
46fi
47
48echo "Running tests ..."
49
50cd tests/
51phpunit
52
53if [ $? -ne 0 ]
54then
55 echo "Build FAILED!"
56 exit 1
57fi
58
59cd ..
60cd user_guide_src/
61
62echo ""
63echo "Building HTML docs; please check output for warnings ..."
64echo ""
65
66make html
67
68echo ""
69
70if [ $? -ne 0 ]
71then
72 echo "Build FAILED!"
73 exit 1
74fi
75
76echo "Building EPUB docs; please check output for warnings ..."
77echo ""
78
79make epub
80
81echo ""
82
83if [ $? -ne 0 ]
84then
85 echo "Build FAILED!"
86 exit 1
87fi
88
89cd ..
90
91if [ -d user_guide/ ]
92then
93 rm -r user_guide/
94fi
95
96cp -r user_guide_src/build/html/ user_guide/
97cp user_guide_src/build/epub/CodeIgniter.epub "CodeIgniter ${version_number}.epub"
98
99echo "Build complete."