/** * Get the destination directory to build the package into. * * @return string The destination */ protected function getDestination() { $destination = $this->options['destination']; if ($this->isRelativePath($destination)) { return Context::getParam('project-root') . '/' . $destination; } return $destination; }
public function execute() { /** @var VCSInterface $vcs */ $vcs = Context::get('vcs'); if (count($vcs->getLocalModifications()) == 0) { Context::get('output')->writeln('<error>No modification found, aborting commit</error>'); return; } $vcs->saveWorkingCopy(str_replace('%version%', Context::getParam('new-version'), $this->options['commit-message'])); $this->confirmSuccess(); }
public function execute() { $newVersion = Context::getParam('new-version'); $composerFile = Context::getParam('project-root') . '/composer.json'; if (!file_exists($composerFile)) { throw new \Liip\RMT\Exception("Impossible to file the composer file ({$composerFile})"); } $fileContent = file_get_contents($composerFile); $fileContent = preg_replace('/("version":[^,]*,)/', '"version": "' . $newVersion . '",', $fileContent); file_put_contents($composerFile, $fileContent); $this->confirmSuccess(); }
public function execute() { $newVersion = Context::getParam('new-version'); // newscoop/library/Newscoop/Version.php $appFile = realpath(__DIR__ . '/../src/SWP/Bundle/CoreBundle/Version/Version.php'); Context::get('output')->writeln("Updating version [<yellow>{$newVersion}</yellow>] in {$appFile}: "); $fileContent = file_get_contents($appFile); $fileContent = preg_replace('/(.*protected \\$version = .*;)/', ' protected $version = \'' . $newVersion . '\';', $fileContent); $fileContent = preg_replace('/(.*protected \\$releaseDate = .*;)/', ' protected $releaseDate = \'' . date('Y-m-d') . '\';', $fileContent); file_put_contents($appFile, $fileContent); $this->confirmSuccess(); }
public function execute() { $versioner = new \NamelessCoder\TYPO3RepositoryClient\Versioner(); $directory = trim(shell_exec('pwd')); $version = $versioner->read('.'); $version[0] = Context::getParam('new-version'); try { $version[1] = Context::getParam('stability'); } catch (\InvalidArgumentException $e) { $version[1] = Context::get('information-collector')->getValueFor('stability'); } $versioner->write($directory, $version[0], $version[1]); }
public function __construct($options = array()) { // Define a default changelog name if (!array_key_exists('location', $options)) { $options['location'] = 'CHANGELOG'; } // The changelog format is related to the version-generator $config = Context::getParam('config'); preg_match('/([^\\\\]+)Generator/', $config['version-generator']['class'], $match); $format = $match[1]; // Create the changelog manager $this->changelogManager = new ChangelogManager(Context::getParam('project-root') . '/' . $options['location'], $format); }
public function execute() { // Handle the commits dump if ($this->options['dump-commits'] == true) { try { $extraLines = Context::get('vcs')->getAllModificationsSince(Context::get('version-persister')->getCurrentVersionTag(), false, $this->options['exclude-merge-commits']); $this->options['extra-lines'] = $extraLines; } catch (NoReleaseFoundException $e) { Context::get('output')->writeln('<error>No commits dumped as this is the first release</error>'); } unset($this->options['dump-commits']); } $manager = new ChangelogManager($this->options['file'], $this->options['format']); $manager->update(Context::getParam('new-version'), Context::get('information-collector')->getValueFor('comment'), array_merge(array('type' => Context::get('information-collector')->getValueFor('type', null)), $this->options)); $this->confirmSuccess(); }
/** * will update a given filename with the current version * * @param string $filename * * @throws \Liip\RMT\Exception */ protected function updateFile($filename) { $current = Context::getParam('current-version'); $next = Context::getParam('new-version'); $content = file_get_contents($filename); if (false === strpos($content, $current)) { throw new Exception('The version class ' . $filename . " does not contain the current version {$current}"); } if (isset($this->options['pattern'])) { $current = str_replace('%version%', $current, $this->options['pattern']); $next = str_replace('%version%', $next, $this->options['pattern']); } $content = str_replace($current, $next, $content); if (false === strpos($content, $next)) { throw new Exception('The version class ' . $filename . " could not be updated with version {$next}"); } file_put_contents($filename, $content); }
public function execute() { if ($this->options['ask-confirmation']) { // Ask the question if there is no confirmation yet $ic = Context::get('information-collector'); if (!$ic->hasValueFor(self::AUTO_PUBLISH_OPTION)) { $answer = Context::get('output')->askConfirmation('Do you want to publish your release (default: <green>y</green>): ', Context::get('input')); $ic->setValueFor(self::AUTO_PUBLISH_OPTION, $answer == true ? 'y' : 'n'); } // Skip if the user didn't ask for publishing if ($ic->getValueFor(self::AUTO_PUBLISH_OPTION) !== 'y') { Context::get('output')->writeln('<error>requested to be ignored</error>'); return; } } Context::get('vcs')->publishChanges($this->getRemote()); Context::get('vcs')->publishTag(Context::get('version-persister')->getTagFromVersion(Context::getParam('new-version')), $this->getRemote()); $this->confirmSuccess(); }
public function execute() { // Output for devs $newVersion = Context::getParam('new-version'); // newscoop/library/Newscoop/Version.php $appFile = realpath(__DIR__ . '/../library/Newscoop/Version.php'); Context::get('output')->writeln("New version [<yellow>{$newVersion}</yellow>] udpated into {$appFile}: "); $fileContent = file_get_contents($appFile); $fileContent = preg_replace('/(.*const VERSION = .*;)/', " const VERSION = '{$newVersion}';", $fileContent); file_put_contents($appFile, $fileContent); // newscoop/template_engine/classes/CampVersion.php $appFile = realpath(__DIR__ . '/../template_engine/classes/CampVersion.php'); Context::get('output')->writeln("New version [<yellow>{$newVersion}</yellow>] udpated into {$appFile}: "); $fileContent = file_get_contents($appFile); $fileContent = preg_replace('/(.*private \\$m_release = .*;)/', ' private $m_release = \'' . $newVersion . '\';', $fileContent); $fileContent = preg_replace('/(.*private \\$m_releaseDate = .*;)/', ' private $m_releaseDate = \'' . date('Y-m-d') . '\';', $fileContent); $fileContent = preg_replace('/(.*private \\$m_copyrightYear = .*;)/', ' private $m_copyrightYear = ' . date('Y') . ';', $fileContent); file_put_contents($appFile, $fileContent); $this->confirmSuccess(); }
/** * Constructor. * * @param \Liip\RMT\Context $context * @throws \Liip\RMT\Exception */ public function __construct(Context $context = null) { if ($context !== null) { $this->setComposerFile($context->getParam('project-root') . '/composer.json'); } }
/** * Always executed, but first initialize and interact have already been called * * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // Get the current version or generate a new one if the user has confirm that this is required try { $currentVersion = Context::get('version-persister')->getCurrentVersion(); } catch (\Liip\RMT\Exception\NoReleaseFoundException $e) { if (Context::get('information-collector')->getValueFor('confirm-first') == false) { throw $e; } $currentVersion = Context::get('version-generator')->getInitialVersion(); } Context::getInstance()->setParameter('current-version', $currentVersion); // Generate and save the new version number $newVersion = Context::get('version-generator')->generateNextVersion(Context::getParam('current-version')); Context::getInstance()->setParameter('new-version', $newVersion); $this->executeActionListIfExist('pre-release-actions'); $this->getOutput()->writeSmallTitle('Release process'); $this->getOutput()->indent(); $this->getOutput()->writeln("A new version named [<yellow>{$newVersion}</yellow>] is going to be released"); Context::get('version-persister')->save($newVersion); $this->getOutput()->writeln('Release: <green>Success</green>'); $this->getOutput()->unIndent(); $this->executeActionListIfExist('post-release-actions'); }
public function execute() { Context::get('vcs')->createTag(Context::get('vcs')->getTagFromVersion(Context::getParam('new-version'))); $this->confirmSuccess(); }