Skip to content

Commit 1dfd896

Browse files
committed
Merge branch 'release/0.2.0'
2 parents 1a6616c + f95a5b7 commit 1dfd896

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2251
-750
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ jdk:
33
- oraclejdk7
44
- openjdk7
55
before_install: git checkout $(git branch --contains $(git rev-parse HEAD)|tail -n1|tr -d ' ')
6-
after_success: ./gradlew bintrayUpload
6+
script: ./gradlew check --continue
7+
after_success: ./gradlew publish
78
branches:
89
only:
910
- master
11+
- develop

README.asciidoc

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
= gradle-gitflow
2+
Max Käufer;
3+
:version: 0.2.0
4+
:doc-version: 0.2.0
5+
:doc-path: https://amkay.github.io/gradle-gitflow/release/{doc-version}/doc
6+
:download-version: 0.2.0
7+
:download-path: https://bintray.com/amkay/gradle-plugins/com.github.amkay%3Agradle-gitflow/{download-version}
8+
:doctype: book
9+
:sectanchors:
10+
:sectlinks:
11+
:source-highlighter: highlightjs
12+
:icons: font
13+
14+
15+
image:https://img.shields.io/badge/download-{download-version}-blue.svg["Download", link="{download-path}"]
16+
image:https://img.shields.io/badge/docs-{doc-version}-blue.svg["Documentation", link="{doc-path}/groovydoc"]
17+
image:http://stillmaintained.com/amkay/gradle-gitflow.svg["Project Status", link="https://stillmaintained.com/amkay/gradle-gitflow"]
18+
image:https://img.shields.io/github/license/amkay/gradle-gitflow.svg["License", link="https://github.com/amkay/gradle-gitflow/blob/master/LICENSE.md"]
19+
image:https://travis-ci.org/amkay/gradle-gitflow.svg?branch=develop["Build Status", link="https://travis-ci.org/amkay/gradle-gitflow"]
20+
image:https://www.versioneye.com/user/projects/559c3d97616634001b000e87/badge.svg?style=flat["Dependency Status", link="https://www.versioneye.com/user/projects/559c3d97616634001b000e87"]
21+
image:https://img.shields.io/badge/semver-2.0.0-blue.svg["Semantic Versioning", link="http://semver.org/spec/v2.0.0.html"]
22+
image:https://img.shields.io/badge/git-flow-blue.svg["Gitflow", link="http://nvie.com/posts/a-successful-git-branching-model/"]
23+
24+
An opinionated plugin that provides http://semver.org/[Semantic Versioning] for https://gradle.org/[Gradle] projects that use http://nvie.com/posts/a-successful-git-branching-model/[Gitflow].
25+
26+
This plugin is heavily inspired by the https://github.com/ajoberstar/gradle-git[gradle-git] plugin.
27+
28+
IMPORTANT: It *intentionally* provides no https://gradle.org/[Gradle] tasks and interacts with http://git-scm.com/[Git] just for inferring the version of the project.
29+
30+
This inferred version is set as the project version of the https://gradle.org/[Gradle] project to which it is applied.
31+
32+
33+
34+
[[versioning]]
35+
== Versioning
36+
37+
[[version-rules]]
38+
=== Version rules
39+
40+
The rules applied when inferring the version are that simple:
41+
42+
* If the current commit is tagged this tag is used as a version -- regardless of the current branch
43+
** this would usually be the _normal version_ (`major.minor.patch`)
44+
* Otherwise the version contains
45+
** the _normal version_ (`major.minor.patch`) extracted from the next reachable tag in the history
46+
*** if the current commit is on a <<branch-identifier-mapping, pre-release>> branch, the _normal version_ is extracted from the name of this branch
47+
** a _pre-release identifier_ indicating the current branch
48+
** a _pre-release identifier_ indicating the number of commits since the last tag
49+
** a _build metadata identifier_ indicating the SHA of the current commit
50+
** a _build metadata identifier_ indicating if the repository is dirty
51+
52+
53+
[[version-structure]]
54+
=== Version structure
55+
56+
The inferred versions consist of the following components:
57+
58+
----
59+
1.2.3-dev.65+sha.9066228.dirty
60+
| | | | | | | |
61+
| | | | | | | indicates if the repository is dirty
62+
| | | | | | |
63+
| | | | | | abbreviated SHA of the current commit
64+
| | | | | |
65+
| | | | | prefix of the SHA
66+
| | | | |
67+
| | | | # of commits since the last tag
68+
| | | |
69+
| | | denotes the current branch
70+
| | |
71+
| | patch version
72+
| |
73+
| minor version
74+
|
75+
major version
76+
----
77+
78+
79+
[[branch-identifier-mapping]]
80+
=== Mapping between Gitflow branches and pre-release identifiers
81+
82+
The following table shows the mapping between http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] branches and the corresponding _pre-release identifiers_ that indicate these branches.
83+
84+
NOTE: If you use a <<gitflow-plugins, Gitflow plugin for Git>>, _gradle-gitflow_ uses the branch names and prefixes of your http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] configuration section in `.git/config`.
85+
If you do not use such a plugin, you will either have to stick to the default names in the table below or add http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] configuration sections to `.git/config` as described in <<gitflow-plugins>>.
86+
87+
|===
88+
| Gitflow branch | Default name in Gitflow plugins | Pre-release identifier | Notes
89+
90+
| production release
91+
| `master`
92+
| (empty string)
93+
|
94+
95+
| development
96+
| `develop`
97+
| `dev`
98+
|
99+
100+
| feature
101+
| `feature/foo`
102+
| `feature.foo`
103+
|
104+
105+
| next release / pre-release
106+
| `release/1.2.3`
107+
| `pre`
108+
| The _normal version_ (`major.minor.patch`) is extracted from the branch name
109+
110+
| hotfix
111+
| `hotfix/foo`
112+
| `fix.foo`
113+
|
114+
115+
| support
116+
| `support/foo`
117+
| `support.foo`
118+
|
119+
|===
120+
121+
NOTE: In case the current head is a _detached head_ the _pre-release identifier_ is `detached`.
122+
123+
124+
125+
[[usage]]
126+
== Usage
127+
128+
Include the following in the project on which you want to apply the plugin:
129+
130+
[source,groovy,subs="attributes"]
131+
----
132+
buildscript {
133+
repositories {
134+
jcenter()
135+
}
136+
137+
dependencies {
138+
classpath 'com.github.amkay:gradle-gitflow:{version}'
139+
}
140+
}
141+
142+
apply plugin: 'com.github.amkay.gitflow'
143+
----
144+
145+
NOTE: The latest build of the current development version can always be obtained from https://github.com/amkay/gradle-gitflow/tree/gh-pages/develop[here].
146+
147+
148+
[[configuration]]
149+
=== Configuration
150+
151+
The plugin registers an extension object named `gitflow` that is the entry point to the configuration.
152+
It also provides a DSL for keyword-based configuration, but configuration via properties is also possible.
153+
The following example shows all configuration options:
154+
155+
[source,groovy]
156+
----
157+
gitflow {
158+
// Use a different Git repository
159+
repositoryRoot 'foo/bar' // defaults to project.projectDir
160+
161+
// Pre-release identifiers based on Gitflow branches
162+
preReleaseIds {
163+
release 'foo' // defaults to ''
164+
develop 'foo' // defaults to 'dev'
165+
preRelease 'foo' // defaults to 'pre'
166+
detachedHead 'foo' // defaults to 'detached'
167+
168+
// The following ones are used as prefixes
169+
feature 'foo' // defaults to 'feature'
170+
hotfix 'foo' // defaults to 'fix'
171+
support 'foo' // defaults to 'support'
172+
}
173+
174+
// Build metadata identifiers that are used as static text
175+
buildMetadataIds {
176+
sha 'foo' // Defaults to 'sha'
177+
dirty 'foo' // Defaults to 'dirty'
178+
}
179+
}
180+
----
181+
182+
183+
[[gitflow-plugins]]
184+
=== Gitflow plugins for Git
185+
186+
This plugin supports the following http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] plugins for http://git-scm.com/[Git]:
187+
188+
* https://github.com/nvie/gitflow[git-flow]
189+
* https://github.com/petervanderdoes/gitflow[git-flow (AVH Edition)]
190+
191+
If you do not use one of the mentioned plugins *and* differ from the default names mentioned in <<branch-identifier-mapping>>, you will have to manually set the branch names and prefixes of the http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] branches and prefixes in `.git/config` like these plugins would do.
192+
This is the only way for _gradle-gitflow_ to pick up this configuration.
193+
194+
The following example shows the default configuration of the above plugins:
195+
196+
----
197+
[gitflow "branch"]
198+
master = master
199+
develop = develop
200+
[gitflow "prefix"]
201+
feature = feature/
202+
release = release/
203+
hotfix = hotfix/
204+
support = support/
205+
versiontag =
206+
----
207+
208+
WARNING: Keep in mind that most *CI* servers simply clone your repository after being called by a commit hook when you push your code.
209+
Therefore you will have to take care in your CI configuration that `.git/config` contains the http://nvie.com/posts/a-successful-git-branching-model/[Gitflow] configuration sections that _gradle-gitflow_ needs if you do not use the default names mentioned in <<branch-identifier-mapping>>.
210+
211+
212+
[[additional-functionality]]
213+
=== Additional functionality of the version object
214+
215+
The following additional functionality is provided by the version object that this plugin provides.
216+
You can have a look at the {doc-path}/groovydoc[Groovydoc] documentation for further information.
217+
218+
219+
[[version-type]]
220+
==== Version type
221+
222+
The type of the inferred version is derived from the current branch and corresponds to the branches mentioned in <<branch-identifier-mapping>>.
223+
This can be used in your buildscripts for distinguishing between development and production builds, e.g. for deploying to staging and production as seen in the following example.
224+
225+
[source,groovy]
226+
----
227+
import static com.github.amkay.gradle.gitflow.version.VersionType.*
228+
229+
task deploy << {
230+
if (version.type == DEVELOP) {
231+
// Deploy to staging...
232+
} else if (version.type == RELEASE) {
233+
// Deploy to production...
234+
}
235+
}
236+
----
237+
238+
TIP: For additional version types see the `enum` {doc-path}/groovydoc/com/github/amkay/gradle/gitflow/version/VersionType.html[VersionType] in the {doc-path}/groovydoc[Groovydoc] documentation.

README.md

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)