HTMLPurifier 4.4.0
/home/ezyang/Dev/htmlpurifier/release1-update.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // release script
00004 // PHP 5.0 only
00005 
00006 if (php_sapi_name() != 'cli') {
00007     echo 'Release script cannot be called from web-browser.';
00008     exit;
00009 }
00010 
00011 if (!isset($argv[1])) {
00012     echo
00013 'php release.php [version]
00014     HTML Purifier release script
00015 ';
00016     exit;
00017 }
00018 
00019 $version = trim($argv[1]);
00020 
00021 // Bump version numbers:
00022 
00023 // ...in VERSION
00024 file_put_contents('VERSION', $version);
00025 
00026 // ...in NEWS
00027 if ($is_dev = (strpos($version, 'dev') === false)) {
00028   $date = date('Y-m-d');
00029   $news_c = str_replace(
00030       $l = "$version, unknown release date",
00031       "$version, released $date",
00032       file_get_contents('NEWS'),
00033       $c
00034   );
00035   if (!$c) {
00036       echo 'Could not update NEWS, missing ' . $l . PHP_EOL;
00037       exit;
00038   } elseif ($c > 1) {
00039       echo 'More than one release declaration in NEWS replaced' . PHP_EOL;
00040       exit;
00041   }
00042   file_put_contents('NEWS', $news_c);
00043 }
00044 
00045 // ...in Doxyfile
00046 $doxyfile_c = preg_replace(
00047     '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
00048     $version,
00049     file_get_contents('Doxyfile'),
00050     1, $c
00051 );
00052 if (!$c) {
00053     echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
00054     exit;
00055 }
00056 file_put_contents('Doxyfile', $doxyfile_c);
00057 
00058 // ...in HTMLPurifier.php
00059 $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
00060 $htmlpurifier_c = preg_replace(
00061     '/HTML Purifier .+? - /',
00062     "HTML Purifier $version - ",
00063     $htmlpurifier_c,
00064     1, $c
00065 );
00066 if (!$c) {
00067     echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
00068     exit;
00069 }
00070 $htmlpurifier_c = preg_replace(
00071     '/public \$version = \'.+?\';/',
00072     "public \$version = '$version';",
00073     $htmlpurifier_c,
00074     1, $c
00075 );
00076 if (!$c) {
00077     echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL;
00078     exit;
00079 }
00080 $htmlpurifier_c = preg_replace(
00081     '/const VERSION = \'.+?\';/',
00082     "const VERSION = '$version';",
00083     $htmlpurifier_c,
00084     1, $c
00085 );
00086 if (!$c) {
00087     echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL;
00088     exit;
00089 }
00090 file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
00091 
00092 $config_c = file_get_contents('library/HTMLPurifier/Config.php');
00093 $config_c = preg_replace(
00094     '/public \$version = \'.+?\';/',
00095     "public \$version = '$version';",
00096     $config_c,
00097     1, $c
00098 );
00099 if (!$c) {
00100     echo 'Could not update Config.php, missing public $version.' . PHP_EOL;
00101     exit;
00102 }
00103 file_put_contents('library/HTMLPurifier/Config.php', $config_c);
00104 
00105 passthru('php maintenance/flush.php');
00106 
00107 if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL;
00108 else echo "Numbers updated to dev, no other modifications necessary!";
00109 
00110 // vim: et sw=4 sts=4