File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace App \Commands ;
4+
5+ use Illuminate \Support \Facades \File ;
6+ use Illuminate \Support \Facades \Process ;
7+ use LaravelZero \Framework \Commands \Command ;
8+
9+ use function Laravel \Prompts \info ;
10+ use function Laravel \Prompts \text ;
11+
12+ class Tag extends Command
13+ {
14+ protected $ signature = 'tag ' ;
15+
16+ protected $ description = 'Tag the current version ' ;
17+
18+ public function handle (): void
19+ {
20+ $ dirty = exec ('git status --porcelain ' );
21+
22+ if ($ dirty ) {
23+ info ('Working directory is not clean. Please commit your changes before tagging. ' );
24+
25+ return ;
26+ }
27+
28+ $ composer = File::json (base_path ('composer.json ' ));
29+
30+ $ version = $ composer ['version ' ];
31+
32+ $ newVersion = text (label: 'Next version: ' , default: $ version );
33+
34+ $ tag = "v {$ newVersion }" ;
35+
36+ info ("Tagging version {$ tag }" );
37+
38+ $ composer ['version ' ] = $ newVersion ;
39+
40+ File::put (base_path ('composer.json ' ), json_encode ($ composer , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . PHP_EOL );
41+
42+ exec ('git add composer.json ' );
43+ exec ('git commit -m "Bump version to ' . $ newVersion . '" ' );
44+ exec ('git tag ' . $ tag );
45+ }
46+ }
Original file line number Diff line number Diff line change 22
33use App \Commands \CompileBinaryCommand ;
44use App \Commands \ContextTypeScriptGeneratorCommand ;
5+ use App \Commands \Tag ;
56
67return [
78
6869 LaravelZero \Framework \Commands \StubPublishCommand::class,
6970 CompileBinaryCommand::class,
7071 ContextTypeScriptGeneratorCommand::class,
72+ Tag::class,
7173 ],
7274
7375 /*
You can’t perform that action at this time.
0 commit comments