diff --git a/src/Commands/Release/Archive.php b/src/Commands/Release/Archive.php index 29abb75..15c41e2 100644 --- a/src/Commands/Release/Archive.php +++ b/src/Commands/Release/Archive.php @@ -9,10 +9,9 @@ * * @author dmooyman */ -class Archive extends Release { +class Archive extends Publish { /** - * * @var string */ protected $name = 'release:archive'; diff --git a/src/Commands/Release/Push.php b/src/Commands/Release/Push.php index b5e3c43..77d70a3 100644 --- a/src/Commands/Release/Push.php +++ b/src/Commands/Release/Push.php @@ -9,7 +9,7 @@ * * @author dmooyman */ -class Push extends Release { +class Push extends Publish { /** * @var string diff --git a/src/Commands/Release/Release.php b/src/Commands/Release/Release.php index f4986f8..8839420 100644 --- a/src/Commands/Release/Release.php +++ b/src/Commands/Release/Release.php @@ -82,15 +82,6 @@ protected function getInputVersion() { return new ReleaseVersion($value); } - /** - * Get the aws profile to use - * - * @return silverstripe - */ - public function getInputAWSProfile() { - return $this->input->getOption('aws-profile'); - } - /** * Determine the branch name that should be used * diff --git a/src/Commands/Release/Tag.php b/src/Commands/Release/Tag.php index 8edc00d..7afe7dc 100644 --- a/src/Commands/Release/Tag.php +++ b/src/Commands/Release/Tag.php @@ -9,10 +9,9 @@ * * @author dmooyman */ -class Tag extends Release { +class Tag extends Publish { /** - * * @var string */ protected $name = 'release:tag'; diff --git a/src/Commands/Release/Upload.php b/src/Commands/Release/Upload.php index 6baa03f..5e34e62 100644 --- a/src/Commands/Release/Upload.php +++ b/src/Commands/Release/Upload.php @@ -9,10 +9,9 @@ * * @author dmooyman */ -class Upload extends Release { +class Upload extends Publish { /** - * * @var string */ protected $name = 'release:upload'; diff --git a/src/Model/ReleaseVersion.php b/src/Model/ReleaseVersion.php index 01ba722..0ca703d 100644 --- a/src/Model/ReleaseVersion.php +++ b/src/Model/ReleaseVersion.php @@ -186,7 +186,7 @@ public function getReleaseFilenames() { /** * For this version, generate the filename * - * @param bol $includeCMS Does this include CMS? + * @param bool $includeCMS Does this include CMS? * @param string $extension archive extension (including period) * @return string */ diff --git a/src/Steps/Release/BuildArchive.php b/src/Steps/Release/BuildArchive.php index e4480e4..31dde8a 100644 --- a/src/Steps/Release/BuildArchive.php +++ b/src/Steps/Release/BuildArchive.php @@ -2,6 +2,7 @@ namespace SilverStripe\Cow\Steps\Release; +use Exception; use SilverStripe\Cow\Commands\Command; use SilverStripe\Cow\Model\Project; use SilverStripe\Cow\Model\ReleaseVersion; @@ -63,7 +64,7 @@ public function run(InputInterface $input, OutputInterface $output) { $this->log($output, "Generating new archive files"); $path = $this->createProject($output); $this->buildFiles($output, $path); - $this->log($output, 'Upload complete'); + $this->log($output, 'Archive complete'); } /** @@ -99,7 +100,7 @@ protected function unlink($folder) { * * @param string $from * @param string $to - * @throws \Exception + * @throws Exception */ protected function copy($from, $to) { $this->unlink($to); @@ -107,14 +108,14 @@ protected function copy($from, $to) { // Copy file if not a folder if(!is_dir($from)) { if(copy($from, $to) === false) { - throw new \Exception("Could not copy from {$from} to {$to}"); + throw new Exception("Could not copy from {$from} to {$to}"); } return; } // Create destination if(mkdir($to) === false) { - throw new \Exception("Could not create destination folder {$to}"); + throw new Exception("Could not create destination folder {$to}"); } // Iterate files @@ -133,12 +134,12 @@ protected function copy($from, $to) { * * @param string $path * @param string $content - * @throws \Exception + * @throws Exception */ protected function write($path, $content) { $result = file_put_contents($path, $content); if($result === false) { - throw new \Exception("Could not write to {$path}"); + throw new Exception("Could not write to {$path}"); } } @@ -216,20 +217,26 @@ protected function createProject(OutputInterface $output) { * @param string $path Location of project to archive */ protected function buildFiles(OutputInterface $output, $path) { - /* $version = $this->getVersion()->getValue(); $cmsArchive = "SilverStripe-cms-v{$version}"; $frameworkArchive = "SilverStripe-framework-v{$version}"; - $destination = $this->getProject()->getDirectory(); - - // Build tar files - $phar = new PharData($destination . '/' . $cmsArchive); - foreach($this->getVersion()->getReleaseFilenames() as $filename) { - // Build paths - $this->log($output, "Uploading {$filename}"); - $from = $this->getProject()->getDirectory() . '/' . $filename; - }*/ + // Build each version + foreach(array($cmsArchive, $frameworkArchive) as $archive) { + $sourceDirArg = escapeshellarg("{$path}/{$archive}/"); + + // Build tar files + $tarFile = "{$destination}/{$archive}.tar.gz"; + $this->log($output, "Building $tarFile"); + $tarFileArg = escapeshellarg($tarFile); + $this->runCommand($output, "cd {$sourceDirArg} && tar -cvzf {$tarFileArg} ."); + + // Build zip files + $zipFile = "{$destination}/{$archive}.zip"; + $this->log($output, "Building {$zipFile}"); + $zipFileArg = escapeshellarg($zipFile); + $this->runCommand($output, "cd {$sourceDirArg} && zip -rv {$zipFileArg} ."); + } } }