-
Notifications
You must be signed in to change notification settings - Fork 27
/
RoboFile.php
158 lines (144 loc) · 4.09 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
require_once 'vendor/autoload.php';
/**
* This is project's console commands configuration for Robo task runner.
*
* NOTE: All arguments referencing $site and $dest will default to looking
* for the peridot-php.github.io directory in the same directory as the Peridot
* project.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
/**
* Release a new version of Peridot.
*
* @param null|string $version the new version number
* @param null|string $site path to the Peridot site to build
*/
public function release($version = null, $site = null)
{
$this->yell("Releasing Peridot");
$this->taskExec("git pull upstream master")->run();
$bump = $this->version($version);
$this->phar($site);
$this->docs($site);
$this->taskExec('git commit -am "release ' . $bump . '"')->run();
$this->taskExec('git tag -a ' . $bump . ' -m "release ' . $bump . '"')->run();
$this->taskExec("git push upstream $bump")->run();
$this->taskExec("git push upstream master")->run();
$this->publish($site);
}
/**
* @param $change
*/
public function changed($change)
{
$this->taskChangelog()
->version(\Peridot\Console\Version::NUMBER)
->change($change)
->run();
}
/**
* Bump the version of Peridot. Defaults to a minor release.
*
* @param null $version
* @return null|string
*/
public function version($version = null)
{
if (!$version) {
$versionParts = explode('.', \Peridot\Console\Version::NUMBER);
$versionParts[count($versionParts)-1]++;
$version = implode('.', $versionParts);
}
$versionFile = __DIR__ . '/src/Console/Version.php';
$this->taskReplaceInFile($versionFile)
->from('NUMBER = "' . \Peridot\Console\Version::NUMBER . '"')
->to('NUMBER = "' . $version . '"')
->run();
return $version;
}
/**
* Generate docs via apigen then move them to the
* site folder
*
* @param null|string $dest
*/
public function docs($dest = null)
{
if (!$dest) {
$dest = __DIR__ . '/../peridot-php.github.io';
}
$src = __DIR__ . '/docs';
$this->taskDeleteDir([
$dest . '/docs',
$src
])->run();
$this->taskExec('apigen generate')->run();
$this->taskCopyDir([
$src => $dest . '/docs'
])->run();
$this->taskDeleteDir([$src])->run();
}
/**
* Build a phar and move it to the site folder
*
* @param null|string $dest
*/
public function phar($dest = null)
{
$this->taskComposerInstall()
->printed(false)
->noDev()
->run();
if (!$dest) {
$dest = __DIR__ . '/../peridot-php.github.io';
}
$src = __DIR__ . '/peridot.phar';
$this->taskCleanDir([$dest . '/downloads'])->run();
if (file_exists($src)) {
unlink($src);
}
$this->taskExec('box build')->run();
$destPhar = $dest . '/downloads/peridot.phar';
$this->say("copying phar to $destPhar");
rename($src, $destPhar);
}
/**
* Publish the Peridot site
*
* @param null|string $dest
*/
public function publish($dest = null)
{
$this->yell('Publishing Peridot docs');
if (!$dest) {
$dest = __DIR__ . '/../peridot-php.github.io';
}
$cwd = getcwd();
chdir($dest);
$this->taskGitStack()
->add('-A')
->commit('auto-update')
->pull()
->push()
->run();
chdir($cwd);
}
/**
* Rebuild docs, phar, and publish the site
*
* @param null|string $dest
*/
public function site($dest = null)
{
if (!$dest) {
$dest = __DIR__ . '/../peridot-php.github.io';
}
$this->phar($dest);
$this->docs($dest);
$this->publish($dest);
}
}