|
| 1 | +--- |
| 2 | +Order: 40 |
| 3 | +Title: Trunk-based (preview) |
| 4 | +Description: Configure and evaluate the experimental TrunkBased workflow |
| 5 | +--- |
| 6 | + |
| 7 | +Use `TrunkBased/preview1` when your team integrates into one main branch, |
| 8 | +works directly on that branch or uses short-lived feature and hotfix branches, |
| 9 | +and wants versions calculated from that mainline history. Release tags record |
| 10 | +published versions; a separate develop or release branch is not required. |
| 11 | + |
| 12 | +This preset is **experimental**. Evaluate it against representative histories |
| 13 | +before adopting it. Its defaults and behavior may change; it does not have the |
| 14 | +same compatibility guarantees as `GitFlow/v1` and `GitHubFlow/v1`. |
| 15 | + |
| 16 | +## Start with the preset |
| 17 | + |
| 18 | +Create `GitVersion.yml` at the repository root: |
| 19 | + |
| 20 | +```yaml |
| 21 | +workflow: TrunkBased/preview1 |
| 22 | +``` |
| 23 | +
|
| 24 | +Inspect the resolved defaults and the version at your current commit: |
| 25 | +
|
| 26 | +```shell |
| 27 | +dotnet-gitversion --show-config |
| 28 | +dotnet-gitversion --show-variable FullSemVer |
| 29 | +``` |
| 30 | + |
| 31 | +The preset selects the `ConfiguredNextVersion` and `Mainline` calculation |
| 32 | +strategies. [Mainline](/docs/reference/modes/mainline) interprets commits and |
| 33 | +merges to calculate version increments; it is a strategy, not a deployment mode. |
| 34 | +You do not need to override `strategies` or set `next-version` to use this preset. |
| 35 | + |
| 36 | +For overrides, follow the [v7 configuration layout](/docs/reference/configuration#v7-configuration-layout): |
| 37 | +`workflow` stays at the root, version-calculation settings go under |
| 38 | +`calculation`, and output settings go under `output`. |
| 39 | + |
| 40 | +## Branch defaults |
| 41 | + |
| 42 | +These are the defaults of `TrunkBased/preview1`, without overrides: |
| 43 | + |
| 44 | +| Branch type | Recognized names | Increment | Deployment mode | Pre-release label | |
| 45 | +| --- | --- | --- | --- | --- | |
| 46 | +| main | `main`, `master` | Patch | ContinuousDeployment | Empty | |
| 47 | +| feature | `feature/foo`, `features/foo` | Minor | ContinuousDelivery | Branch name, such as `foo` | |
| 48 | +| hotfix | `hotfix/fix`, `hotfixes/fix` | Patch | ContinuousDelivery | Branch name, such as `fix` | |
| 49 | +| pull-request | `pull/42`, `pull-requests/42`, `pr/42` (including merge refs) | Inherit | ContinuousDelivery | `PullRequest42` | |
| 50 | +| unknown | Other names | Patch | ContinuousDelivery | Branch name | |
| 51 | + |
| 52 | +The feature, hotfix, and pull-request patterns also accept `-` as the separator. |
| 53 | +Feature, hotfix, and unknown branches list `main` as their source branch type; |
| 54 | +pull requests list `main`, `feature`, and `hotfix`. Hotfix branches are marked |
| 55 | +`is-release-branch: true`. The preset has no dedicated `develop`, `release`, or |
| 56 | +`support` branch configuration: those names use the unknown-branch fallback. |
| 57 | + |
| 58 | +On `main`, ContinuousDeployment produces versions without a pre-release suffix. |
| 59 | +An untagged commit can therefore have a stable-looking version; that alone does |
| 60 | +not mean it has been published. Feature and hotfix builds carry branch labels. |
| 61 | +Commit-message incrementing is enabled, and the default tag prefix accepts |
| 62 | +both `1.2.0` and `v1.2.0`. |
| 63 | + |
| 64 | +See the [complete built-in configuration](/docs/reference/configuration#global-configuration) |
| 65 | +for the exact regular expressions, merge handling, and output weights. Do not |
| 66 | +substitute the outputs of customized GitFlow Mainline examples for this preset. |
| 67 | + |
| 68 | +## Try representative histories |
| 69 | + |
| 70 | +The [worked examples](examples) show direct commits on main, feature and hotfix |
| 71 | +merges, release tags, and commit-message increments using this exact preset. |
| 72 | +Compare those histories with your repository, including your actual merge |
| 73 | +policy, before switching workflows. Squash and fast-forward merges produce |
| 74 | +different histories from the explicit merge commits in these examples. |
0 commit comments