#!/usr/bin/env php argv(1); if (! $version) { echo "Please pass a version number as the first argument (e.g. '1.0.0alpha5'.)\n"; exit(1); } // does the version already exist? $exists = is_dir("$core/tags/release-$version"); if ($exists) { echo "Version $version already tagged; please try another version.\n"; exit(1); }; // --------------------------------------------------------------------- // // FILE PREP // // make sure relevant files are up-to-date solar_passthru('svn update trunk/'); // remove previous release files, if any solar_passthru("rm trunk/*.xml"); solar_passthru("rm trunk/*.tgz"); // clean dotfiles solar_passthru('find ./trunk -type f -name "\.*" -print -delete'); // update keywords solar_passthru('svn propset svn:keywords "Id" ./trunk/Solar.php'); solar_passthru('find "./trunk/Solar" -type f -name "*.php" -exec svn propset svn:keywords "Id" {} \;'); // make sure everything is committed properly $result = solar_exec('svn status trunk/', $output); if (trim($result) != '') { echo implode("\n", $output) . "\n"; echo "Trunk not up-to-date. Please handle outstanding issues.\n"; exit(1); } // --------------------------------------------------------------------- // // PARSE API REFERENCE DOCS // $php = Solar::factory('Solar_Php'); $php->setIniVal('include_path', "$core/trunk"); $code = "\$ref = Solar::factory('Solar_Docs_Apiref');\n" . "\$ref->addFiles('$core/trunk', 'Solar');\n"; $php->runSolarCode($code); if ($php->getLastLine()) { echo "Inline API reference docs not complete.\n"; exit(1); } // --------------------------------------------------------------------- // // GET RELEASE INFORMATION // // the info directory $info = "$core/trunk/info"; // info values $stability = file_get_contents("$info/stability"); $summary = file_get_contents("$info/summary"); $descr = file_get_contents("$info/description"); $notes = file_get_contents("$info/notes"); $maintainers = file("$info/maintainers"); // convert maintainers array foreach ($maintainers as $key => $val) { // ignore blank lines if (trim($val) == '') { unset($maintainers[$key]); continue; } // convert string to data array $data = explode(',', trim($val)); array_walk($data, 'trim'); $maintainers[$key] = $data; } // pear packager is too eager; using 'ignore' => array('/info') etc causes // it to ignore **all** info dirs, not just the top-level one. remove the info // dir now, and restore it after packaging is complete. solar_passthru("rm -rf $info"); // --------------------------------------------------------------------- // // BUILD THE PACKAGE // require_once 'PEAR/PackageFileManager2.php'; PEAR::setErrorHandling(PEAR_ERROR_PRINT); $pkg = new PEAR_PackageFileManager2; $opts = array( 'baseinstalldir' => '/', 'packagefile' => 'package.xml', 'packagedirectory' => "$core/trunk/", 'filelistgenerator' => 'file', 'roles' => array( '*' => 'php', ), 'dir_roles' => array( 'docs' => 'doc', 'tests' => 'test', 'script' => 'script', ), ); $e = $pkg->setOptions($opts); $pkg->setPackage('Solar'); $pkg->setSummary($summary); $pkg->setDescription($descr); foreach ($maintainers as $person) { $result = call_user_func_array( array($pkg, 'addMaintainer'), $person ); } $pkg->setChannel('solarphp.com'); $pkg->setAPIVersion($version); $pkg->setReleaseVersion($version); $pkg->setReleaseStability($stability); $pkg->setAPIStability($stability); $pkg->setPackageType('php'); $pkg->addRelease(); $pkg->setNotes($notes); $pkg->setPhpDep('5.2.9'); $pkg->setPearinstallerDep('1.6.2'); $pkg->setLicense('BSD', 'http://www.opensource.org/licenses/bsd-license.php'); // without this, it installs to "pear/bin/bin/solar", which is dumb :-/ $pkg->addInstallAs('script/solar', 'Solar/solar'); // generic replacements $pkg->addGlobalReplacement('package-info', '@package_version@', 'version'); $pkg->addGlobalReplacement('package-info', '@package_date@', 'date'); // write the package file echo "\nWrite package file...\n"; $pkg->generateContents(); $pkg->writePackageFile(); // create the package. // creates package.xml (v2 only) and the .tgz file $exit_code = solar_passthru('cd trunk; pear package'); // restore the info dir solar_passthru("svn update $info"); // was there a packaging error? if ($exit_code) { echo "Error in packaging.\n"; exit($exit_code); } // --------------------------------------------------------------------- // // COMMIT THE RELEASE // if ($request->argv(2) != 'commit') { // not committing the release, so we're done echo "Argument 'commit' not specified; dry-run complete.\n"; exit(0); } // copy trunk to tags/release-x.y.z // and commit with release message solar_passthru("svn copy trunk tags/release-$version"); solar_passthru("svn add tags/release-$version/*"); solar_passthru("svn commit -m \"tagged release $version\" tags/release-$version"); echo "Done.\n"; exit(0);