public function RoboFile::releaseCreate in Panopoly 7
Release Stage 1: results in local tag and commit for the new version.
@option $clean If passed, the repos under `release/` will be cleaned up before starting.
Parameters
string $old_version: The previous version.
string $new_version: The new version.
Return value
\Robo\Collection\CollectionBuilder
Throws
\Exception
1 call to RoboFile::releaseCreate()
- RoboFile::release in ./
RoboFile.php - Runs all 3 stages of the release process in order.
File
- ./
RoboFile.php, line 705
Class
- RoboFile
- This is project's console commands configuration for Robo task runner.
Code
public function releaseCreate($old_version, $new_version, $opts = [
'clean' => FALSE,
]) {
$branch = static::PANOPOLY_DEFAULT_BRANCH;
if ($this
->getCurrentBranch() !== $branch) {
throw new \Exception("Only run this command on the {$branch} branch");
}
if ($this
->runProcess("git status -s -uno")
->getOutput() !== '') {
throw new \Exception("Cannot do release because there are uncommitted changes");
}
// If git tag already exists, then bail completely.
if ($this
->runProcess("git rev-parse {$new_version}")
->getExitCode() === 0) {
throw new \Exception("Tag {$new_version} already exists");
}
$commit_message = "Updated CHANGELOG.txt for {$new_version} release.";
$commits = $this
->runProcess("git log --oneline --grep='{$commit_message}'")
->getOutput();
if (strpos($commits, $commit_message) !== FALSE) {
throw new \Exception("The commit message '{$commit_message}' is already used. You should check it, and if all is good, create the {$new_version} tag.");
}
/** @var \Robo\Collection\CollectionBuilder|$this $collection */
$collection = $this
->collectionBuilder();
$collection
->taskGitStack()
->pull();
$collection
->addTask($this
->checkoutManyreposForRelease($branch, $opts['clean']));
// Update all the CHANGELOG.txt files in the monorepo (except for
// panopoly_demo, which needs to get updated in its own repo).
foreach ($this
->getPanopolyFeaturesNames() as $panopoly_feature => $panopoly_feature_name) {
$panopoly_feature_release_path = "release/{$panopoly_feature}";
$panopoly_feature_source_path = "modules/panopoly/{$panopoly_feature}";
// For panopoly_demo, this needs to be updated in its separate repo.
if ($panopoly_feature === 'panopoly_demo') {
$panopoly_feature_source_path = $panopoly_feature_release_path;
}
// @todo Probably should be a custom Task
$collection
->addCode(function () use ($old_version, $new_version, $branch, $panopoly_feature_name, $panopoly_feature_release_path, $panopoly_feature_source_path) {
$drush_rn = $this
->runDrush("rn {$old_version} {$branch} --changelog 2>/dev/null", $panopoly_feature_release_path)
->getOutput();
$this
->updateChangelog("{$panopoly_feature_source_path}/CHANGELOG.txt", $panopoly_feature_name, $new_version, $drush_rn);
});
if ($panopoly_feature === 'panopoly_demo') {
$collection
->taskExec("git -C {$panopoly_feature_release_path} add CHANGELOG.txt");
}
else {
$collection
->taskGitStack()
->add("{$panopoly_feature_source_path}/CHANGELOG.txt");
}
}
// Do top-level CHANGELOG.txt too.
// @todo Probably should be a custom Task
$collection
->addCode(function () use ($old_version, $new_version, $branch) {
$drush_rn = $this
->runDrush("rn {$old_version} {$branch} --changelog 2>/dev/null")
->getOutput();
$this
->updateChangelog("CHANGELOG.txt", 'Panopoly', $new_version, $drush_rn);
});
$collection
->taskGitStack()
->add("CHANGELOG.txt");
// Commit the CHANGELOG.txt changes, and tag everything.
$collection
->taskExecStack()
->exec("git -C release/panopoly_demo commit -m '{$commit_message}'")
->exec("git -C release/panopoly_demo tag {$new_version}");
$collection
->taskGitStack()
->commit($commit_message)
->tag($new_version);
return $collection;
}