Skip to content

Commit

Permalink
Merge branch '8.5' into 9.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 19, 2022
2 parents 6e89191 + 872c971 commit bcaa5a2
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions build/scripts/phar-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@
exit(1);
}

$dependencies = dependencies();
$package = package();
$version = version();
$dependencies = dependencies();

manifest($argv[1], $version, $dependencies);
sbom($argv[2], $version, $dependencies);
manifest($argv[1], $package, $version, $dependencies);
sbom($argv[2], $package, $version, $dependencies);

function manifest(string $outputFilename, string $version, array $dependencies): void
function manifest(string $outputFilename, array $package, string $version, array $dependencies): void
{
$buffer = 'phpunit/phpunit: ' . $version . "\n";
$buffer = sprintf(
'%s/%s: %s' . "\n",
$package['group'],
$package['name'],
$version
);

foreach ($dependencies as $dependency) {
$buffer .= $dependency['name'] . ': ' . $dependency['version'];
Expand All @@ -35,7 +41,7 @@ function manifest(string $outputFilename, string $version, array $dependencies):
file_put_contents($outputFilename, $buffer);
}

function sbom(string $outputFilename, string $version, array $dependencies): void
function sbom(string $outputFilename, array $package, string $version, array $dependencies): void
{
$writer = new XMLWriter;

Expand All @@ -50,11 +56,11 @@ function sbom(string $outputFilename, string $version, array $dependencies): voi

writeComponent(
$writer,
'phpunit',
'phpunit',
$package['group'],
$package['name'],
$version,
'The PHP Unit Testing framework',
['BSD-3-Clause']
$package['description'],
$package['license']
);

foreach ($dependencies as $dependency) {
Expand Down Expand Up @@ -92,6 +98,26 @@ function dependencies(): array
)['packages'];
}

function package(): array
{
$data = json_decode(
file_get_contents(
__DIR__ . '/../../composer.json'
),
true
);

[$group, $name] = explode('/', $data['name']);

return [
'group' => $group,
'name' => $name,
'description' => $data['description'],
'license' => [$data['license']],
'branch' => $data['extra']['branch-alias']['dev-master']
];
}

function version(): string
{
$tag = @exec('git describe --tags 2>&1');
Expand Down

0 comments on commit bcaa5a2

Please sign in to comment.