diff --git a/app/Console/Commands/ReleaseCommand.php b/app/Console/Commands/ReleaseCommand.php index aa639a3d..adfd6b43 100644 --- a/app/Console/Commands/ReleaseCommand.php +++ b/app/Console/Commands/ReleaseCommand.php @@ -25,6 +25,7 @@ class ReleaseCommand extends Command public function handle(): int { + self::ensureMainBranch(); self::ensureCleanWorkingDirectory(); $this->getCurrentVersion(); @@ -134,6 +135,17 @@ class ReleaseCommand extends Command note('Current version: ' . $this->currentVersion->prefix()); } + private static function ensureMainBranch(): void + { + $branch = trim(Process::run('git branch --show-current')->output()); + + if ($branch !== 'master') { + error("You must be on the master branch to release a new version (Current branch: '$branch.')"); + + exit(self::FAILURE); + } + } + private static function ensureCleanWorkingDirectory(): void { if (Process::run('git status --porcelain')->output()) {