1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Console\Commands;
7
8use App\Models\UpdateStream;
9use Illuminate\Console\Command;
10
11class BuildsCreate extends Command
12{
13 /**
14 * The name and signature of the console command.
15 *
16 * @var string
17 */
18 protected $signature = 'builds:create {--stream-id=}';
19
20 /**
21 * The console command description.
22 *
23 * @var string
24 */
25 protected $description = 'Creates build from orphan changelog entries of specified stream id';
26
27 /**
28 * Execute the console command.
29 *
30 * @return mixed
31 */
32 public function handle()
33 {
34 $streamId = get_int($this->option('stream-id'));
35
36 if ($streamId === null) {
37 $this->error('Missing stream-id');
38 return;
39 }
40
41 $stream = UpdateStream::findOrFail($streamId);
42
43 $build = $stream->createBuild();
44
45 if ($build === null) {
46 $this->info('No build created (probably no orphan changelog entry).');
47 return;
48 }
49
50 $this->info("Created build {$build->displayVersion()}");
51 $this->info('URL: '.build_url($build));
52 }
53}