Skip to content

Commit

Permalink
More accurate version generator in e107_make.php build script
Browse files Browse the repository at this point in the history
No longer trips up on hyphens in the tagged releases
  • Loading branch information
Deltik committed Jul 8, 2020
1 parent b0376d7 commit 3fcbcd3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/build-release/OsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -52,14 +54,25 @@ public static function runValidated($command, &$stdout = "", &$stderr = "")

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);
}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-release/e107_make.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function status($msg, $heading = false)
}
}

private function validateReadme()
private function validateReadme()
{
//check for readme files associated with configured releases
foreach ($this->config['releases'] as $rel)
Expand Down Expand Up @@ -276,7 +276,7 @@ private function createReleases()

$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])
Expand Down Expand Up @@ -312,8 +312,8 @@ private function createReleases()
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()
Expand Down Expand Up @@ -379,7 +379,7 @@ private function editVersion($dir = 'export')
{
$version = $this->version;

if (strpos($version, "-") !== false)
if (preg_match("/" . OsHelper::REGEX_MATCH_GIT_DESCRIBE_TAGS . "$/", $version))
{
$version .= " nightly build " . date('Ymd');
}
Expand Down

0 comments on commit 3fcbcd3

Please sign in to comment.