release.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2007 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Release script.
  11. *
  12. * Usage: php data/bin/release.php 1.1.0 stable
  13. *
  14. * @package symfony
  15. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  16. * @version SVN: $Id$
  17. */
  18. require_once(dirname(__FILE__).'/../../lib/exception/sfException.class.php');
  19. require_once(dirname(__FILE__).'/../../lib/task/sfFilesystem.class.php');
  20. require_once(dirname(__FILE__).'/../../lib/util/sfFinder.class.php');
  21. require_once(dirname(__FILE__).'/../../lib/vendor/lime/lime.php');
  22. if (!isset($argv[1]))
  23. {
  24. throw new Exception('You must provide version prefix.');
  25. }
  26. if (!isset($argv[2]))
  27. {
  28. throw new Exception('You must provide stability status (alpha/beta/stable).');
  29. }
  30. $stability = $argv[2];
  31. $filesystem = new sfFilesystem();
  32. if (($stability == 'beta' || $stability == 'alpha') && count(explode('.', $argv[1])) < 2)
  33. {
  34. $version_prefix = $argv[1];
  35. $result = $filesystem->sh('svn status -u '.getcwd());
  36. if (preg_match('/Status against revision\:\s+(\d+)\s*$/im', $result, $match))
  37. {
  38. $version = $match[1];
  39. }
  40. if (!isset($version))
  41. {
  42. throw new Exception('Unable to find last SVN revision.');
  43. }
  44. // make a PEAR compatible version
  45. $version = $version_prefix.'.'.$version;
  46. }
  47. else
  48. {
  49. $version = $argv[1];
  50. }
  51. print sprintf("Releasing symfony version \"%s\".\n", $version);
  52. // tests
  53. $result = $filesystem->sh('php test/bin/prove.php');
  54. if (0 != $result)
  55. {
  56. throw new Exception('Some tests failed. Release process aborted!');
  57. }
  58. if (is_file('package.xml'))
  59. {
  60. $filesystem->remove(getcwd().DIRECTORY_SEPARATOR.'package.xml');
  61. }
  62. $filesystem->copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml');
  63. // add class files
  64. $finder = sfFinder::type('file')->relative();
  65. $xml_classes = '';
  66. $dirs = array('lib' => 'php', 'data' => 'data');
  67. foreach ($dirs as $dir => $role)
  68. {
  69. $class_files = $finder->in($dir);
  70. foreach ($class_files as $file)
  71. {
  72. $xml_classes .= '<file role="'.$role.'" baseinstalldir="symfony" install-as="'.$file.'" name="'.$dir.'/'.$file.'" />'."\n";
  73. }
  74. }
  75. // replace tokens
  76. $filesystem->replaceTokens(getcwd().DIRECTORY_SEPARATOR.'package.xml', '##', '##', array(
  77. 'SYMFONY_VERSION' => $version,
  78. 'CURRENT_DATE' => date('Y-m-d'),
  79. 'CLASS_FILES' => $xml_classes,
  80. 'STABILITY' => $stability,
  81. ));
  82. $results = $filesystem->sh('pear package');
  83. echo $results;
  84. $filesystem->remove(getcwd().DIRECTORY_SEPARATOR.'package.xml');
  85. exit(0);