Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# https://help.github.com/en/articles/about-code-owners
#

* @brettmc @bobstrecansky @pdelewski
* @brettmc @bobstrecansky
# note that open-telemetry/php-approvers does not exist in this organization
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ifneq ("$(wildcard .env)","")
export $(.env)
endif

PHP_VERSION ?= 7.4
PHP_VERSION ?= 8.1
DC_RUN_PHP = docker compose run --rm php
PSALM_THREADS ?= 1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Options:
- `--branch=` - github branch to tag from
- `--dry-run` - do not make any changes
- `--repo=` - choose a single upstream repo to run against (default: all)
- `--filter=` - filter repositories by prefix

The script will then:
* fetch `.gitsplit.yaml` from source repositories
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.7'
services:
php:
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-7.4}
image: ghcr.io/open-telemetry/opentelemetry-php/opentelemetry-php-base:${PHP_VERSION:-8.1}
volumes:
- ./:/usr/src/myapp
user: "${PHP_USER}:root"
Expand Down
22 changes: 17 additions & 5 deletions src/Console/Command/Release/ReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ protected function configure(): void
->addOption('token', ['t'], InputOption::VALUE_OPTIONAL, 'github token')
->addOption('branch', null, InputOption::VALUE_OPTIONAL, 'branch to tag off (default: main)')
->addOption('repo', ['r'], InputOption::VALUE_OPTIONAL, 'repo to handle (core, contrib)')
->addOption('filter', null, InputOption::VALUE_OPTIONAL, 'filter by repository prefix')
->addOption('force', ['f'], InputOption::VALUE_NONE, 'force new releases even if no changes')
;
}
Expand All @@ -63,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->dry_run = $input->getOption('dry-run');
$this->force = $input->getOption('force');
$source = $input->getOption('repo');
$filter = $input->getOption('filter');
if ($source && !array_key_exists($source, self::AVAILABLE_REPOS)) {
$options = implode(',', array_keys(self::AVAILABLE_REPOS));
$this->output->writeln("<error>Invalid source: {$source}. Options: {$options}</error>");
Expand All @@ -75,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$repositories = [];

try {
$found = $this->find_repositories();
$found = $this->find_repositories($filter);
} catch (\Exception $e) {
$this->output->writeln("<error>{$e->getCode()} {$e->getMessage()}</error>");

Expand Down Expand Up @@ -104,18 +106,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
* @throws \Exception
* @return array<Repository>
*/
private function find_repositories(): array
private function find_repositories(?string $filter): array
{
$repositories = [];
foreach ($this->sources as $key => $repo) {
$this->output->isVerbose() && $this->output->writeln("<info>Fetching .gitsplit.yaml for {$key} ({$repo})</info>");
$repositories = array_merge($repositories, $this->get_gitsplit_repositories($repo));
$repositories = array_merge($repositories, $this->get_gitsplit_repositories($repo, $filter));
}

return $repositories;
}

private function get_gitsplit_repositories(string $repo): array
private function get_gitsplit_repositories(string $repo, ?string $filter): array
{
$url = "https://raw.githubusercontent.com/{$repo}/main/.gitsplit.yml";
$response = $this->fetch($url);
Expand All @@ -127,14 +129,24 @@ private function get_gitsplit_repositories(string $repo): array
$repositories = [];
$this->output->isVeryVerbose() && $this->output->writeln('[RESPONSE]' . json_encode($yaml['splits']));
foreach ($yaml['splits'] as $entry) {
$prefix = $entry['prefix'];
if ($filter && !str_contains($prefix, $filter)) {
$this->output->isVerbose() && $this->output->writeln(sprintf('[SKIP] %s does not match filter: %s', $prefix, $filter));

continue;
}
$repository = new Repository();
$repository->upstream = new Project($repo);
$repository->upstream->path = $entry['prefix'];
$repository->upstream->path = $prefix;
$target = $entry['target'];
$repository->downstream = new Project(str_replace(['https://${GH_TOKEN}@github.com/', '.git'], ['',''], $target));
$repositories[] = $repository;
}

if ($this->output->isVeryVerbose()) {
$this->output->writeln('[FOUND]' . json_encode($repositories));
}

return $repositories;
}

Expand Down