Skip to content

Wrong configuration loaded for custom workers #94

@tchapuis

Description

@tchapuis

Hello !

Since version 12.3.1, my custom worker for releasing with Git is not loading the current default branch. No problems on version 12.3.0.

Here is my config :

return static function (MBConfig $mbConfig): void {
    $mbConfig->packageDirectories([__DIR__.'/packages']);

    $mbConfig->defaultBranch('main');

    $mbConfig->workers([
        MyCustom\MonorepoBuilder\Release\PushNextDevReleaseWorker::class,
    ]);

    $services = $mbConfig->services();
    $services->remove(Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker::class);
};

And here is my custom worker. Its the same as the original PushNextDevReleaseWorker, but I changed the commit message.

namespace MyCustom\MonorepoBuilder\Release;

use PharIo\Version\Version;
use Symplify\MonorepoBuilder\Release\Contract\ReleaseWorker\ReleaseWorkerInterface;
use Symplify\MonorepoBuilder\Release\Process\ProcessRunner;
use Symplify\MonorepoBuilder\Utils\VersionUtils;
use Symplify\MonorepoBuilder\ValueObject\Option;
use Symplify\PackageBuilder\Parameter\ParameterProvider;

final readonly class PushNextDevReleaseWorker implements ReleaseWorkerInterface
{
    private string $branchName;

    public function __construct(
        private ProcessRunner $processRunner,
        private VersionUtils $versionUtils,
        ParameterProvider $parameterProvider
    ) {
        $this->branchName = $parameterProvider->provideStringParameter(Option::DEFAULT_BRANCH_NAME);
    }

    public function work(Version $version): void
    {
        $versionInString = $this->getVersionDev($version);
        $gitAddCommitCommand = \sprintf('git add . && git commit --allow-empty -m "chore(release): open %s" && git push origin "%s"', $versionInString, $this->branchName);
        $this->processRunner->run($gitAddCommitCommand);
    }

    public function getDescription(Version $version): string
    {
        $versionInString = $this->getVersionDev($version);

        return \sprintf('Push "%s" open to remote repository, on branch "%s"', $versionInString, $this->branchName);
    }

    private function getVersionDev(Version $version): string
    {
        return $this->versionUtils->getNextAliasFormat($version);
    }
}

But maybe there is another way for loading the correct config ?

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions