Add force mode to svn:publish command, add svn:checkout command

This commit is contained in:
Alexey Stoletniy
2016-12-15 16:20:12 +03:00
parent 71711b4a0d
commit dfa13726e7
3 changed files with 31 additions and 7 deletions

View File

@ -14,3 +14,5 @@ WP_TEST_MAILER_SENDGRID_API=""
WP_TEST_MAILER_SMTP_HOST="" WP_TEST_MAILER_SMTP_HOST=""
WP_TEST_MAILER_SMTP_LOGIN="" WP_TEST_MAILER_SMTP_LOGIN=""
WP_TEST_MAILER_SMTP_PASSWORD="" WP_TEST_MAILER_SMTP_PASSWORD=""
WP_SVN_USERNAME=""
WP_SVN_PASSWORD=""

View File

@ -132,14 +132,16 @@ You can use Twig i18n functions in Handlebars, just load your template from a Tw
# Publish # Publish
Before you run a publishing command, you need to: Before you run a publishing command, you need to:
1. Set up a local copy of MailPoet SVN repository in `.mp_svn` directory. Sample command: `svn co https://plugins.svn.wordpress.org/mailpoet/ .mp_svn`. The repo should be up-to-date. 1. Ensure there is an up-to-date local copy of MailPoet SVN repository in `.mp_svn` directory by running `./do svn:checkout`.
2. Have all your features merged in Git `master`, your `mailpoet.php` and `readme.txt` tagged with a new version. 2. Have all your features merged in Git `master`, your `mailpoet.php` and `readme.txt` tagged with a new version.
3. Run `./build.sh` to produce a `mailpoet.zip` distributable archive. 3. Run `./build.sh` to produce a `mailpoet.zip` distributable archive.
Everything's ready? Then run `./do publish`. Everything's ready? Then run `./do svn:publish`.
If the job goes fine, you'll get a message like this: If the job goes fine, you'll get a message like this:
``` ```
Go to '.mp_svn' and run 'svn ci -m "Release 3.0.0-beta.9"' to publish the Go to '.mp_svn' and run 'svn ci -m "Release 3.0.0-beta.9"' to publish the
release release
``` ```
It's quite literal: you can review the changes to be pushed and if you're satisfied, run the suggested command to finish the release publishing process. It's quite literal: you can review the changes to be pushed and if you're satisfied, run the suggested command to finish the release publishing process.
If you're confident, execute `./do svn:publish --force` and your release will be published to the remote SVN repository without manual intervention (automatically). For easier authentication you might want to set `WP_SVN_USERNAME` and `WP_SVN_PASSWORD` environment variables.

View File

@ -199,7 +199,11 @@ class RoboFile extends \Robo\Tasks {
); );
} }
function publish() { function svnCheckout() {
return $this->_exec('svn co https://plugins.svn.wordpress.org/mailpoet/ .mp_svn');
}
function svnPublish($opts = ['force' => false]) {
$this->loadWP(); $this->loadWP();
$svn_dir = ".mp_svn"; $svn_dir = ".mp_svn";
@ -270,11 +274,27 @@ class RoboFile extends \Robo\Tasks {
$result = $collection->run(); $result = $collection->run();
if($result->wasSuccessful()) { if($result->wasSuccessful()) {
// Run or suggest release command depending on a flag
$release_cmd = "svn ci -m \"Release $plugin_version\""; $release_cmd = "svn ci -m \"Release $plugin_version\"";
if(!empty($opts['force'])) {
$svn_login = getenv('WP_SVN_USERNAME');
$svn_password = getenv('WP_SVN_PASSWORD');
if ($svn_login && $svn_password) {
$release_cmd .= " --username $svn_login --password $svn_password";
} else {
$release_cmd .= ' --force-interactive';
}
$result = $this->taskExecStack()
->stopOnFail()
->dir($svn_dir)
->exec($release_cmd)
->run();
} else {
$this->yell( $this->yell(
"Go to '$svn_dir' and run '$release_cmd' to publish the release" "Go to '$svn_dir' and run '$release_cmd' to publish the release"
); );
} }
}
return $result; return $result;
} }