Skip to content

Commit 0c0e41c

Browse files
committed
Add Robo and .semver
1 parent 2071a7c commit 0c0e41c

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

.semver

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
:major: 0
3+
:minor: 0
4+
:patch: 0
5+
:special: ''
6+
:metadata: ''

RoboFile.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
use Robo\Symfony\ConsoleIO;
4+
use Robo\Tasks;
5+
6+
/**
7+
* This is project's console commands configuration for Robo task runner.
8+
*
9+
* @see https://robo.li/
10+
*/
11+
class RoboFile extends Tasks
12+
{
13+
public function release(ConsoleIO $io, $opt = [
14+
'branch' => 'main',
15+
'what' => 'patch'
16+
]): void
17+
{
18+
$result = $this->taskSemVer()
19+
->increment($opt['what'])
20+
->run();
21+
22+
$tag = $result->getMessage();
23+
24+
$this->say("Releasing $tag");
25+
26+
$this->clean($io);
27+
$this->publishGit($opt['branch'], ['tag' => $tag]);
28+
}
29+
30+
public function clean(ConsoleIO $io): void
31+
{
32+
$io->say('Cleaning up');
33+
$this->taskCleanDir(['logs'])->run();
34+
$this->taskDeleteDir('logs')->run();
35+
}
36+
37+
/**
38+
* @desc creates a new version tag and pushes to GitHub
39+
* @param null $branch
40+
* @param array $opt
41+
*/
42+
public function publishGit($branch = null, $opt = ['tag' => null])
43+
{
44+
$this->say('Pushing ' . $opt['tag'] . ' to GitHub');
45+
$this->taskExec('git tag ' . $opt['tag'])
46+
->run();
47+
$this->taskExec("git push origin $branch --tags")
48+
->run();
49+
}
50+
}

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@
2323
"psr-4": {
2424
"BeastBytes\\PostalCode\\": "src"
2525
}
26+
},
27+
"require-dev": {
28+
"consolidation/robo": "^4.0"
29+
},
30+
"scripts": {
31+
"robo": "robo"
2632
}
2733
}

0 commit comments

Comments
 (0)