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]
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user