From a0d2be50e8f205e1cae91bc972d5a26ec1808e04 Mon Sep 17 00:00:00 2001 From: Alexey Stoletniy Date: Thu, 16 Mar 2017 15:11:38 +0300 Subject: [PATCH] Upload translation files to Transifex via publish command [MAILPOET-855] --- README.md | 10 +++++++--- RoboFile.php | 25 ++++++++++++++++++++++++- tasks/pack_translations.sh | 9 --------- tasks/transifex_init.sh | 10 ++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 tasks/transifex_init.sh diff --git a/README.md b/README.md index 1a3b4206cc..27394108d5 100644 --- a/README.md +++ b/README.md @@ -144,12 +144,16 @@ Finally , a `WP_TRANSIFEX_API_TOKEN` environment variable should be initialized # Publish -Before you run a publishing command, you need to: +The `publish` command currently does the following: +* Pushes translations POT file to Transifex; +* Publishes the release in SVN. + +Before you run it, you need to: 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. 3. Run `./build.sh` to produce a `mailpoet.zip` distributable archive. -Everything's ready? Then run `./do svn:publish`. +Everything's ready? Then run `./do publish`. 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 @@ -157,4 +161,4 @@ 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. -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. +If you're confident, execute `./do 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. diff --git a/RoboFile.php b/RoboFile.php index 000e1aa947..8eeb91f876 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -104,10 +104,24 @@ class RoboFile extends \Robo\Tasks { ); } + function pushpot() { + return $this->collectionBuilder() + ->addCode(array($this, 'txinit')) + ->taskExec('tx push -s') + ->run(); + } + function packtranslations() { + return $this->collectionBuilder() + ->addCode(array($this, 'txinit')) + ->taskExec('./tasks/pack_translations.sh') + ->run(); + } + + function txinit() { // Define WP_TRANSIFEX_API_TOKEN env. variable $this->loadEnv(); - return $this->_exec('./tasks/pack_translations.sh'); + return $this->_exec('./tasks/transifex_init.sh'); } function testUnit($opts=['file' => null, 'xml' => false]) { @@ -311,6 +325,15 @@ class RoboFile extends \Robo\Tasks { return $result; } + public function publish($opts = ['force' => false]) { + return $this->collectionBuilder() + ->addCode(array($this, 'pushpot')) + ->addCode(function () use ($opts) { + return $this->svnPublish($opts); + }) + ->run(); + } + protected function loadEnv() { $dotenv = new Dotenv\Dotenv(__DIR__); $dotenv->load(); diff --git a/tasks/pack_translations.sh b/tasks/pack_translations.sh index 975f3a59f8..3d723bbbce 100755 --- a/tasks/pack_translations.sh +++ b/tasks/pack_translations.sh @@ -1,14 +1,5 @@ #!/bin/bash -# Write .transifexrc file if not exists -if [ ! -f ~/.transifexrc ]; then - echo "[https://www.transifex.com]" > ~/.transifexrc - echo "hostname = https://www.transifex.com" >> ~/.transifexrc - echo "username = api" >> ~/.transifexrc - echo "password = $WP_TRANSIFEX_API_TOKEN" >> ~/.transifexrc - echo "token =" >> ~/.transifexrc -fi - echo "Getting translations from Transifex..." tx pull -a -f diff --git a/tasks/transifex_init.sh b/tasks/transifex_init.sh new file mode 100644 index 0000000000..6693b99584 --- /dev/null +++ b/tasks/transifex_init.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Write ~/.transifexrc file if not exists +if [ ! -f ~/.transifexrc ]; then + echo "[https://www.transifex.com]" > ~/.transifexrc + echo "hostname = https://www.transifex.com" >> ~/.transifexrc + echo "username = api" >> ~/.transifexrc + echo "password = $WP_TRANSIFEX_API_TOKEN" >> ~/.transifexrc + echo "token =" >> ~/.transifexrc +fi