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 $date = date('Y-m-d');
28 $news_c = str_replace(
29 $l = "$version, unknown release date",
30 "$version, released $date",
31 file_get_contents('NEWS'),
35 echo 'Could not update NEWS, missing ' . $l . PHP_EOL
;
38 echo 'More than one release declaration in NEWS replaced' . PHP_EOL
;
41 file_put_contents('NEWS', $news_c);
44 $doxyfile_c = preg_replace(
45 '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
47 file_get_contents('Doxyfile'),
51 echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL
;
54 file_put_contents('Doxyfile', $doxyfile_c);
56 // ...in HTMLPurifier.php
57 $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
58 $htmlpurifier_c = preg_replace(
59 '/HTML Purifier .+? - /',
60 "HTML Purifier $version - ",
65 echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL
;
68 $htmlpurifier_c = preg_replace(
69 '/var \$version = \'.+?\';/',
70 "var \$version = '$version';",
75 echo 'Could not update HTMLPurifier.php, missing var $version.' . PHP_EOL
;
78 file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
80 $config_c = file_get_contents('library/HTMLPurifier/Config.php');
81 $config_c = preg_replace(
82 '/var \$version = \'.+?\';/',
83 "var \$version = '$version';",
88 echo 'Could not update Config.php, missing var $version.' . PHP_EOL
;
91 file_put_contents('library/HTMLPurifier/Config.php', $config_c);
93 echo "Review changes, write something in WHATSNEW, and then SVN commit with log 'Release $version.'" . PHP_EOL
;