2014-07-07 08:38:35 +04:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2017-03-20 00:08:34 +07:00
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
2016-11-15 15:02:14 +07:00
|
|
|
*/
|
|
|
|
|
2017-03-20 00:08:34 +07:00
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
2014-07-07 08:38:35 +04:00
|
|
|
|
2017-03-20 00:08:34 +07:00
|
|
|
define('ROOT', realpath(__DIR__ . '/..'));
|
2015-02-05 17:25:17 +03:00
|
|
|
$opt = getopt('v::');
|
|
|
|
|
|
|
|
$version = 'dev-master';
|
|
|
|
if (array_key_exists('v', $opt)) {
|
|
|
|
$version = $opt['v'];
|
|
|
|
if (!preg_match('/^\d+\.\d+\.\d+(-[\d\w\.]+)?$/i', $version)) {
|
|
|
|
die("Version number must follow semantic versioning.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-20 00:08:34 +07:00
|
|
|
chdir(ROOT);
|
|
|
|
exec('composer require deployer/phar-update:~2.0 --no-update');
|
|
|
|
exec('composer install --no-dev');
|
|
|
|
exec('git checkout -- composer.json composer.lock');
|
|
|
|
|
2014-08-13 13:47:18 +04:00
|
|
|
$pharName = "deployer.phar";
|
2017-03-20 00:08:34 +07:00
|
|
|
$pharFile = ROOT . '/' . $pharName;
|
2014-07-07 08:38:35 +04:00
|
|
|
|
|
|
|
if (file_exists($pharFile)) {
|
|
|
|
unlink($pharFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
$phar = new \Phar($pharFile, 0, $pharName);
|
|
|
|
$phar->setSignatureAlgorithm(\Phar::SHA1);
|
|
|
|
|
|
|
|
$phar->startBuffering();
|
|
|
|
|
|
|
|
$finder = new Symfony\Component\Finder\Finder();
|
|
|
|
$finder->files()
|
|
|
|
->ignoreVCS(true)
|
|
|
|
->name('*.php')
|
|
|
|
->name('*.json')
|
2015-04-15 17:47:50 +07:00
|
|
|
->name('*.exe')
|
2014-07-07 08:38:35 +04:00
|
|
|
->exclude('phpunit')
|
|
|
|
->exclude('Tests')
|
|
|
|
->exclude('test')
|
|
|
|
->exclude('tests')
|
2015-05-26 18:33:07 +07:00
|
|
|
->exclude('phpspec')
|
2017-03-20 00:08:34 +07:00
|
|
|
->in(ROOT);
|
2014-07-07 08:38:35 +04:00
|
|
|
|
|
|
|
foreach ($finder as $fileInfo) {
|
2017-03-20 00:08:34 +07:00
|
|
|
$file = str_replace(ROOT, '', $fileInfo->getRealPath());
|
2014-07-07 08:38:35 +04:00
|
|
|
|
|
|
|
echo "Add file: " . $file . "\n";
|
|
|
|
|
|
|
|
$phar->addFile($fileInfo->getRealPath(), $file);
|
|
|
|
}
|
|
|
|
|
2014-07-07 11:08:04 +04:00
|
|
|
// Add bin/dep file
|
2017-03-20 00:08:34 +07:00
|
|
|
$depContent = file_get_contents(ROOT . '/bin/dep');
|
2014-07-07 11:08:04 +04:00
|
|
|
$depContent = str_replace("#!/usr/bin/env php\n", '', $depContent);
|
2015-02-05 17:25:17 +03:00
|
|
|
$depContent = str_replace("'master'", "'$version'", $depContent);
|
2015-05-26 18:33:07 +07:00
|
|
|
$depContent = str_replace('__FILE__', 'str_replace("phar://", "", Phar::running())', $depContent);
|
2014-07-07 11:08:04 +04:00
|
|
|
$phar->addFromString('bin/dep', $depContent);
|
|
|
|
|
2014-07-08 17:23:25 +04:00
|
|
|
$stub = <<<STUB
|
2014-07-07 08:38:35 +04:00
|
|
|
#!/usr/bin/env php
|
|
|
|
<?php
|
2014-07-08 17:16:31 +04:00
|
|
|
Phar::mapPhar('{$pharName}');
|
|
|
|
require 'phar://{$pharName}/bin/dep';
|
2014-07-07 08:38:35 +04:00
|
|
|
__HALT_COMPILER();
|
2014-07-08 17:23:25 +04:00
|
|
|
STUB;
|
2014-07-07 08:38:35 +04:00
|
|
|
|
|
|
|
$phar->setStub($stub);
|
2015-04-15 18:22:07 +07:00
|
|
|
// Bug #53467. Phar cannot compress large archives. https://bugs.php.net/bug.php?id=53467
|
|
|
|
// $phar->compressFiles(Phar::GZ);
|
2014-07-07 08:38:35 +04:00
|
|
|
$phar->stopBuffering();
|
2014-07-07 09:23:33 +04:00
|
|
|
unset($phar);
|
2014-07-07 08:38:35 +04:00
|
|
|
|
2015-05-19 12:28:14 +02:00
|
|
|
echo "$pharName was created successfully.\n";
|