6 if (php_sapi_name() != 'cli') {
7 echo 'Release script cannot be called from web-browser.';
11 if (!isset($argv[1])) {
13 'php release.php [version]
14 HTML Purifier release script
19 $version = trim($argv[1]);
21 // Bump version numbers:
24 file_put_contents('VERSION', $version);
27 if ($is_dev = (strpos($version, 'dev') === false)) {
28 $date = date('Y-m-d');
29 $news_c = str_replace(
30 $l = "$version, unknown release date",
31 "$version, released $date",
32 file_get_contents('NEWS'),
36 echo 'Could not update NEWS, missing ' . $l . PHP_EOL
;
39 echo 'More than one release declaration in NEWS replaced' . PHP_EOL
;
42 file_put_contents('NEWS', $news_c);
46 $doxyfile_c = preg_replace(
47 '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
49 file_get_contents('Doxyfile'),
53 echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL
;
56 file_put_contents('Doxyfile', $doxyfile_c);
58 // ...in HTMLPurifier.php
59 $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
60 $htmlpurifier_c = preg_replace(
61 '/HTML Purifier .+? - /',
62 "HTML Purifier $version - ",
67 echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL
;
70 $htmlpurifier_c = preg_replace(
71 '/public \$version = \'.+?\';/',
72 "public \$version = '$version';",
77 echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL
;
80 $htmlpurifier_c = preg_replace(
81 '/const VERSION = \'.+?\';/',
82 "const VERSION = '$version';",
87 echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL
;
90 file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
92 $config_c = file_get_contents('library/HTMLPurifier/Config.php');
93 $config_c = preg_replace(
94 '/public \$version = \'.+?\';/',
95 "public \$version = '$version';",
100 echo 'Could not update Config.php, missing public $version.' . PHP_EOL
;
103 file_put_contents('library/HTMLPurifier/Config.php', $config_c);
105 passthru('php maintenance/flush.php');
107 if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL
;
108 else echo "Numbers updated to dev, no other modifications necessary!";