Skip to content

Commit 1146d58

Browse files
committed
Updating readme
1 parent 3ede844 commit 1146d58

File tree

2 files changed

+142
-13
lines changed

2 files changed

+142
-13
lines changed

Icons/CommitGraph.png

49.6 KB
Loading

README.md

Lines changed: 142 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
![Icon](https://raw.github.com/Particular/GitVersion/master/Icons/package_icon.png)
22

3-
The easy way to use semantic versioning (semver.org) with a Git.
4-
5-
GitVersion uses your *git* repository branching conventions to determine the current [Semantic Version](http://semver.org) of your application. It supports [GitFlow](https://github.com/Particular/GitVersion/wiki/GitFlow) and the much simpler [GitHubFlow](https://github.com/Particular/GitVersion/wiki/GitHubFlow) and might work with others (let us know).
3+
The easy way to use semantic versioning (semver.org) with a Git. Running GitVersion will calculate the SemVer of your application by looking at your git history.
64

75
GitVersion in action!
86

@@ -13,23 +11,153 @@ You are seeing:
1311
- Pull requests being built as pre-release builds
1412
- A branch called `release-1.0.0` producing beta v1 packages
1513

16-
Once a release is done, and you **tag** the commit which was released, the version will automatically be bumped. See our wiki for the rules and examples of how we increment the SemVer.
17-
18-
## Usage:
19-
20-
GitVersion can be used in several ways
14+
## Examples
15+
16+
## How it works
17+
![README](Icons/CommitGraph.png)
18+
19+
At each commit sha GitVersion will calculate:
20+
21+
- e137e9 - 1.0.0+0
22+
- a5f6c5 - 1.0.1+1
23+
- adb29a - 1.0.1-feature-foo.1+1 (PR #5 Version: `1.0.1-PullRequest.5+2`)
24+
- 7c2438 - 1.0.1-feature-foo.1+2 (PR #5 Version: `1.0.1-PullRequest.5+3`)
25+
- 5f413b - 1.0.1+4
26+
- d6155b - 2.0.0-rc.1+0 (Before and after tag)
27+
- d53ab6 - 2.0.0-rc.2+1 (Pre-release number was bumped because of the tag on previous commit)
28+
- b5d142 - 2.0.0+0 (2.0.0 branch was merged, so master is now at 2.0.0)
29+
30+
This is just a small sample of the way GitVersion works. The idea is you just plug it in and you will get sensible version numbers by default. We support the following branch types ootb:
31+
32+
- master
33+
- develop
34+
- hotfix/
35+
- feature/
36+
- pull requests (stash, github and a few others)
37+
- support/
38+
- release/
39+
40+
If you have other branch types GitVersion is entirely configuration driven, so check out the [Configuration](#Configuration) section of the readme to understand how to make GitVersion work for you.
41+
42+
<a name='continuousdeployment' />
43+
## Octopus Deploy/CI Build NuGet Packages
44+
Those of you who have tried to do SemVer with Octopus Deploy or consume CI packages out of TeamCity would have hit
45+
the problem that the SemVer version does not change each commit.
46+
47+
By default GitVersion is setup for *continuous delivery*, meaning that when you want to release you publish the artifact attached to your CI Build ([read more about what this means](https://github.com/ParticularLabs/GitVersion/wiki/Continuous-Delivery-Mode).
48+
49+
If you want to consume packages from you CI server, for instance Octopus Deploy is looking at TeamCity's NuGet feed then you want GitVersion's *continuous deployment mode*. See the [Configuration]
50+
51+
When using the continuous deployment mode all builds *must* have a pre-release tag, except for builds which are explicitly tagged as stable.
52+
Then the build metadata (which is the commit count) is promoted to the pre-release tag. Applying those rules the above commit graph would produce:
53+
54+
- e137e9 - 1.0.0+0
55+
- a5f6c5 - 1.0.1-ci.1
56+
- adb29a - 1.0.1-feature-foo.1 (PR #5 Version: `1.0.1-PullRequest.5+2`)
57+
- 7c2438 - 1.0.1-feature-foo.2 (PR #5 Version: `1.0.1-PullRequest.5+3`)
58+
- 5f413b - 1.0.1-ci.4
59+
- d6155b - 2.0.0-rc.1+4 (Before and after tag)
60+
- d53ab6 - 2.0.0-rc.2 (If there was another commit on the release branch it would be 2.0.0-rc.3)
61+
- b5d142 - 2.0.0-ci.0 (2.0.0 branch was merged, so master is now at 2.0.0)
62+
63+
As you can see the versions now no longer conflict. When you want to create a stable `2.0.0` release you simply `git tag 2.0.0` then build the tag and it will produce a stable 2.0.0 package.
64+
65+
### NuGet Compatibility
66+
Again, if you have used NuGet you would notice the versions above are not compatible with NuGet. GitVersion solves this by providing *variables*.
67+
68+
What you have seen above is the **SemVer** variable. You can use the **NuGetVersion** variable to have the version formatted in a NuGet compatible way.
69+
So `1.0.1-rc.1+5` would become `1.0.1-rc0001`, this takes into account characters which are not allowed and NuGets crap sorting.
70+
71+
**note: ** The `NuGetVersion` variable is floating, so when NuGet 3.0 comes out with proper SemVer support GitVersion will switch this variable to a proper SemVer.
72+
If you want to fix the version, use `NuGetVersionV2` which will stay the same after NuGet 3.0 comes out
73+
74+
## Variables
75+
Variables are quite useful if you need different formats of the version number. Running `GitVersion.exe` in your repo will show you what is available.
76+
For the `release/3.0.0` branch of GitVersion it shows:
77+
```json
78+
{
79+
"Major":3,
80+
"Minor":0,
81+
"Patch":0,
82+
"PreReleaseTag":"beta.1",
83+
"PreReleaseTagWithDash":"-beta.1",
84+
"BuildMetaData":1,
85+
"FullBuildMetaData":"1.Branch.release/3.0.0.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
86+
"MajorMinorPatch":"3.0.0",
87+
"SemVer":"3.0.0-beta.1",
88+
"LegacySemVer":"3.0.0-beta1",
89+
"LegacySemVerPadded":"3.0.0-beta0001",
90+
"AssemblySemVer":"3.0.0.0",
91+
"FullSemVer":"3.0.0-beta.1+1",
92+
"InformationalVersion":"3.0.0-beta.1+1.Branch.release/3.0.0.Sha.28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
93+
"BranchName":"release/3.0.0",
94+
"Sha":"28c853159a46b5a87e6cc9c4f6e940c59d6bc68a",
95+
"NuGetVersionV2":"3.0.0-beta0001",
96+
"NuGetVersion":"3.0.0-beta0001"
97+
}
98+
99+
```
100+
101+
## Configuration
102+
GitVersion 3.0 is mainly powered by configuration and no longer has branching strategies hard coded. This means it probably can be changed to work for your scenario.
103+
104+
To create your config file just type `GitVersion init` in your repo directory after installing via chocolatey and we will create a sample (but commented out) config file.
105+
Uncomment and modify as you need.
106+
107+
The configuration options are:
108+
109+
- `?assembly-versioning-scheme`: When updating assembly info tells GitVersion how to treat the AssemblyVersion attribute. Useful to lock the major when using Strong Naming.
110+
- `mode`: Either ContinuousDelivery or ContinuousDeployment. See [Octopus Deploy/CI Build NuGet Packages](#continuousdeployment) above for more information
111+
- `tag-prefix`: A regex which is used to trim git tags before processing (eg v1.0.0). Default is `[vV]` though this is just for illustrative purposes as we do a IgnoreCase match and could be `v`
112+
113+
Then we have branch specific configuration, which looks something like this:
114+
115+
``` yaml
116+
branches:
117+
master:
118+
tag:
119+
increment: Patch
120+
preventIncrementOfMergedBranchVersion: true
121+
(pull|pull\-requests|pr)[/-]:
122+
tag: PullRequest
123+
increment: Inherit
124+
tagNumberPattern: '[/-](?<number>\d+)[-/]'
125+
```
126+
127+
The options in here are:
128+
- `tag`: The pre release tag to use for this branch
129+
- `increment`: the part of the SemVer to increment when GitVersion detects it needs to be (i.e commit after a tag)
130+
- `preventIncrementOfMergedBranchVersion`: When `release-2.0.0` is merged into master, we want master to build `2.0.0`.
131+
If `release-2.0.0` is merged into develop we want it to build `2.1.0`, this option prevents incrementing after a versioned branch is merged
132+
- `tagNumberPattern`: Pull requests require us to pull the pre-release number out of the branch name so `refs/pulls/534/merge` builds as `PullRequest.5`.
133+
This is a regex with a named capture group called `number`
134+
135+
We don't envision many people needing to change most of these configuration values, but they are there if you need to.
136+
137+
## Build Server support
138+
GitVersion has support for quite a few build servers out of the box. Currently we support:
139+
140+
- TeamCity
141+
- AppVeyor
142+
- Continua Ci
143+
- MyGet
144+
145+
When GitVersion.exe is run with the `/output buildserver` flag instead of outputting Json it will export variables to the current build server.
146+
For instance if you are running in TeamCity after you run `GitVersion /output buildserver` you will have the `%system.GitVersion.SemVer%` available for you to use
147+
148+
When running in MSBuild either from the MSBuild Task or by using the `/proj myproject.sln` GitVersion will make the MSBuild variables available in the format `$(GitVersion_SemVer)`.
149+
150+
## MSBuild Task/Ruby Gem/API
151+
GitVersion has multiple ways it can be consumed.
21152

153+
- [A Command Line tool](https://github.com/Particular/GitVersion/wiki/Command-Line-Tool)
22154
- [An MSBuild Task](https://github.com/Particular/GitVersion/wiki/MSBuild-Task-Usage)
23155
- [A NuGet Library package](https://github.com/Particular/GitVersion/wiki/GitVersion-NuGet-Library) - to use from your own code
24-
- [A Command Line tool](https://github.com/Particular/GitVersion/wiki/Command-Line-Tool)
25156
- [A Ruby Gem](https://github.com/Particular/GitVersion/wiki/Ruby-Gem)
26157

27158
### Examples
28159
We have a bunch of examples in our Wiki, if something is missing, let us know! There are examples for GitHubFlow and GitFlow
29160

30-
### Supported Variables
31-
Because not everyone is the same, we give you a bunch of different variables which you can use in your builds to meet *your* requirements
32-
33161
### Who is using GitVersion?
34162
Find a list of projects who are currently using GitVersion [here](https://github.com/ParticularLabs/GitVersion/wiki/Who-is-using-GitVersion%3F)
35163

@@ -39,12 +167,13 @@ Find a list of projects who are currently using GitVersion [here](https://github
39167

40168
### [Semantic Versioning](http://semver.org/)
41169

170+
### [Git Visualiser used above](http://onlywei.github.io/explain-git-with-d3/)
171+
42172
## Chat
43173

44174
Have questions? Come join in the chat room:
45175

46176
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/ParticularLabs/GitVersion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
47177

48178
## Icon
49-
50179
<a href="http://thenounproject.com/noun/tree/#icon-No13389" target="_blank">Tree</a> designed by <a href="http://thenounproject.com/david.chapman" target="_blank">David Chapman</a> from The Noun Project

0 commit comments

Comments
 (0)