Reputation: 1805
I have a private repository in Git and I have managed to make it work with composer properly as a package. However, there is one thing that I dislike : When I specify the version of the repository, I have to say dev-master
, to get the master branch. What I would like instead is to be able to specify a repository version. So, how do I configure my repository to allow the other repositories that use it as a dependency with a version identifier ?
This is my package's composer.json, which resides in my one and only master
branch :
{
"name": "username/packagename",
"type": "mytype",
"version": "1.0.0"
}
And then in another project where I want to include this package I have this composer.json:
{
"repositories": [
{
"type": "git",
"url": "git@githost:username/packagename.git/"
}
],
"require": {
"username/packagename": "dev-master"
},
}
As you can see, I have to say 'dev-master'
to get my package from my master branch, but I want to be able to say '1.0.0' or '^1.0.0' or any other composer versioning operation available. What do I have to do in my package structure to enable proper versioning behaviour ?
Thanks in advance !
Upvotes: 1
Views: 671
Reputation: 70863
Create a tag, and before that: remove that version
entry in the composer.json
file.
Usage example for creating a tag on the master branch:
git checkout master
git tag -a 1.0.0
git push --follow-tags
Using annotated tags will record the date and username creating the tag. Git will ask for a message, which is rather irrelevant for most people, so you can fill in anything you like. I usually opt for repeating the tag name.
Removing the version
entry before tagging a version should be obvious. :)
Upvotes: 1