-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy
executable file
·46 lines (34 loc) · 1.6 KB
/
deploy
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
#!/usr/bin/env php
<?php
if(!defined('STDIN')) { die("You're unauthorized to view this page."); }
if(!file_exists('./script/wp-script-config.php')) { die("Your script/wp-script-config.php file wasn't found."); }
include_once('./script/wp-script-config.php');
if(!isset($argv[1])) { die("USAGE: ./script/deploy [version-number]\n"); }
$my_version = $argv[1];
if(!preg_match('/\d+\.\d+\.\d+(([a-z_-]+)\d+)?/i', $my_version, $m)) {
exit("Improper Version Format\n\n");
}
echo "!! Deploying version \"{$my_version}\"\n";
//print_r($m);
$my_branch = 'master';
if(isset($m[2]) && !in_array($m[2], array('a','b','rc'))) {
$my_branch = $m[2];
}
if(!defined('MY_PLUGIN_MAIN_FILE')) {
define('MY_PLUGIN_MAIN_FILE', WP_SCRIPT_TEXTDOMAIN . '.php');
}
echo "!! Deploying from branch \"{$my_branch}\"\n";
$commands = array();
$commands[] = "/usr/bin/git checkout {$my_branch}";
$commands[] = "/usr/bin/perl -p -i -e 's/^Version: (.*)$/Version: {$my_version}/' ./" . MY_PLUGIN_MAIN_FILE;
$commands[] = './script/mki18n';
$commands[] = './script/rmlb';
$commands[] = './script/cleartrailingwhitespace';
$commands[] = './script/rmtabs';
$commands[] = "/usr/bin/git commit -am 'Bump {$my_branch} to version {$my_version}'";
$commands[] = "/usr/bin/git push origin {$my_branch}";
$commands[] = "/usr/bin/git tag {$my_version}";
$commands[] = "/usr/bin/git push origin {$my_version}";
$commands[] = '/usr/bin/curl -d "apikey=' . MOTHERSHIP_API_KEY . '" ' . MOTHERSHIP_URL . '/versions/deploy/' . MOTHERSHIP_PROJECT_ID . '/' . $my_version;
foreach($commands as $command) { echo "\n$command\n"; system($command); sleep(1); }
echo "\n\n";