From a518e3b7b35902dd184a78994c816b28cfb6442b Mon Sep 17 00:00:00 2001 From: Pierre Rudloff Date: Mon, 22 Jun 2020 23:15:31 +0200 Subject: [PATCH] Create release package cleanly from a temporary folder (#279) --- RoboFile.php | 61 ++++++++++++++++++--------------------------------- composer.json | 2 +- 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/RoboFile.php b/RoboFile.php index 6481aa6..53f97fd 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -1,7 +1,6 @@ stopOnFail(); + $result = $this->taskExec('git') - ->args('describe') + ->arg('describe') ->run(); $result->provideOutputdata(); - $tag = trim($result->getOutputData()); - // We don't want the whole vendor directory. - $finder = new Finder(); - $finder->files() - ->in(__DIR__ . '/vendor/') - ->exclude( - [ - 'ffmpeg/', - 'phpstan/', - 'bin/', - 'anam/phantomjs-linux-x86-binary/', - 'phpunit/', - 'squizlabs/', - 'rinvex/countries/resources/geodata/', - 'rinvex/countries/resources/flags/' - ] - ); + $tmpDir = $this->_tmpDir(); - $zipTask = $this->taskPack('alltube-' . $tag . '.zip') - ->add('index.php') - ->add('config/config.example.yml') - ->add('.htaccess') - ->add('img') - ->add('LICENSE') - ->add('README.md') - ->add('robots.txt') - ->add('resources') - ->add('templates') - ->add('templates_c/') - ->add('classes') - ->add('controllers') - ->add('css') - ->add('i18n'); + $filename = 'alltube-' . trim($result->getOutputData()) . '.zip'; - foreach ($finder as $file) { - if ($path = $file->getRelativePathname()) { - $zipTask->add('vendor/' . $path); - } - } + $this->taskFilesystemStack() + ->remove($filename) + ->run(); - $zipTask->run(); + $this->taskGitStack() + ->cloneRepo(__DIR__, $tmpDir) + ->run(); + + $this->taskComposerInstall() + ->dir($tmpDir) + ->optimizeAutoloader() + ->noDev() + ->run(); + + $this->taskPack($filename) + ->addDir('alltube', $tmpDir) + ->run(); } } diff --git a/composer.json b/composer.json index 530604a..9510c22 100644 --- a/composer.json +++ b/composer.json @@ -92,7 +92,7 @@ "scripts": { "lint": "grumphp run --ansi", "test": "phpunit", - "release": "robo release", + "release": "robo release --ansi", "update-locales": [ "tsmarty2c.php templates > i18n/template.pot", "xgettext --omit-header -kt -j -o i18n/template.pot classes/*.php classes/*/*.php controllers/*"