antonioribeiro / version

Laravel App versioning
MIT License
581 stars 103 forks source link

Increase app version with every git commit #54

Open hassan715 opened 5 years ago

hassan715 commented 5 years ago

I want assign the commit counts to patch number where: git describe > v1.5.0-3-g41abd80 currently when running php artisan version:show the result is: version 1.5.0 (build 41abd8) I want the result to be version 1.5.3 (build 41abd8) where patch number equals to commit counts.

antonioribeiro commented 5 years ago

This is exactly what it should show, unless you configure it to be used with version:absorb

antonioribeiro commented 5 years ago

On version 1.0 absorb is the way to go, you just have to run:

php artisan version:absorb
bolechen commented 4 years ago

There is a problem, in my project the config/version.yml is under the version control in my git response.

I put the php artisan version:absorb to my post-commit hook.

But when i commit some code, the version.yml file was auto update the current section, my git stats is always modified, is anyway am i wrong?

Is there any way to refresh the version but not update version.yml?

@antonioribeiro thx

$ git status
On branch develop
Your branch is ahead of 'origin/develop' by 2 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   config/version.yml

no changes added to commit (use "git add" and/or "git commit -a")
antonioribeiro commented 4 years ago

The version is stored in this file. I cannot find a way to securely store the version in a different way than in a file. So, if you version:absorb, the file will be updated.

If that's a problem for you and your deployment uses git to pull new versions, you can probably execute it it in the server, but to cleanup the directory before a new pull, you would probably have to do something like:

git reset --hard HEAD
git pull origin production
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
php artisan version:absorb
...
bolechen commented 4 years ago

The version is stored in this file. I cannot find a way to securely store the version in a different way than in a file. So, if you version:absorb, the file will be updated.

If that's a problem for you and your deployment uses git to pull new versions, you can probably execute it it in the server, but to cleanup the directory before a new pull, you would probably have to do something like:

git reset --hard HEAD
git pull origin production
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
php artisan version:absorb
...

This tips so helpful for me, thanks!

bolechen commented 4 years ago

In case when use git version:

First run read the version info from git-local or git-remote, and save the current version information to the .env file for cache.

Will this flow is better?

JunaidQadirB commented 4 years ago

The version is stored in this file. I cannot find a way to securely store the version in a different way than in a file. So, if you version:absorb, the file will be updated.

If that's a problem for you and your deployment uses git to pull new versions, you can probably execute it it in the server, but to cleanup the directory before a new pull, you would probably have to do something like:

git reset --hard HEAD
git pull origin production
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
php artisan version:absorb
...

I'm using post-hook on me server to run commands as i push. how can I achieve the same results?

I get this error: Unable to find git tags in this repository that matches the git.version.matcher pattern in version.yml because I don't have the .git directory i tried setting the GIT_WORK_TREE before calling the version:absorb command but no luck.

JunaidQadirB commented 4 years ago

I finally settled with adding php artisan version:absorb to the scripts section of composer.json under post-autoload-dump and it is working nicely and as @antonioribeiro suggested to reset the remote repo before pulling new changes. Works perfectly. Thanks!