-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompile.php
55 lines (39 loc) · 1.54 KB
/
compile.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
45
46
47
48
49
50
51
52
53
54
55
<?php
\set_error_handler(static function ($errno, $errstr, $errfile, $errline) {
\fwrite(\STDERR, "$errno: $errstr in $errfile on line $errline\n");
exit(1);
});
\set_exception_handler(static function ($exception) {
\fwrite(\STDERR, $exception->getMessage() . "\n");
exit(1);
});
require __DIR__ . '/vendor/autoload.php';
$stdout = \getenv('GITHUB_OUTPUT') ?: 'output.txt';
$workspace = \getenv('GITHUB_WORKSPACE') ?: \getcwd();
$source = \getenv('INPUT_SOURCE') ?: '';
$output = \getenv('INPUT_OUTPUT') ?: 'build/packages';
$ref = \getenv('GITHUB_REF');
$inputVersion = $ref
? \basename($ref)
: '0.0.0';
if (!\is_dir($output)) {
\mkdir("$workspace/$output", 0755, true);
}
$package = (new \Rah\Mtxpc\Compiler())
->useCompression(true)
->setVersion($inputVersion)
->compile("$workspace/$source");
$name = $package->getName();
$version = $package->getVersion();
$path = "${output}/${name}_v${version}_zip.txt";
\file_put_contents($workspace . \DIRECTORY_SEPARATOR . $path, $package->getInstaller());
\file_put_contents($stdout, "compressed=$path\n", \FILE_APPEND);
$package = (new \Rah\Mtxpc\Compiler())
->useCompression(false)
->setVersion($inputVersion)
->compile("$workspace/$source");
$path = "${output}/${name}_v${version}.txt";
\file_put_contents($workspace . \DIRECTORY_SEPARATOR . $path, $package->getInstaller());
\file_put_contents($stdout, "uncompressed=$path\n", \FILE_APPEND);
\file_put_contents($stdout, "version=$version\n", \FILE_APPEND);
\file_put_contents($stdout, "name=$name\n", \FILE_APPEND);