Skip to content

Commit

Permalink
include build date in version number #141
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Jan 19, 2018
1 parent 6e12c00 commit 333f866
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions app/Console/Commands/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ class Version extends BaseCommand
{
protected $signature = 'phpvms:version {--write}';

/**
* Create the version number that gets written out
*/
protected function createVersionNumber($cfg)
{
exec($cfg['git']['git-local'], $version);
$version = substr($version[0], 0, $cfg['build']['length']);

# prefix with the date in YYMMDD format
$date = date('ymd');

$version = $date.'-'.$version;

return $version;
}

/**
* Run dev related commands
* @throws \Symfony\Component\Yaml\Exception\ParseException
Expand All @@ -19,8 +35,8 @@ public function handle()
$version_file = config_path('version.yml');

$cfg = Yaml::parse(file_get_contents($version_file));
exec($cfg['git']['git-local'], $version);
$version = substr($version[0], 0, $cfg['build']['length']);

$version = $this->createVersionNumber($cfg);
$cfg['build']['number'] = $version;

file_put_contents($version_file, Yaml::dump($cfg, 4, 2));
Expand Down
2 changes: 1 addition & 1 deletion config/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build:
mode: number
length: 6
increment_by: 1
number: 5e097e
number: 180119-6e12c0
git_absorb: git-local
git:
git-local: 'git rev-parse --verify HEAD'
Expand Down

0 comments on commit 333f866

Please sign in to comment.