RoboFile.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * This is project's console commands configuration for Robo task runner.
  4. *
  5. * @see http://robo.li/
  6. */
  7. class RoboFile extends \Robo\Tasks
  8. {
  9. /**
  10. * Creates release zip
  11. *
  12. * @param string $version
  13. * @see https://gist.github.com/Rarst/5a8a65478755539770df653c4575219a
  14. */
  15. public function release($version)
  16. {
  17. $package = 'upyun/sdk';
  18. $name = 'php-sdk';
  19. $collection = $this->collectionBuilder();
  20. $workingPath = __DIR__ . DIRECTORY_SEPARATOR . $collection->workDir("release");
  21. $collection->taskExec("composer create-project {$package} {$name} {$version}")
  22. ->dir($workingPath)
  23. ->arg('--prefer-dist')
  24. ->arg('--no-dev')
  25. ->arg('-vvv')
  26. ->taskExec('composer dump-autoload --optimize')
  27. ->dir($workingPath . DIRECTORY_SEPARATOR . $name)
  28. ->arg('-vvv');
  29. $collection->run();
  30. $zipFile = "release/{$name}-{$version}.zip";
  31. $this->_remove($zipFile);
  32. $this->taskPack($zipFile)
  33. ->addDir("php-sdk", __DIR__ . "/release/php-sdk")
  34. ->run();
  35. $this->_deleteDir("release/$name");
  36. }
  37. }