Skip to content

Commit 8774277

Browse files
authored
Merge pull request #4064 from HHobeck/feature/document-git-hub-flow-workflow
[Documentation]: Documenting the GitHubFlow workflow and create sequence diagrams
2 parents c8029ef + 7db8407 commit 8774277

14 files changed

+249
-173
lines changed
Loading
Loading
Loading
Loading

docs/input/docs/learn/branching-strategies/gitflow/examples.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ iterations. Release branches are taken from `main` (or from `develop`) and will
8686
be merged back afterwards. Finally the `main` branch is tagged with the
8787
released version.
8888

89+
Release branches can be used in the `GitFlow` as well as `GitHubFlow` workflow.
90+
Sometimes you want to start on a large feature which may take a while
91+
to stabilize so you want to keep it off main.
92+
In these scenarios you can either create a long lived
93+
feature branch (if you do not know the version number this large feature will go
94+
into, and it's non-breaking) otherwise you can create a release branch for the
95+
next major version. You can then submit pull requests to the long lived feature
96+
branch or the release branch.
97+
8998
### Create release branch
9099

91100
![GitFlow](/docs/img/DocumentationSamplesForGitFlow\_ReleaseBranch.png)

docs/input/docs/learn/branching-strategies/githubflow/examples.md

Lines changed: 73 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,88 @@ Title: GitHubFlow Examples
44
RedirectFrom: docs/git-branching-strategies/githubflow-examples
55
---
66

7-
## Feature branch
7+
These examples are illustrating the usage of the supported `GitHubFlow` workflow
8+
in GitVersion. To enable this workflow, the builtin template
9+
[GitHubFlow/v1](/docs/workflows/GitHubFlow/v1.json) needs to be referenced in the
10+
configuration as follows:
11+
```yaml
12+
workflow: GitHubFlow/v1
13+
mode: ContinuousDelivery
14+
```
815
9-
![GitHubFlow](/docs/img/githubflow_feature-branch.png)
16+
Where
17+
the [continuous deployment][continuous-deployment] mode for no branches,
18+
the [continuous delivery][continuous-delivery] mode for
19+
`main` branch and
20+
the [manual deployment][manual-deployment] mode
21+
for `release`, `feature` and `unknown` branches are specified.
1022

11-
## Pull requests
23+
This configuration allows you to publish CI (Continuous Integration) builds
24+
from `main` branch to an artifact repository.
25+
All other branches are manually published. Read more about this at
26+
[version increments](/docs/reference/version-increments).
1227

13-
![GitHubFlow](/docs/img/githubflow_pull-request.png)
28+
:::{.alert .alert-info}
29+
The _continuous delivery_ mode has been used for the `main` branch in this
30+
examples (specified as a fallback on the root
31+
configuration layer) to illustrate how the version increments are applied.
32+
In production context the _continuous deployment_ mode might be a better
33+
option when e.g. the release process is automated or the commits are tagged
34+
by the pipeline automatically.
35+
:::
1436

15-
## Release branch
37+
## Feature Branch
1638

17-
Release branches can be used in GitHubFlow as well as GitFlow. Sometimes you
39+
Feature branches can be used in the `GitHubFlow` workflow to implement a
40+
feature or fix a bug in an isolated environment. Feature branches will take
41+
the feature
42+
branch name and use that as the pre-release label. Feature branches will be
43+
created from a `main` or `release` branch.
44+
45+
### Create feature branch from main
46+
47+
![GitHubFlow](/docs/img/DocumentationSamplesForGitHubFlow_FeatureBranch.png)
48+
49+
:::{.alert .alert-info}
50+
After the feature branch is merged, the version on `main` is `2.0.0-5`.
51+
This is due to `main` running in _continuous delivery_ mode. If `main` was
52+
configured to use _continuous deployment_ the version would be `2.0.0`.
53+
:::
54+
55+
## Release Branches
56+
57+
Release branches are used for major, minor and patch releases to stabilize a RC
58+
(Release Candidate) or to integrate features/hotfixes (in parallel) targeting
59+
different
60+
iterations. Release branches are taken from `main` and will
61+
be merged back afterwards. Finally the `main` branch is tagged with the
62+
released version.
63+
64+
Release branches can be used in the `GitHubFlow` as well as `GitFlow` workflow.
65+
Sometimes you
1866
want to start on a large feature which may take a while to stabilize so you want
1967
to keep it off main. In these scenarios you can either create a long lived
2068
feature branch (if you do not know the version number this large feature will go
2169
into, and it's non-breaking) otherwise you can create a release branch for the
2270
next major version. You can then submit pull requests to the long lived feature
2371
branch or the release branch.
2472

25-
![GitFlow](/docs/img/githubflow_release-branch.png)
73+
### Create release branch
74+
75+
![GitFlow](/docs/img/DocumentationSamplesForGitHubFlow_ReleaseBranch.png)
76+
77+
### Create release branch with version
78+
79+
![GitFlow](/docs/img/DocumentationSamplesForGitHubFlow_VersionedReleaseBranch.png)
80+
81+
## To Contribute
82+
83+
See [contributing examples](/docs/learn/branching-strategies/contribute-examples).
84+
85+
### Source
86+
87+
See `DocumentationSamplesForGitHubFlow.cs`. To update, modify then run test.
88+
89+
[continuous-deployment]: /docs/reference/modes/continuous-deployment
90+
[continuous-delivery]: /docs/reference/modes/continuous-delivery
91+
[manual-deployment]: /docs/reference/modes/manual-deployment

docs/input/docs/reference/configuration.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following supported workflow configurations are available in GitVersion and
3737

3838
- GitFlow (GitFlow/v1)
3939
- GitHubFlow (GitHubFlow/v1)
40+
- TrunkBased (TrunkBased/preview1)
4041

4142
Example of using a `GitHubFlow` workflow with a different `tag-prefix`:
4243

@@ -338,6 +339,91 @@ is-release-branch: false
338339
is-main-branch: false
339340
```
340341

342+
The preview built-in configuration (experimental usage only) for the `TrunkBased` workflow (`workflow: TrunkBased/preview1`) looks like:
343+
344+
```yaml
345+
assembly-versioning-scheme: MajorMinorPatch
346+
assembly-file-versioning-scheme: MajorMinorPatch
347+
tag-prefix: '[vV]?'
348+
version-in-branch-pattern: (?<version>[vV]?\d+(\.\d+)?(\.\d+)?).*
349+
major-version-bump-message: '\+semver:\s?(breaking|major)'
350+
minor-version-bump-message: '\+semver:\s?(feature|minor)'
351+
patch-version-bump-message: '\+semver:\s?(fix|patch)'
352+
no-bump-message: '\+semver:\s?(none|skip)'
353+
tag-pre-release-weight: 60000
354+
commit-date-format: yyyy-MM-dd
355+
merge-message-formats: {}
356+
update-build-number: true
357+
semantic-version-format: Strict
358+
strategies:
359+
- Mainline
360+
- ConfiguredNextVersion
361+
branches:
362+
main:
363+
mode: ContinuousDeployment
364+
label: ''
365+
increment: Patch
366+
prevent-increment:
367+
of-merged-branch: true
368+
when-current-commit-tagged: true
369+
track-merge-target: false
370+
regex: ^master$|^main$
371+
source-branches: []
372+
tracks-release-branches: false
373+
is-release-branch: false
374+
is-main-branch: true
375+
pre-release-weight: 55000
376+
feature:
377+
increment: Minor
378+
regex: ^features?[/-](?<BranchName>.+)
379+
prevent-increment:
380+
when-current-commit-tagged: false
381+
source-branches:
382+
- main
383+
pre-release-weight: 30000
384+
hotfix:
385+
increment: Patch
386+
regex: ^hotfix(es)?[/-](?<BranchName>.+)
387+
prevent-increment:
388+
when-current-commit-tagged: false
389+
source-branches:
390+
- main
391+
pre-release-weight: 30000
392+
pull-request:
393+
mode: ContinuousDelivery
394+
label: PullRequest
395+
increment: Inherit
396+
label-number-pattern: '[/-](?<number>\d+)'
397+
regex: ^(pull|pull\-requests|pr)[/-]
398+
source-branches:
399+
- main
400+
pre-release-weight: 30000
401+
unknown:
402+
increment: Patch
403+
regex: (?<BranchName>.+)
404+
prevent-increment:
405+
when-current-commit-tagged: false
406+
source-branches:
407+
- main
408+
pre-release-weight: 30000
409+
ignore:
410+
sha: []
411+
mode: ContinuousDelivery
412+
label: '{BranchName}'
413+
increment: Inherit
414+
prevent-increment:
415+
of-merged-branch: false
416+
when-branch-merged: false
417+
when-current-commit-tagged: true
418+
track-merge-target: false
419+
track-merge-message: true
420+
commit-message-incrementing: Enabled
421+
regex: ''
422+
tracks-release-branches: false
423+
is-release-branch: false
424+
is-main-branch: false
425+
```
426+
341427
The details of the available options are as follows:
342428

343429
### workflow

docs/input/docs/reference/modes/continuous-delivery.md

Lines changed: 20 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,39 @@
22
Order: 20
33
Title: Continuous Delivery
44
Description: |
5-
Continuous Delivery is the default versioning mode. In this mode,
6-
GitVersion calculates the next version and will use that until that is
7-
released.
5+
Sometimes you just want the version to keep changing and deploy continuously
6+
to an testing system. In this case, Continuous Delivery is a good mode to
7+
operate GitVersion by.
88
RedirectFrom: docs/reference/versioning-modes/continuous-delivery
99
---
1010

11-
Continuous Delivery is the practice of having a deployment pipeline and is the
12-
default mode in GitVersion. Each stage of the pipeline gets the code going
13-
through the pipeline closer to production.
11+
Continuous Delivery is the process of checking into a branch, running all the
12+
tests and if everything goes green it is automatically pushed to a testing system.
1413

15-
The topic itself is rather large, here we will just focus on the building and
16-
creation of _releasable_ artifacts. This is only a part of continuous delivery
17-
as a whole, with the hard part being the ability to measure the impacts of what
18-
you have deployed into production.
14+
A good case for Continuous Delivery is when using Octopus deploy, as you
15+
cannot publish the same version of a package into the same feed.
1916

20-
In essence continuous delivery means:
21-
22-
* Your code is automatically built and tested
23-
* If any of the automated tests fail, the team's #1 priority is to fix the
24-
build
25-
* If the build is green, the application can be deployed at any time
26-
* Ideally the business should make that decision
27-
* The same artifacts which were built and tested should be deployed
28-
* That means no rebuilding everything when you are deploying
29-
30-
Continuous delivery does not work well with GitFlow. The reason is that you are
31-
required to _merge_ to main to do a release, triggering a rebuild and a new
32-
set of artifacts to go through your pipeline. Depending on how long your
33-
pipeline is, this could be a while.
34-
35-
GitHubFlow is a better fit for Continuous delivery, the [mainline
36-
development][mainline] model means that every merged feature branch will be
37-
built as a _stable_ version and if the build/builds go green then you are free
38-
to deploy to production at any time.
39-
40-
## Usage
41-
42-
By default, GitVersion is set up to do Continuous Delivery on all branches but
43-
`develop`, which is set up with [Continuous Deployment][continuous-deployment].
44-
To change the mode to Continuous Delivery, change your
45-
[configuration][configuration] to:
46-
47-
```yaml
48-
mode: ContinuousDelivery
49-
```
17+
For this mode we follow the logic in [this blog post by Xavier Decoster][blog]
18+
on the issues of incrementing automatically.
5019

5120
## How Continuous Delivery affects GitVersion
5221

53-
The thing about continuous delivery is that there will be _multiple_ candidates
54-
to deploy to production and it is a human choice to deploy. This means that
55-
GitVersion will build **the same semantic version** until that version is
56-
deployed. For instance:
22+
Continuous delivery is good when you deploy continuously to an testing system.
5723

58-
* 1.1.0+5
59-
* 1.1.0+6
60-
* 1.1.0+7 <-- This is the artifact we release, tag the commit which created
61-
this version
62-
* 1.1.1+0
24+
* 1.1.0-3
25+
* 1.1.0-2 (tag: 1.1.0-2) <-- This is the version which has been deployed on testing
26+
* 1.1.0-1
27+
* 1.1.1-0
6328

64-
Tags are required in this mode to communicate when the release is done as it's
65-
an external manual process.
29+
Tags are not required but optional in this mode to communicate when the release
30+
is done as it's an automated process.
6631

6732
## Resources
6833

69-
* [Continuous Delivery on Wikipedia][wikipedia]
70-
* [Continuous Delivery, the book][book]
34+
* [Configuration][configuration]
35+
* [Semantic Versioning & auto-incremented NuGet package versions][blog]
36+
* [Continuous delivery][wikipedia]
7137

72-
[book]: https://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912
7338
[configuration]: /docs/reference/configuration
74-
[continuous-deployment]: /docs/reference/modes/continuous-deployment
75-
[mainline]: /docs/reference/modes/mainline
39+
[blog]: https://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions
7640
[wikipedia]: https://en.wikipedia.org/wiki/Continuous_delivery

docs/input/docs/reference/modes/continuous-deployment.md

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,32 @@ Order: 30
33
Title: Continuous Deployment
44
Description: |
55
Sometimes you just want the version to keep changing and deploy continuously.
6-
In this case, Continuous Deployment is a good mode to operate GitVersion by.
76
RedirectFrom: docs/reference/versioning-modes/continuous-deployment
87
---
98

10-
Continuous Deployment is the process of checking into main, running all the
11-
tests and if everything goes green it is automatically pushed to production.
12-
13-
A good case for Continuous Deployment is when using Octopus deploy, as you
14-
cannot publish the same version of a package into the same feed.
9+
Continuous Deployment is the process of checking into main and automatically
10+
deploying to production.
1511

1612
For this mode we follow the logic in [this blog post by Xavier Decoster][blog]
1713
on the issues of incrementing automatically.
1814

19-
As such we force a pre-release tag on all branches, this is fine for
20-
applications but can cause problems for libraries. As such this mode may or may
21-
not work for you, which leads us into a new mode in v4 of GitVersion:
22-
[Mainline Development][mainline].
15+
## How Continuous Deployment affects GitVersion
2316

24-
### Usage
17+
The thing about continuous deployment is that there will be only one version
18+
to deploy on production. This means that GitVersion will build
19+
**the same semantic version** for every commit until it has been tagged. For instance:
2520

26-
By default GitVersion is set up to do Continuous Deployment versioning on the
27-
`develop` branch, but for all other branches, [Continuous
28-
Delivery][continuous-delivery] is the default mode. From version 3 of GitVersion
29-
this behavior is [configurable][configuration].
21+
* 1.2.0
22+
* 1.1.0 (tag: 1.1.0) <-- This is the version which has been deployed on production
23+
* 1.1.0
24+
* 1.1.1
3025

31-
The default behavior for v3 and how v1 & 2 worked was that the version only
32-
incremented after a tag, which signified a release. In v3 you can simply switch
33-
the default mode in the [configuration][configuration] from `ContinuousDelivery`
34-
to `ContinuousDeployment` and the version will then increment each commit,
35-
giving you the features of GitVersion with continuous deployment:
26+
Tags are required in this mode to communicate when the deployement happens on production.
3627

37-
```yaml
38-
mode: ContinuousDeployment
39-
```
28+
## Resources
29+
30+
* [Configuration][configuration]
31+
* [Semantic Versioning & auto-incremented NuGet package versions][blog]
4032

41-
[blog]: https://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions
4233
[configuration]: /docs/reference/configuration
43-
[continuous-delivery]: /docs/reference/modes/continuous-delivery
44-
[mainline]: /docs/reference/modes/mainline
34+
[blog]: https://www.xavierdecoster.com/semantic-versioning-auto-incremented-nuget-package-versions

0 commit comments

Comments
 (0)