[1.7.0] StrictBlockquote child definition refrains from wrapping whitespace in tags...
[htmlpurifier.git] / release1-update.php
blob05b6b904e4f0d581ff801f407721653c5fc1b9d4
1 <?php
3 // release script
4 // PHP 5.0 only
6 if (php_sapi_name() != 'cli') {
7 echo 'Release script cannot be called from web-browser.';
8 exit;
11 if (!isset($argv[1])) {
12 echo
13 'php release.php [version]
14 HTML Purifier release script
16 exit;
19 $version = trim($argv[1]);
21 // Bump version numbers:
23 // ...in VERSION
24 file_put_contents('VERSION', $version);
26 // ...in NEWS
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'),
34 if (!$c) {
35 echo 'Could not update NEWS, missing ' . $l . PHP_EOL;
36 exit;
37 } elseif ($c > 1) {
38 echo 'More than one release declaration in NEWS replaced' . PHP_EOL;
39 exit;
41 file_put_contents('NEWS', $news_c);
43 // ...in Doxyfile
44 $doxyfile_c = preg_replace(
45 '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
46 $version,
47 file_get_contents('Doxyfile'),
48 1, $c
50 if (!$c) {
51 echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
52 exit;
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 - ",
61 $htmlpurifier_c,
62 1, $c
64 if (!$c) {
65 echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
66 exit;
68 $htmlpurifier_c = preg_replace(
69 '/var \$version = \'.+?\';/',
70 "var \$version = '$version';",
71 $htmlpurifier_c,
72 1, $c
74 if (!$c) {
75 echo 'Could not update HTMLPurifier.php, missing var $version.' . PHP_EOL;
76 exit;
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';",
84 $config_c,
85 1, $c
87 if (!$c) {
88 echo 'Could not update Config.php, missing var $version.' . PHP_EOL;
89 exit;
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;