mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
make-release: trap more errors
This commit is contained in:
parent
0973472842
commit
0ccb47fb07
@ -75,6 +75,14 @@ const ACCEPTED_OPTS = [
|
|||||||
"channel" => "Release channel to post this build into"
|
"channel" => "Release channel to post this build into"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function systemWrapper(string $command, string $errorMessage) : void{
|
||||||
|
system($command, $result);
|
||||||
|
if($result !== 0){
|
||||||
|
echo "error: $errorMessage; aborting\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function main() : void{
|
function main() : void{
|
||||||
$filteredOpts = [];
|
$filteredOpts = [];
|
||||||
foreach(Utils::stringifyKeys(getopt("", ["current:", "next:", "channel:", "help"])) as $optName => $optValue){
|
foreach(Utils::stringifyKeys(getopt("", ["current:", "next:", "channel:", "help"])) as $optName => $optValue){
|
||||||
@ -115,7 +123,7 @@ function main() : void{
|
|||||||
echo "$currentVer will be published on release channel \"$channel\".\n";
|
echo "$currentVer will be published on release channel \"$channel\".\n";
|
||||||
echo "please add appropriate notes to the changelog and press enter...";
|
echo "please add appropriate notes to the changelog and press enter...";
|
||||||
fgets(STDIN);
|
fgets(STDIN);
|
||||||
system('git add "' . dirname(__DIR__) . '/changelogs"');
|
systemWrapper('git add "' . dirname(__DIR__) . '/changelogs"', "failed to stage changelog changes");
|
||||||
system('git diff --cached --quiet "' . dirname(__DIR__) . '/changelogs"', $result);
|
system('git diff --cached --quiet "' . dirname(__DIR__) . '/changelogs"', $result);
|
||||||
if($result === 0){
|
if($result === 0){
|
||||||
echo "error: no changelog changes detected; aborting\n";
|
echo "error: no changelog changes detected; aborting\n";
|
||||||
@ -123,14 +131,15 @@ function main() : void{
|
|||||||
}
|
}
|
||||||
$versionInfoPath = dirname(__DIR__) . '/src/VersionInfo.php';
|
$versionInfoPath = dirname(__DIR__) . '/src/VersionInfo.php';
|
||||||
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel);
|
replaceVersion($versionInfoPath, $currentVer->getBaseVersion(), false, $channel);
|
||||||
system('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"');
|
systemWrapper('git commit -m "Release ' . $currentVer->getBaseVersion() . '" --include "' . $versionInfoPath . '"', "failed to create release commit");
|
||||||
system('git tag ' . $currentVer->getBaseVersion());
|
systemWrapper('git tag ' . $currentVer->getBaseVersion(), "failed to create release tag");
|
||||||
|
|
||||||
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, $channel);
|
replaceVersion($versionInfoPath, $nextVer->getBaseVersion(), true, $channel);
|
||||||
system('git add "' . $versionInfoPath . '"');
|
systemWrapper('git add "' . $versionInfoPath . '"', "failed to stage changes for post-release commit");
|
||||||
system('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"');
|
systemWrapper('git commit -m "' . $nextVer->getBaseVersion() . ' is next" --include "' . $versionInfoPath . '"', "failed to create post-release commit");
|
||||||
echo "pushing changes in 5 seconds\n";
|
echo "pushing changes in 5 seconds\n";
|
||||||
sleep(5);
|
sleep(5);
|
||||||
system('git push origin HEAD ' . $currentVer->getBaseVersion());
|
systemWrapper('git push origin HEAD ' . $currentVer->getBaseVersion(), "failed to push changes to remote");
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user