From 8e0283b4dd9f6e38aa1cb7bb29bf6bbbcde0b0ab Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Tue, 5 Apr 2022 15:02:24 -0300 Subject: [PATCH] Update release:publish to use mailpoet.pot file from CircleCI This commit changes the Robo command release:publish to use the mailpoet.pot file that is present in the zip file in the release branch of the CircleCI build. Before we were using the mailpoet.pot file present in the local repository, which meant it could contain undesired local changes that should not be included when creating a new MailPoet release. A new Robo command was created to get the zip file from CircleCI called translations:get-pot-file-from-circle-ci. The old translations:build was preserved as it is used inside mailpoet/build.sh. [MAILPOET-4173] --- mailpoet/RoboFile.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/mailpoet/RoboFile.php b/mailpoet/RoboFile.php index 1a3717eb69..0881abcf92 100644 --- a/mailpoet/RoboFile.php +++ b/mailpoet/RoboFile.php @@ -111,6 +111,36 @@ class RoboFile extends \Robo\Tasks { )->run(); } + public function translationsGetPotFileFromCircleCI() { + $potFilePathInsideZip = 'mailpoet/lang/mailpoet.pot'; + $potFilePath = 'lang/mailpoet.pot'; + + if (!is_file(self::ZIP_BUILD_PATH)) { + $this->yell('mailpoet.zip file is missing. You must first download it from CircleCI using `./do release:download-zip`.', 40, 'red'); + exit(1); + } + + if (!is_file('mailpoet/lang')) { + $this->taskExec('mkdir -p ' . __DIR__ . '/lang')->run(); + } + + $zip = new ZipArchive(); + + if ($zip->open(self::ZIP_BUILD_PATH) === true) { + $potFileContent = $zip->getFromName($potFilePathInsideZip); + if ($potFileContent) { + file_put_contents($potFilePath, $potFileContent); + $this->say('mailpoet.pot extracted from the zip file to ' . $potFilePath); + } else { + $this->yell('Unable to find mailpoet.pot inside the zip file.', 40, 'red'); + exit(1); + } + } else { + $this->yell('Unable to open the zip file.', 40, 'red'); + exit(1); + } + } + public function translationsPush() { $tokenEnvName = 'WP_TRANSIFEX_API_TOKEN'; $token = getenv($tokenEnvName); @@ -820,7 +850,7 @@ class RoboFile extends \Robo\Tasks { return $this->releaseDownloadZip(); }) ->addCode(function () { - return $this->translationsBuild(); + return $this->translationsGetPotFileFromCircleCI(); }) ->addCode(function () { return $this->translationsPush();