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