update-for-release 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. $is_dev = strpos($version, 'dev') === false;
  20. // ...in Doxyfile
  21. $doxyfile_c = preg_replace(
  22. '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
  23. $version,
  24. file_get_contents('Doxyfile'),
  25. 1, $c
  26. );
  27. if (!$c) {
  28. echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
  29. exit;
  30. }
  31. file_put_contents('Doxyfile', $doxyfile_c);
  32. // ...in HTMLPurifier.php
  33. $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
  34. $htmlpurifier_c = preg_replace(
  35. '/HTML Purifier .+? - /',
  36. "HTML Purifier $version - ",
  37. $htmlpurifier_c,
  38. 1, $c
  39. );
  40. if (!$c) {
  41. echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
  42. exit;
  43. }
  44. $htmlpurifier_c = preg_replace(
  45. '/public \$version = \'.+?\';/',
  46. "public \$version = '$version';",
  47. $htmlpurifier_c,
  48. 1, $c
  49. );
  50. if (!$c) {
  51. echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL;
  52. exit;
  53. }
  54. $htmlpurifier_c = preg_replace(
  55. '/const VERSION = \'.+?\';/',
  56. "const VERSION = '$version';",
  57. $htmlpurifier_c,
  58. 1, $c
  59. );
  60. if (!$c) {
  61. echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL;
  62. exit;
  63. }
  64. file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
  65. $config_c = file_get_contents('library/HTMLPurifier/Config.php');
  66. $config_c = preg_replace(
  67. '/public \$version = \'.+?\';/',
  68. "public \$version = '$version';",
  69. $config_c,
  70. 1, $c
  71. );
  72. if (!$c) {
  73. echo 'Could not update Config.php, missing public $version.' . PHP_EOL;
  74. exit;
  75. }
  76. file_put_contents('library/HTMLPurifier/Config.php', $config_c);
  77. $includes = file_get_contents('library/HTMLPurifier.includes.php');
  78. $includes = preg_replace(
  79. '/@version .+?/',
  80. "@version $version",
  81. $includes,
  82. 1, $c
  83. );
  84. if (!$c) {
  85. echo 'Could not update HTMLPurifier.includes.php, missing @version docblock.' . PHP_EOL;
  86. exit;
  87. }
  88. file_put_contents('HTMLPurifier.includes.php', $includes);
  89. passthru('maintenance/flush.sh');
  90. if ($is_dev) echo "Review changes, and then commit with log 'Release $version.'" . PHP_EOL;
  91. else echo "Numbers updated to dev, no other modifications necessary!";
  92. // vim: et sw=4 sts=4