Add support for publishing specific version
* Fix variable reuse bug in publish command. * Allow providing a specific version to publish.
This commit is contained in:
@@ -11,6 +11,7 @@ use NoccyLabs\Composer\PackagePlugin\Registry\Credentials\InsecureStore;
|
||||
use NoccyLabs\Composer\PackagePlugin\Registry\Gitea\GiteaProvider;
|
||||
use NoccyLabs\Composer\PackagePlugin\Registry\RegistryFactory;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
class PackagePublishCommand extends BaseCommand
|
||||
{
|
||||
@@ -20,6 +21,7 @@ class PackagePublishCommand extends BaseCommand
|
||||
->setName('package:publish')
|
||||
->setDescription("Publish a package to a composer package registry")
|
||||
->addArgument("registry", InputArgument::OPTIONAL, "The registry to publish to")
|
||||
->addArgument("version", InputArgument::OPTIONAL, "The tag to publish (default is latest tag)")
|
||||
;
|
||||
}
|
||||
|
||||
@@ -27,22 +29,24 @@ class PackagePublishCommand extends BaseCommand
|
||||
{
|
||||
$credentials = new InsecureStore();
|
||||
|
||||
$registry = $input->getArgument("registry");
|
||||
$version = $input->getArgument("version");
|
||||
|
||||
$providers = [
|
||||
'gitea' => new GiteaProvider($credentials)
|
||||
];
|
||||
|
||||
$registry = new RegistryFactory($providers);
|
||||
$publisher = new PackagePublisher($registry, $output);
|
||||
$factory = new RegistryFactory($providers);
|
||||
$publisher = new PackagePublisher($factory, $output);
|
||||
|
||||
$project = ProjectInfo::read();
|
||||
$project = ProjectInfo::read(version: $version);
|
||||
|
||||
$registry = $input->getArgument("registry");
|
||||
if (!$registry) {
|
||||
$output->writeln([
|
||||
"Missing registry to publish to. Please specify the registry like this:",
|
||||
"",
|
||||
" <info>gitea:<server></> - to publish to <info>server</> as the default user",
|
||||
" <info>gitea:<server>/<owner></> - to publish to <info>server</> as <info>owner</>",
|
||||
" <info>gitea:{server}</> - to publish to <info>server</> as the default user",
|
||||
" <info>gitea:{server}:{owner}</> - to publish to <info>server</> as <info>owner</>",
|
||||
""
|
||||
]);
|
||||
return self::INVALID;
|
||||
|
||||
Reference in New Issue
Block a user