forked from VFedyk/yandex-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phar.php
44 lines (39 loc) · 1.15 KB
/
phar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
// Remove reposes
exec("find . | grep .git | xargs rm -rf");
$branchName = getenv('TRAVIS_BRANCH');
$fileName = 'yandex-php-library_.phar';
$phar = new Phar($fileName, 0, $fileName);
// Add files to Phar
$phar->buildFromDirectory(dirname(__FILE__), '/vendor/');
$phar->buildFromDirectory(dirname(__FILE__), '/src/');
$phar->addFile('CHANGELOG.md');
$phar->addFile('LICENSE');
$phar->addFile('README.md');
require_once dirname(__FILE__) . '/vendor/autoload.php';
use Yandex\Disk\DiskClient;
$disk = new DiskClient();
$disk->setAccessToken(getenv('ACCESS_TOKEN'));
// Send to Yandex.DisK
$disk->uploadFile(
'/builds/',
array(
'path' => $fileName,
'size' => filesize($fileName),
'name' => str_replace('.phar', $branchName . '.phar', $fileName)
)
);
// Compressing
if (Phar::canCompress(Phar::BZ2)) {
$phar->compress(Phar::BZ2, 'phar.bz2');
//Send to Yandex.DisK
$fileName .= '.bz2';
$disk->uploadFile(
'/builds/',
array(
'path' => $fileName,
'size' => filesize($fileName),
'name' => str_replace('.phar.bz2', $branchName . '.phar.bz2', $fileName)
)
);
}