From 01487d86be2ea2b25670069ac85e0eda840c4c25 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Dec 2024 21:42:16 +0200 Subject: [PATCH] Execute PHAR after building Closes #26 --- src/SvnBuddyUpdater/ReleaseManager.php | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/SvnBuddyUpdater/ReleaseManager.php b/src/SvnBuddyUpdater/ReleaseManager.php index 84dc477..ce224a9 100644 --- a/src/SvnBuddyUpdater/ReleaseManager.php +++ b/src/SvnBuddyUpdater/ReleaseManager.php @@ -13,6 +13,7 @@ use Aws\S3\S3Client; use ConsoleHelpers\ConsoleKit\ConsoleIO; +use ConsoleHelpers\ConsoleKit\Exception\CommandException; use Github\Client; use Github\HttpClient\CachedHttpClient; use Symfony\Component\Process\ProcessBuilder; @@ -312,12 +313,38 @@ private function _createPhar($commit_hash, $stability) $phar_file = $this->_snapshotsPath . '/svn-buddy.phar'; $signature_file = $this->_snapshotsPath . '/svn-buddy.phar.sig'; + $this->_executePhar($phar_file); + return $this->_uploadToS3( $stability . 's/' . $commit_hash, array($phar_file, $signature_file) ); } + /** + * Executes a PHAR file. + * + * @param string $phar_file Path to a PHAR file. + * + * @return void + * @throws CommandException When PHAR execution ended with an error. + */ + private function _executePhar($phar_file) + { + $this->_io->writeln(' * executing phar file ... '); + + $exit_code = 0; + $output = array(); + exec('php ' . escapeshellarg($phar_file), $output, $exit_code); + + $this->_io->writeln(array('Exit Code: ' . $exit_code, 'Output:')); + $this->_io->writeln($output); + + if ( $exit_code !== 0 ) { + throw new CommandException('Failed to execute "' . $phar_file . '" phar file.'); + } + } + /** * Deletes old releases. *