選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

111 行
2.6KB

  1. <?php
  2. // release script
  3. // PHP 5.0 only
  4. if (php_sapi_name() != 'cli') {
  5. echo 'Release script cannot be called from web-browser.';
  6. exit;
  7. }
  8. if (!isset($argv[1])) {
  9. echo
  10. 'php release.php [version]
  11. HTML Purifier release script
  12. ';
  13. exit;
  14. }
  15. $version = trim($argv[1]);
  16. // Bump version numbers:
  17. // ...in VERSION
  18. file_put_contents('VERSION', $version);
  19. // ...in NEWS
  20. if ($is_dev = (strpos($version, 'dev') === false)) {
  21. $date = date('Y-m-d');
  22. $news_c = str_replace(
  23. $l = "$version, unknown release date",
  24. "$version, released $date",
  25. file_get_contents('NEWS'),
  26. $c
  27. );
  28. if (!$c) {
  29. echo 'Could not update NEWS, missing ' . $l . PHP_EOL;
  30. exit;
  31. } elseif ($c > 1) {
  32. echo 'More than one release declaration in NEWS replaced' . PHP_EOL;
  33. exit;
  34. }
  35. file_put_contents('NEWS', $news_c);
  36. }
  37. // ...in Doxyfile
  38. $doxyfile_c = preg_replace(
  39. '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
  40. $version,
  41. file_get_contents('Doxyfile'),
  42. 1, $c
  43. );
  44. if (!$c) {
  45. echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
  46. exit;
  47. }
  48. file_put_contents('Doxyfile', $doxyfile_c);
  49. // ...in HTMLPurifier.php
  50. $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
  51. $htmlpurifier_c = preg_replace(
  52. '/HTML Purifier .+? - /',
  53. "HTML Purifier $version - ",
  54. $htmlpurifier_c,
  55. 1, $c
  56. );
  57. if (!$c) {
  58. echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
  59. exit;
  60. }
  61. $htmlpurifier_c = preg_replace(
  62. '/public \$version = \'.+?\';/',
  63. "public \$version = '$version';",
  64. $htmlpurifier_c,
  65. 1, $c
  66. );
  67. if (!$c) {
  68. echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL;
  69. exit;
  70. }
  71. $htmlpurifier_c = preg_replace(
  72. '/const VERSION = \'.+?\';/',
  73. "const VERSION = '$version';",
  74. $htmlpurifier_c,
  75. 1, $c
  76. );
  77. if (!$c) {
  78. echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL;
  79. exit;
  80. }
  81. file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
  82. $config_c = file_get_contents('library/HTMLPurifier/Config.php');
  83. $config_c = preg_replace(
  84. '/public \$version = \'.+?\';/',
  85. "public \$version = '$version';",
  86. $config_c,
  87. 1, $c
  88. );
  89. if (!$c) {
  90. echo 'Could not update Config.php, missing public $version.' . PHP_EOL;
  91. exit;
  92. }
  93. file_put_contents('library/HTMLPurifier/Config.php', $config_c);
  94. passthru('php maintenance/flush.php');
  95. if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL;
  96. else echo "Numbers updated to dev, no other modifications necessary!";
  97. // vim: et sw=4 sts=4