Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase app version with every git commit #54

Open
hassan715 opened this issue Feb 18, 2019 · 8 comments
Open

Increase app version with every git commit #54

hassan715 opened this issue Feb 18, 2019 · 8 comments

Comments

@hassan715
Copy link

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
Copy link
Owner

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

@antonioribeiro
Copy link
Owner

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

php artisan version:absorb

@bolechen
Copy link

bolechen commented Sep 29, 2019

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
Copy link
Owner

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
Copy link

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
Copy link

bolechen commented Sep 30, 2019

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
Copy link

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
Copy link

JunaidQadirB commented Jun 16, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants