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