From 745198e4062371e14c8ed4eb73b3929cb6dac74c Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Wed, 6 Feb 2019 14:17:30 +0100 Subject: [PATCH] Add Robofile commands for changelog update and get [MAILPOET-1770] --- .env.sample | 2 ++ README.md | 3 +++ RoboFile.php | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/.env.sample b/.env.sample index 16ceb7df54..b87561a0b0 100644 --- a/.env.sample +++ b/.env.sample @@ -25,3 +25,5 @@ WP_TEST_MAILER_SMTP_PASSWORD="" WP_SVN_USERNAME="" WP_SVN_PASSWORD="" WP_TRANSIFEX_API_TOKEN="" +WP_JIRA_USER="" // Jira username/email +WP_JIRA_TOKEN="" // Jira token (https://confluence.atlassian.com/cloud/api-tokens-938839638.html) or password diff --git a/README.md b/README.md index 52da4e38e3..594271f960 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,9 @@ $ ./do qa:lint:javascript # JS code linter. $ ./do qa:phpstan # PHP code static analysis using PHPStan. $ ./do qa # PHP and JS linters. +$ ./do changelog:get [--version-name=...] # Prints out changelog and release notes for given version or for newest version. +$ ./do changelog:update [--version-name=...] [--quiet] # Updates changelog in readme.txt for given version or for newest version. + $ ./do container:dump # Generates DI container cache. ``` diff --git a/RoboFile.php b/RoboFile.php index cc0c78b060..f33940863a 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -550,6 +550,22 @@ class RoboFile extends \Robo\Tasks { ->run(); } + function changelogUpdate($opts = ['version-name' => null]) { + $this->say("Updating changelog"); + $outputs = $this->getChangelogController()->update($opts['version-name']); + if($opts['quiet']) { + return; + } + $this->say("Changelog \n{$outputs[0]} \n{$outputs[1]}\n\n"); + $this->say("IMPORTANT NOTES \n" . ($outputs[2] ?: 'none')); + } + + function changelogGet($opts = ['version-name' => null]) { + $outputs = $this->getChangelogController()->get($opts['version-name']); + $this->say("Changelog \n{$outputs[0]} \n{$outputs[1]}\n"); + $this->say("IMPORTANT NOTES \n" . ($outputs[2] ?: 'none')); + } + protected function loadEnv() { $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); @@ -561,6 +577,17 @@ class RoboFile extends \Robo\Tasks { return !empty($m[1]) ? trim($m[1]) : false; } + protected function getChangelogController() { + require_once './tasks/release/ChangelogController.php'; + $this->loadEnv(); + return \MailPoetTasks\Release\ChangelogController::createWithJiraCredentials( + getenv('WP_JIRA_TOKEN'), + getenv('WP_JIRA_USER'), + \MailPoetTasks\Release\Jira::PROJECT_MAILPOET, + __DIR__ . '/readme.txt' + ); + } + public function testAcceptanceGroupTests() { return $this->taskSplitTestFilesByGroups(4) ->projectRoot('.')