mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
More accurate version generator in e107_make.php build script
No longer trips up on hyphens in the tagged releases
This commit is contained in:
21
.github/workflows/build-release/OsHelper.php
vendored
21
.github/workflows/build-release/OsHelper.php
vendored
@@ -10,6 +10,8 @@
|
||||
|
||||
class OsHelper
|
||||
{
|
||||
const REGEX_MATCH_GIT_DESCRIBE_TAGS = "-[0-9]+-g[0-9a-f]+";
|
||||
|
||||
/**
|
||||
* @param string $command The command to run
|
||||
* @param string $stdout Reference to the STDOUT output as a string
|
||||
@@ -52,14 +54,25 @@ class OsHelper
|
||||
|
||||
public static function gitVersionToPhpVersion($gitVersion, $verFileVersion = "0")
|
||||
{
|
||||
$verFileVersion = explode(" ", $verFileVersion);
|
||||
$verFileVersion = explode(" ", $verFileVersion);
|
||||
$verFileVersion = array_shift($verFileVersion);
|
||||
$version = preg_replace("/^v/", "", $gitVersion);
|
||||
$versionSplit = explode("-", $version);
|
||||
if (count($versionSplit) > 1)
|
||||
$matchGitDescribeTags = self::REGEX_MATCH_GIT_DESCRIBE_TAGS;
|
||||
if (preg_match("/{$matchGitDescribeTags}$/", $version))
|
||||
{
|
||||
if (version_compare($verFileVersion, $versionSplit[0], '>')) $versionSplit[0] = $verFileVersion;
|
||||
$versionSplit[0] .= "dev";
|
||||
$increment = 1;
|
||||
if (version_compare($verFileVersion, $version, '>'))
|
||||
{
|
||||
$increment = 0;
|
||||
$versionSplit[0] = $verFileVersion;
|
||||
}
|
||||
$version = implode("-", $versionSplit);
|
||||
return preg_replace_callback("/(.*\.)([0-9]+)([^.]*)({$matchGitDescribeTags})$/",
|
||||
function ($matches) use ($increment)
|
||||
{
|
||||
return $matches[1] . ($matches[2] + $increment) . "dev" . $matches[4];
|
||||
}, $version);
|
||||
}
|
||||
return implode("-", $versionSplit);
|
||||
}
|
||||
|
10
.github/workflows/build-release/e107_make.php
vendored
10
.github/workflows/build-release/e107_make.php
vendored
@@ -91,7 +91,7 @@ class e107Build
|
||||
}
|
||||
}
|
||||
|
||||
private function validateReadme()
|
||||
private function validateReadme()
|
||||
{
|
||||
//check for readme files associated with configured releases
|
||||
foreach ($this->config['releases'] as $rel)
|
||||
@@ -276,7 +276,7 @@ class e107Build
|
||||
|
||||
$releaseDir = "{$this->config['baseDir']}/target/{$this->config['main']['name']}/release/" . $this->releaseDir;
|
||||
|
||||
$this->copyCoreImage($releaseDir . "/core_image.phar");
|
||||
$this->copyCoreImage($releaseDir . "/core_image.phar");
|
||||
|
||||
/**
|
||||
* git archive -o update.zip HEAD $(git diff --name-only [id])
|
||||
@@ -312,8 +312,8 @@ class e107Build
|
||||
unlink($tarfile);
|
||||
} // end loop
|
||||
|
||||
$this->status('Removing export folder', true);
|
||||
$this->rmdir($this->exportDir);
|
||||
$this->status('Removing export folder', true);
|
||||
$this->rmdir($this->exportDir);
|
||||
}
|
||||
|
||||
private function emptyExportDir()
|
||||
@@ -379,7 +379,7 @@ class e107Build
|
||||
{
|
||||
$version = $this->version;
|
||||
|
||||
if (strpos($version, "-") !== false)
|
||||
if (preg_match("/" . OsHelper::REGEX_MATCH_GIT_DESCRIBE_TAGS . "$/", $version))
|
||||
{
|
||||
$version .= " nightly build " . date('Ymd');
|
||||
}
|
||||
|
Reference in New Issue
Block a user