diff --git a/.travis/deploy_script.sh b/.travis/deploy_script.sh index 3fec086b..988dc021 100755 --- a/.travis/deploy_script.sh +++ b/.travis/deploy_script.sh @@ -19,7 +19,8 @@ if [ "$TRAVIS" = "true" ]; then cd $TRAVIS_BUILD_DIR - php artisan version:show --format compact --suppress-app-name > VERSION + #php artisan version:show --format compact --suppress-app-name > VERSION + php artisan phpvms:version --write > VERSION VERSION=`cat VERSION` echo "Version: $VERSION" diff --git a/app/Console/BaseCommand.php b/app/Console/BaseCommand.php index 2cbea30b..9d662bd7 100644 --- a/app/Console/BaseCommand.php +++ b/app/Console/BaseCommand.php @@ -31,21 +31,35 @@ class BaseCommand extends Command /** * @param $cmd + * @param bool $return + * @return string */ - public function runCommand($cmd) + public function runCommand($cmd, $return=false, $verbose=true) { - if (is_array($cmd)) + if (\is_array($cmd)) { $cmd = join(' ', $cmd); + } - $this->info('Running "' . $cmd . '"'); + if($verbose) { + $this->info('Running "' . $cmd . '"'); + } + $val = ''; $process = new Process($cmd); - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - echo $buffer; + $process->run(function ($type, $buffer) use ($return, $val) { + if ($return) { + $val .= $buffer; } else { echo $buffer; } + + /*if (Process::ERR === $type) { + echo $buffer; + } else { + echo $buffer; + }*/ }); + + return $val; } } diff --git a/app/Console/Commands/Version.php b/app/Console/Commands/Version.php new file mode 100644 index 00000000..af8b92a9 --- /dev/null +++ b/app/Console/Commands/Version.php @@ -0,0 +1,34 @@ +option('write')) { + $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, 6); + $cfg['build']['number'] = $version; + + file_put_contents($version_file, Yaml::dump($cfg, 4, 2)); + } + + $this->call('version:show', [ + '--format' => 'compact', + '--suppress-app-name' => true + ]); + } +} diff --git a/config/version.yml b/config/version.yml index bda2968e..4b266084 100644 --- a/config/version.yml +++ b/config/version.yml @@ -1,29 +1,28 @@ -version_source: config # "config", "git-local" or "git-remote" +version_source: config current: major: 7 minor: 0 patch: 0 git_absorb: git-local - format: "{$major}.{$minor}.{$patch}" + format: '{$major}.{$minor}.{$patch}' build: mode: number - number: 451e9e + number: 18cb95 git_absorb: git-local git: - git-local: "git rev-parse --verify HEAD" - git-remote: "git ls-remote {$repository}" - branch: "refs/heads/master" - repository: "{{ env('VERSION_GIT_REMOTE_REPOSITORY') }}" + git-local: 'git rev-parse --verify HEAD' + git-remote: 'git ls-remote {$repository}' + branch: refs/heads/master + repository: '{{ env(''VERSION_GIT_REMOTE_REPOSITORY'') }}' version: - git-local: "git describe" - git-remote: "git ls-remote {$repository} | grep tags/ | grep -v {} | cut -d \/ -f 3 | sort --version-sort | tail -1" - matcher: "/[V|v]*[ersion]*\\s*\\.*(\\d+)\\.(\\d+)\\.(\\d+)\\.*(\\w*)/" + git-local: 'git describe' + git-remote: 'git ls-remote {$repository} | grep tags/ | grep -v {} | cut -d / -f 3 | sort --version-sort | tail -1' + matcher: '/[V|v]*[ersion]*\s*\.*(\d+)\.(\d+)\.(\d+)\.*(\w*)/' format: - major: "{$major}" - minor: "{$minor}" - patch: "{$patch}" - build: "{$build}" - version: "{$major}.{$minor}.{$patch} (build {$build})" - full: "version {{'format.version'}}" - compact: "v{$major}.{$minor}.{$patch}-{$build}" - ## add as many formats as you need !!!! + major: '{$major}' + minor: '{$minor}' + patch: '{$patch}' + build: '{$build}' + version: '{$major}.{$minor}.{$patch} (build {$build})' + full: 'version {{''format.version''}}' + compact: 'v{$major}.{$minor}.{$patch}-{$build}'