Liip\RMT\Command\ReleaseCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    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');
    }

Usage Example

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $detector = new GitFlowBranch($this->getContext()->getVCS());
     $newVersion = $detector->getCurrentVersion();
     $this->getContext()->setNewVersion($newVersion);
     $currentVersion = $this->getContext()->getVersionDetector()->getCurrentVersion();
     $type = $currentVersion->getDifferenceType($newVersion);
     if ($type === null) {
         throw new Exception('Could not detect a version difference.', 404);
     }
     $this->getContext()->setParameter('type', $type);
     //in case the type information is needed...
     $this->getContext()->getInformationCollector()->registerStandardRequest('type');
     $this->getContext()->getInformationCollector()->setValueFor('type', $type);
     //push a git flow finish action to the post release list
     $action = new GitFlowFinishAction($detector->getBranchType());
     $action->setContext($this->getContext());
     $this->getContext()->getList(Context::POSTRELEASE_LIST)->push($action);
     parent::execute($input, $output);
 }