/** * Run the build with the provided commandline parameters. * * @param $argv * Array of commandline parameters passed to the script. */ function main($argv) { if (count($argv) !== 3) { print 'Usage:' . PHP_EOL; print 'php build.php [[optional branch key].][.run file name] [section in .run file]' . PHP_EOL; exit(1); } $branch = ''; if (strpos($argv[1], '.') === FALSE) { $run_file_name = $argv[1] . '.run'; } else { list($branch, $run_file_name) = explode('.', $argv[1]); $run_file_name .= '.run'; } $command_set = trim($argv[2]); try { $variables = parse_variable_file(__DIR__ . '/build.ini', $branch); $commands = parse_run_file(__DIR__ . '/' . $run_file_name); if (!empty($commands[$command_set])) { $commands = $commands[$command_set]; } else { throw new InvalidArgumentException('Could not access command set: ' . '[' . $command_set . ']'); } } catch (Exception $e) { print $e->getMessage() . PHP_EOL; exit(1); } if (isset($variables['all'])) { foreach ($variables['all'] as $key => $vars) { run_commands($commands, $vars); } } else { if (isset($variables['master'])) { run_commands($commands, $variables['master']); } } }
// Performing check according to: https://getcomposer.org/doc/04-schema.md#version $regexp = '/^[0-9]+\\.[0-9]+\\.[0-9]+(?:-(?:dev|rc\\.[0-9]+))?$/'; if (!preg_match($regexp, $version, $matches)) { echo "Bad version format. You must follow the format of X.Y.Z with an optional suffix of -dev," . " or -rc.N (where N is a number).\n"; exit(1); } function run_commands($commands) { foreach ($commands as $command) { echo "{$command}\n"; passthru($command, $returnVal); if ($returnVal !== 0) { echo "Error executing command! Interrupting!\n"; exit(2); } } } $elggPath = dirname(__DIR__); $branch = "release-{$version}"; // Setup. Version checks are here so we fail early if any deps are missing run_commands(array("tx --version", "git --version", "npm --version", "node --version", "sphinx-build --version", "cd {$elggPath}", "git checkout -B {$branch}")); // Update translations run_commands(array("tx pull -a --minimum-perc=100", "sphinx-build -b gettext docs docs/locale/pot", "sphinx-intl --locale-dir=docs/locale/ build", "git add .", "git commit -am \"chore(i18n): update translations\"")); // Update version in composer.json $composerPath = "{$elggPath}/composer.json"; $composerJson = json_decode(file_get_contents($composerPath)); $composerJson->version = $version; file_put_contents($composerPath, json_encode($composerJson, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); // Generate changelog run_commands(array("npm install && npm update", "node .scripts/write-changelog.js", "git add .", "git commit -am \"chore(release): v{$version}\""));
if (!isset($argv[1]) || $argv[1] == '--help') { echo "Usage: php .scripts/languages.php <branch>\n"; exit; } $branch = $argv[1]; require_once dirname(__DIR__) . '/vendor/autoload.php'; function run_commands($commands) { foreach ($commands as $command) { echo "{$command}\n"; passthru($command, $return_val); if ($return_val !== 0) { echo "Error executing command! Interrupting!\n"; exit(2); } } } $new_branch = "{$branch}_i18n_" . time(); $elgg_path = dirname(__DIR__); // Setup. Version checks are here so we fail early if any deps are missing run_commands(["tx --version", "git --version", "cd {$elgg_path}", "git checkout -B {$new_branch}", "tx pull -af --minimum-perc=95"]); // Clean translations $cleaner = new Elgg\I18n\ReleaseCleaner(); $cleaner->cleanInstallation(dirname(__DIR__)); foreach ($cleaner->log as $msg) { echo "ReleaseCleaner: {$msg}\n"; } run_commands(["git add .", "git commit -am \"chore(i18n): update translations\""]); echo "Please submit '{$new_branch}' as a pull request:\n\n"; echo " git push -u <fork_remote> {$new_branch}\n";
$regexp = '/^[0-9]+\\.[0-9]+\\.[0-9]+(?:-(?:alpha|beta|rc)\\.[0-9]+)?$/'; if (!preg_match($regexp, $version, $matches)) { echo "Bad version format. You must follow the format of X.Y.Z with an optional suffix of" . " -alpha.N, -beta.N, or -rc.N (where N is a number).\n"; exit(1); } require_once dirname(__DIR__) . '/vendor/autoload.php'; function run_commands($commands) { foreach ($commands as $command) { echo "{$command}\n"; passthru($command, $return_val); if ($return_val !== 0) { echo "Error executing command! Interrupting!\n"; exit(2); } } } $elgg_path = dirname(__DIR__); $branch = "release-{$version}"; // Setup. Version checks are here so we fail early if any deps are missing run_commands(["git --version", "npm --version", "node --version", "sphinx-build --version", "cd {$elgg_path}", "git checkout -B {$branch}"]); // Update version in composer.json $encoding = new \Elgg\Json\EmptyKeyEncoding(); $composer_path = "{$elgg_path}/composer.json"; $composer_config = $encoding->decode(file_get_contents($composer_path)); $composer_config->version = $version; $json = $encoding->encode($composer_config, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); file_put_contents($composer_path, $json); // Generate changelog run_commands(array("sphinx-build -b gettext docs docs/locale/pot", "sphinx-intl build --locale-dir=docs/locale/", "npm install && npm update", "node .scripts/write-changelog.js", "git add .", "git commit -am \"chore(release): v{$version}\""));
#!/usr/bin/env php <?php require_once __DIR__ . '/vendor/autoload.php'; use Symfony\Component\Process\Process; $commands = array('php vendor/bin/phpunit', 'php vendor/bin/behat --format=progress --ansi'); exit(run_commands($commands)); function run_commands($commands) { return array_reduce($commands, function ($exitCode, $command) { return run_command($command) !== 0 ? 1 : $exitCode; }, 0); } function run_command($command) { $process = new Process($command); $process->run(function ($type, $data) { if ('out' === $type) { echo $data; } }); return $process->getExitCode(); }
$low_locale = join('-', $tags_locale); } else { $t = 'default'; } $commands[] = "php '{$glotpress_path}/scripts/export.php' -p {$glotpress_project} -l {$low_locale} -t {$t} -o po > {$pot_git_checkout}{$relative_po_path}/{$locale}/LC_MESSAGES/{$locale}.po"; //$commands[] = "php '{$glotpress_path}/scripts/export.php' -p {$glotpress_project} -l {$low_locale} -t {$t} -o mo > {$pot_git_checkout}{$relative_po_path}/{$locale}/LC_MESSAGES/{$locale}.mo"; $po_files[] = "{$pot_git_checkout}{$relative_po_path}/{$locale}/LC_MESSAGES/{$locale}.po"; } } closedir($dh); } $commit_message = join("\n", $commit_message); } } // Make the POs run_commands($commands); // Make the MOs if (!empty($po_files) && !$dry_run) { require_once 'php-mo.php'; foreach ($po_files as $po_file) { phpmo_convert($po_file); } } // Only commit if required if (!$exists || $real_differences || !empty($commit_message)) { if (empty($commit_message)) { $commit_message = 'Dev Automatic translation update'; } $commands = array("git commit -am '{$commit_message}'", "git push origin {$branch}"); run_commands($commands); }