Development

Changeset 3261

You must first sign up to be able to contribute.

Changeset 3261

Show
Ignore:
Timestamp:
01/13/07 15:19:56 (2 years ago)
Author:
fabien
Message:

moved release script to data/bin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/bin/release.php

    r2871 r3261  
    33/* 
    44 * This file is part of the symfony package. 
    5  * (c) 2004, 2005 Fabien Potencier <fabien.potencier@symfony-project.com> 
    6  * 
     5 * (c) 2004-2007 Fabien Potencier <fabien.potencier@symfony-project.com> 
     6 *  
    77 * For the full copyright and license information, please view the LICENSE 
    88 * file that was distributed with this source code. 
     
    1010 
    1111/** 
    12  * @package    symfony 
    13  * @author     Fabien Potencier <fabien.potencier@symfony-project.com> 
    14  * @version    SVN: $Id$ 
    15  */ 
    16  
    17 /** 
    18  * Pakefile. 
     12 * Release script. 
     13 * 
     14 * Usage: php data/bin/release.php 1.0.0 stable 
    1915 * 
    2016 * @package    symfony 
     
    2218 * @version    SVN: $Id$ 
    2319 */ 
     20require_once(dirname(__FILE__).'/../../lib/vendor/pake/pakeFunction.php'); 
     21require_once(dirname(__FILE__).'/../../lib/vendor/pake/pakeGetopt.class.php'); 
     22require_once(dirname(__FILE__).'/../../lib/vendor/lime/lime.php'); 
    2423 
    25 pake_import('pear'); 
    26  
    27 pake_desc('launch symfony test suite'); 
    28 pake_task('test'); 
    29  
    30 pake_desc('release a new symfony version'); 
    31 pake_task('release', 'test'); 
    32  
    33 function run_test($task, $args) 
     24if (!isset($argv[1])) 
    3425{ 
    35   require_once(dirname(__FILE__).'/lib/vendor/lime/lime.php'); 
    36  
    37   $h = new lime_harness(new lime_output_color()); 
    38  
    39   $h->base_dir = realpath(dirname(__FILE__).'/test'); 
    40  
    41   // unit tests 
    42   $h->register_glob($h->base_dir.'/unit/*/*Test.php'); 
    43  
    44   // functional tests 
    45   $h->register_glob($h->base_dir.'/functional/*Test.php'); 
    46   $h->register_glob($h->base_dir.'/functional/*/*Test.php'); 
    47  
    48   $h->run(); 
     26  throw new Exception('You must provide version prefix.'); 
    4927} 
    5028 
    51 function run_create_pear_package($task, $args
     29if (!isset($argv[2])
    5230{ 
    53   if (!isset($args[0])) 
     31  throw new Exception('You must provide stability status (alpha/beta/stable).'); 
     32
     33 
     34$stability = $argv[2]; 
     35 
     36if (($stability == 'beta' || $stability == 'alpha') && count(explode('.', $argv[1])) < 2) 
     37
     38  $version_prefix = $argv[1]; 
     39 
     40  $result = pake_sh('svn status -u '.getcwd()); 
     41  if (preg_match('/Status against revision\:\s+(\d+)\s*$/im', $result, $match)) 
    5442  { 
    55     throw new Exception('you must provide pake version to release')
     43    $version = $match[1]
    5644  } 
    5745 
    58   $version    = $args[0]; 
    59   $stability  = $args[1]; 
    60  
    61   // create a pear package 
    62   print 'create pear package for version "'.$version."\"\n"; 
    63  
    64   try 
     46  if (!isset($version)) 
    6547  { 
    66     @pake_remove('package.xml', getcwd()); 
    67   } 
    68   catch (Exception $e) 
    69   { 
    70   } 
    71   pake_copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml'); 
    72  
    73   // add class files 
    74   $finder = pakeFinder::type('file')->ignore_version_control()->relative(); 
    75   $xml_classes = ''; 
    76   $dirs = array('lib' => 'php', 'data' => 'data'); 
    77   foreach ($dirs as $dir => $role) 
    78   { 
    79     $class_files = $finder->in($dir); 
    80     foreach ($class_files as $file) 
    81     { 
    82       $xml_classes .= '<file role="'.$role.'" baseinstalldir="symfony" install-as="'.$file.'" name="'.$dir.'/'.$file.'" />'."\n"; 
    83     } 
     48    throw new Exception('unable to find last svn revision'); 
    8449  } 
    8550 
    86   // replace tokens 
    87   pake_replace_tokens('package.xml', getcwd(), '##', '##', array( 
    88     'SYMFONY_VERSION' => $version, 
    89     'CURRENT_DATE'    => date('Y-m-d'), 
    90     'CLASS_FILES'     => $xml_classes, 
    91     'STABILITY'       => $stability, 
    92   )); 
    93   pakePearTask::run_pear($task, $args); 
     51  // make a PEAR compatible version 
     52  $version = $version_prefix.'.'.$version; 
     53
     54else 
     55
     56  $version = $argv[1]; 
     57
     58 
     59print 'releasing symfony version "'.$version."\"\n"; 
     60 
     61// Test 
     62$h = new lime_harness(new lime_output_color()); 
     63 
     64$h->base_dir = realpath(dirname(__FILE__).'/../../test'); 
     65 
     66// unit tests 
     67$h->register_glob($h->base_dir.'/unit/*/*Test.php'); 
     68 
     69// functional tests 
     70$h->register_glob($h->base_dir.'/functional/*Test.php'); 
     71$h->register_glob($h->base_dir.'/functional/*/*Test.php'); 
     72 
     73$ret = $h->run(); 
     74 
     75if (!$ret) 
     76
     77  throw new Exception('Some tests failed. Release process aborted!'); 
     78
     79 
     80if (is_file('package.xml')) 
     81
    9482  pake_remove('package.xml', getcwd()); 
    9583} 
    9684 
    97 function run_release($task, $args) 
     85pake_copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml'); 
     86 
     87// add class files 
     88$finder = pakeFinder::type('file')->ignore_version_control()->relative(); 
     89$xml_classes = ''; 
     90$dirs = array('lib' => 'php', 'data' => 'data'); 
     91foreach ($dirs as $dir => $role) 
    9892{ 
    99   if (!isset($args[0])) 
     93  $class_files = $finder->in($dir); 
     94  foreach ($class_files as $file) 
    10095  { 
    101     throw new Exception('you must provide version prefix')
     96    $xml_classes .= '<file role="'.$role.'" baseinstalldir="symfony" install-as="'.$file.'" name="'.$dir.'/'.$file.'" />'."\n"
    10297  } 
     98} 
    10399 
    104   if (!isset($args[1])) 
    105   { 
    106     throw new Exception('you must provide stability status (alpha/beta/stable)'); 
    107   } 
     100// replace tokens 
     101pake_replace_tokens('package.xml', getcwd(), '##', '##', array( 
     102  'SYMFONY_VERSION' => $version, 
     103  'CURRENT_DATE'    => date('Y-m-d'), 
     104  'CLASS_FILES'     => $xml_classes, 
     105  'STABILITY'       => $stability, 
     106)); 
    108107 
    109   $stability = $args[1]; 
     108$results = pake_sh('pear package'); 
     109echo $results; 
    110110 
    111   if (($stability == 'beta' || $stability == 'alpha') && count(explode('.', $args[0])) < 2) 
    112   { 
    113     $version_prefix = $args[0]; 
     111pake_remove('package.xml', getcwd()); 
    114112 
    115     $result = pake_sh('svn status -u '.getcwd()); 
    116     if (preg_match('/Status against revision\:\s+(\d+)\s*$/im', $result, $match)) 
    117     { 
    118       $version = $match[1]; 
    119     } 
     113// copy .tgz as symfony-latest.tgz 
     114pake_copy(getcwd().'/symfony-'.$version.'.tgz', getcwd().'/symfony-latest.tgz'); 
    120115 
    121     if (!isset($version)) 
    122     { 
    123       throw new Exception('unable to find last svn revision'); 
    124     } 
    125  
    126     // make a PEAR compatible version 
    127     $version = $version_prefix.'.'.$version; 
    128   } 
    129   else 
    130   { 
    131     $version = $args[0]; 
    132   } 
    133  
    134   if ($task->is_verbose()) 
    135   { 
    136     print 'releasing symfony version "'.$version."\"\n"; 
    137   } 
    138  
    139   $args[0] = $version; 
    140  
    141   run_create_pear_package($task, $args); 
    142  
    143   // copy .tgz as symfony-latest.tgz 
    144   pake_copy(getcwd().'/symfony-'.$version.'.tgz', getcwd().'/symfony-latest.tgz'); 
    145 
     116exit(0);