From 512d8a2172a406917ad517a9a4a0a2d3d05a7b1a Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sat, 3 Feb 2018 13:16:37 -0600 Subject: [PATCH] Read the version base from the install for the deployment --- .travis.yml | 11 ++++++----- .travis/deploy_script.sh | 10 ++++++---- app/Console/Commands/Version.php | 27 +++++++++++++++++---------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6cf0ebff..4be67ea9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,8 +40,9 @@ jobs: - if [ "$TRAVIS_BRANCH" = "dev" ]; then ./.travis/deploy_script.sh; fi - if [ "$TRAVIS_BRANCH" = "master" ]; then ./.travis/deploy_script.sh; fi on: - php: '7.0' - - stage: deploy-release + all_branches: true + php: '7.0' + - stage: release script: skip before_deploy: - curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash @@ -54,6 +55,6 @@ jobs: file_glob: true file: build/* on: - tags: true - repo: nabeelio/phpvms - php: '7.0' + tags: true + repo: nabeelio/phpvms + php: '7.0' diff --git a/.travis/deploy_script.sh b/.travis/deploy_script.sh index b7dab83f..d5824ea1 100755 --- a/.travis/deploy_script.sh +++ b/.travis/deploy_script.sh @@ -2,26 +2,28 @@ if [ "$TRAVIS" = "true" ]; then + cd $TRAVIS_BUILD_DIR + if test "$TRAVIS_TAG"; then PKG_NAME=$TRAVIS_TAG else - PKG_NAME=v7.0.0-$TRAVIS_BRANCH + BASE_VERSION=`php artisan phpvms:version --base-only` + PKG_NAME=$BASE_VERSION-$TRAVIS_BRANCH fi FILE_NAME="phpvms-$PKG_NAME" TAR_NAME="$FILE_NAME.tar.gz" echo "Writing $TAR_NAME" - cd $TRAVIS_BUILD_DIR - php artisan phpvms:version --write > VERSION VERSION=`cat VERSION` echo "Version: $VERSION" echo "Cleaning files" + make clean - rm -rf env.php + rm -rf env.php config.php find ./vendor -type d -name ".git" -print0 | xargs rm -rf find . -type d -name "sass-cache" -print0 | xargs rm -rf diff --git a/app/Console/Commands/Version.php b/app/Console/Commands/Version.php index 9740b216..6675cf26 100644 --- a/app/Console/Commands/Version.php +++ b/app/Console/Commands/Version.php @@ -7,7 +7,7 @@ use Symfony\Component\Yaml\Yaml; class Version extends BaseCommand { - protected $signature = 'phpvms:version {--write}'; + protected $signature = 'phpvms:version {--write} {--base-only}'; /** * Create the version number that gets written out @@ -31,20 +31,27 @@ class Version extends BaseCommand */ public function handle() { + $version_file = config_path('version.yml'); + $cfg = Yaml::parse(file_get_contents($version_file)); + if($this->option('write')) { - $version_file = config_path('version.yml'); - - $cfg = Yaml::parse(file_get_contents($version_file)); - $version = $this->createVersionNumber($cfg); $cfg['build']['number'] = $version; - file_put_contents($version_file, Yaml::dump($cfg, 4, 2)); } - $this->call('version:show', [ - '--format' => 'compact', - '--suppress-app-name' => true - ]); + # Only show the major.minor.patch version + if($this->option('base-only')) { + $version = 'v'.$cfg['current']['major'] . '.' + .$cfg['current']['minor'] . '.' + .$cfg['current']['patch']; + + print $version; + } else { + $this->call('version:show', [ + '--format' => 'compact', + '--suppress-app-name' => true + ]); + } } }