File tree 2 files changed +48
-0
lines changed
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 2
2
3
3
use App \Commands \CompileBinaryCommand ;
4
4
use App \Commands \ContextTypeScriptGeneratorCommand ;
5
+ use App \Commands \Tag ;
5
6
6
7
return [
7
8
68
69
LaravelZero \Framework \Commands \StubPublishCommand::class,
69
70
CompileBinaryCommand::class,
70
71
ContextTypeScriptGeneratorCommand::class,
72
+ Tag::class,
71
73
],
72
74
73
75
/*
You can’t perform that action at this time.
0 commit comments