setName('package:build') ->setAliases([ "package" ]) ->setDescription("Package the library into a zipball, or publish directly") ->addOption("publish", null, InputOption::VALUE_REQUIRED, "Publish to registry immediately after building") ->addOption("dirty", null, InputOption::VALUE_NONE, "Build directly from source without cloning") ->addOption("force", null, InputOption::VALUE_NONE, "Build even if the output file already exists") ; } protected function execute(InputInterface $input, OutputInterface $output): int { $registry = $input->getOption("publish"); $builder = new PackageBuilder($output); $project = ProjectInfo::read(); if ($registry && file_exists($project->filename)) { $output->writeln("Package file already exists. Pass --force to rebuild it."); } else { $builder->build($project, $input->getOption("force")); } if ($registry) { $credentials = new InsecureStore(); $providers = [ 'gitea' => new GiteaProvider($credentials) ]; $factory = new RegistryFactory($providers); $publisher = new PackagePublisher($factory, $output); if (!$registry) { $output->writeln([ "Missing registry to publish to. Please specify the registry like this:", "", " gitea: - to publish to server as the default user", " gitea:/ - to publish to server as owner", "" ]); return self::INVALID; } $publisher->publish($project, $registry); } return 0; } }