Upstream null version; build version tags not being saved properly #575 (#578)

* Check for null version from upstream #575

* Fix for pre-release version numbering

* Move popup to right

* Split get/generate build ID #575
This commit is contained in:
Nabeel S
2020-02-23 12:23:19 -05:00
committed by GitHub
parent b9fe8bf738
commit 0e13905098
9 changed files with 89 additions and 20 deletions

View File

@@ -34,7 +34,7 @@ class Version extends Command
// If a version is being passed in, the update the build, etc data against this
if ($this->argument('version')) {
$version = \SemVer\SemVer\Version::fromString($this->argument('version'));
if ($this->option('write_full_version')) {
if ($this->option('write-full-version')) {
$cfg['current']['major'] = $version->getMajor();
$cfg['current']['minor'] = $version->getMinor();
$cfg['current']['patch'] = $version->getPatch();
@@ -51,7 +51,7 @@ class Version extends Command
}
// Always write out the build ID/build number which is the commit hash
$build_number = $this->versionSvc->getBuildId($cfg);
$build_number = $this->versionSvc->generateBuildId($cfg);
$cfg['current']['commit'] = $build_number;
$cfg['build']['number'] = $build_number;

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Http\Composers;
use App\Services\VersionService;
use Illuminate\View\View;
class VersionComposer
{
protected $versionSvc;
public function __construct(VersionService $versionSvc)
{
$this->versionSvc = $versionSvc;
}
public function compose(View $view)
{
$view->with('version', $this->versionSvc->getCurrentVersion(false));
$view->with('version_full', $this->versionSvc->getCurrentVersion(true));
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace App\Providers;
use App\Http\Composers\VersionComposer;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class ComposerServiceProvider extends ServiceProvider
{
public function boot()
{
// Attach the version number to the admin sidebar
View::composer('admin.sidebar', VersionComposer::class);
}
}

View File

@@ -76,7 +76,7 @@ class VersionService extends Service
}
/**
* Download the latest version from github
* Download the latest version from github and return the version number
*/
private function getLatestVersionGithub()
{
@@ -112,7 +112,7 @@ class VersionService extends Service
);
}
return $releases;
return null;
}
/**
@@ -133,12 +133,30 @@ class VersionService extends Service
*/
public function getBuildId($cfg)
{
return $cfg['build']['number'];
}
/**
* Generate a build ID
*
* @param array $cfg The version config
*
* @return false|string
*/
public function generateBuildId($cfg)
{
$date = date('ymd');
exec($cfg['git']['git-local'], $version);
if (empty($version)) {
return $date;
}
$version = substr($version[0], 0, $cfg['build']['length']);
// prefix with the date in YYMMDD format
$date = date('ymd');
return $date.'.'.$version;
$version = $date.'.'.$version;
return $version;
}
/**
@@ -165,8 +183,9 @@ class VersionService extends Service
if ($include_build) {
// Get the current build id
$build_number = $this->getBuildId($cfg);
$cfg['build']['number'] = $build_number;
$version = $version.'+'.$build_number;
if (!empty($build_number)) {
$version = $version.'+'.$build_number;
}
}
return $version;
@@ -188,9 +207,12 @@ class VersionService extends Service
}
// Replace "dev" with "alpha", since
$latest_version = $this->getLatestVersion();
if (empty($latest_version)) {
return false;
}
// Convert to semver
if ($this->isGreaterThan($latest_version, $current_version)) {
$this->kvpRepo->save('new_version_available', true);