Don't add nofollow for matching hosts, generalize this code.
[htmlpurifier.git] / release1-update.php
blob834d385676b5f0abea420aa03da973b55115453d
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 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'),
35 if (!$c) {
36 echo 'Could not update NEWS, missing ' . $l . PHP_EOL;
37 exit;
38 } elseif ($c > 1) {
39 echo 'More than one release declaration in NEWS replaced' . PHP_EOL;
40 exit;
42 file_put_contents('NEWS', $news_c);
45 // ...in Doxyfile
46 $doxyfile_c = preg_replace(
47 '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
48 $version,
49 file_get_contents('Doxyfile'),
50 1, $c
52 if (!$c) {
53 echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
54 exit;
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 - ",
63 $htmlpurifier_c,
64 1, $c
66 if (!$c) {
67 echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
68 exit;
70 $htmlpurifier_c = preg_replace(
71 '/public \$version = \'.+?\';/',
72 "public \$version = '$version';",
73 $htmlpurifier_c,
74 1, $c
76 if (!$c) {
77 echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL;
78 exit;
80 $htmlpurifier_c = preg_replace(
81 '/const VERSION = \'.+?\';/',
82 "const VERSION = '$version';",
83 $htmlpurifier_c,
84 1, $c
86 if (!$c) {
87 echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL;
88 exit;
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';",
96 $config_c,
97 1, $c
99 if (!$c) {
100 echo 'Could not update Config.php, missing public $version.' . PHP_EOL;
101 exit;
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!";
110 // vim: et sw=4 sts=4