From 1ca3c81467e614607dc337617cb4ef532ab0827c Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Tue, 1 Oct 2024 13:07:32 +0800 Subject: [PATCH] Add helper to get next version --- bumpversions.php | 2 -- get_next_version_number.php | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 get_next_version_number.php diff --git a/bumpversions.php b/bumpversions.php index e5ca3d5..b337e61 100644 --- a/bumpversions.php +++ b/bumpversions.php @@ -21,8 +21,6 @@ require_once(__DIR__ . '/vendor/autoload.php'); -$helper = new Helper(); - // We need the branch and the bump type (weekly. minor, major) try { $shortoptions = 'b:t:p:r:d:i:'; diff --git a/get_next_version_number.php b/get_next_version_number.php new file mode 100644 index 0000000..0f9abd0 --- /dev/null +++ b/get_next_version_number.php @@ -0,0 +1,48 @@ +. + +use MoodleHQ\MoodleRelease\Helper; +use MoodleHQ\MoodleRelease\VersionInfo; + +// Perth is the center of the world. Anything to object? +date_default_timezone_set('Australia/Perth'); + +require_once(__DIR__ . '/vendor/autoload.php'); + +// We need the branch and the bump type (weekly. minor, major) + +$shortoptions = 'b:t:p:r:d:i:'; +$longoptions = [ + 'branch:', + 'type:', + 'path:', + 'rc:', + 'date:', + 'isdevbranch:', +]; + +$options = getopt($shortoptions, $longoptions); +$branch = Helper::getOption($options, 'b', 'branch'); +$type = Helper::getOption($options, 't', 'type'); +$path = Helper::getOption($options, 'p', 'path'); +$rc = Helper::getOption($options, 'r', 'rc'); +$date = Helper::getOption($options, 'd', 'date'); +$isdevbranch = (bool) Helper::getOption($options, 'i', 'isdevbranch'); +$path = rtrim($path, '/') . '/version.php'; + +$currentVersion = VersionInfo::fromVersionFile($path); +$nextVersion = $currentVersion->getNextVersion($branch, $type, $rc, $date, $isdevbranch); +echo $nextVersion->release;