diff --git a/docs/input/docs/workflows/GitFlow/v1.yml b/docs/input/docs/workflows/GitFlow/v1.yml index 897bb5e169..f839b27b94 100644 --- a/docs/input/docs/workflows/GitFlow/v1.yml +++ b/docs/input/docs/workflows/GitFlow/v1.yml @@ -1,4 +1,4 @@ -assembly-versioning-scheme: MajorMinorPatch +assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch tag-prefix: '[vV]?' version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* diff --git a/docs/input/docs/workflows/GitHubFlow/v1.yml b/docs/input/docs/workflows/GitHubFlow/v1.yml index 4b3a4c9591..822fe7991f 100644 --- a/docs/input/docs/workflows/GitHubFlow/v1.yml +++ b/docs/input/docs/workflows/GitHubFlow/v1.yml @@ -1,4 +1,4 @@ -assembly-versioning-scheme: MajorMinorPatch +assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch tag-prefix: '[vV]?' version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* @@ -57,12 +57,12 @@ branches: increment: Inherit prevent-increment: when-current-commit-tagged: false + track-merge-message: true regex: ^features?[/-](?.+) source-branches: - main - release is-source-branch-for: [] - track-merge-message: true is-main-branch: false pre-release-weight: 30000 pull-request: @@ -73,13 +73,13 @@ branches: of-merged-branch: true when-current-commit-tagged: false label-number-pattern: '[/-](?\d+)' + track-merge-message: true regex: ^(pull|pull\-requests|pr)[/-] source-branches: - main - release - feature is-source-branch-for: [] - track-merge-message: true pre-release-weight: 30000 unknown: mode: ManualDeployment @@ -87,6 +87,7 @@ branches: increment: Inherit prevent-increment: when-current-commit-tagged: false + track-merge-message: false regex: (?.+) source-branches: - main @@ -94,7 +95,6 @@ branches: - feature - pull-request is-source-branch-for: [] - track-merge-message: false is-main-branch: false ignore: sha: [] diff --git a/docs/input/docs/workflows/TrunkBased/preview1.yml b/docs/input/docs/workflows/TrunkBased/preview1.yml index cc9b59a1dd..07012e4dd6 100644 --- a/docs/input/docs/workflows/TrunkBased/preview1.yml +++ b/docs/input/docs/workflows/TrunkBased/preview1.yml @@ -1,4 +1,4 @@ -assembly-versioning-scheme: MajorMinorPatch +assembly-versioning-scheme: MajorMinorPatch assembly-file-versioning-scheme: MajorMinorPatch tag-prefix: '[vV]?' version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* @@ -12,8 +12,8 @@ merge-message-formats: {} update-build-number: true semantic-version-format: Strict strategies: -- Mainline - ConfiguredNextVersion +- Mainline branches: main: mode: ContinuousDeployment @@ -21,46 +21,65 @@ branches: increment: Patch prevent-increment: of-merged-branch: true - when-current-commit-tagged: true track-merge-target: false + track-merge-message: true regex: ^master$|^main$ source-branches: [] + is-source-branch-for: [] tracks-release-branches: false is-release-branch: false is-main-branch: true pre-release-weight: 55000 feature: + mode: ContinuousDelivery + label: '{BranchName}' increment: Minor - regex: ^features?[/-](?.+) prevent-increment: when-current-commit-tagged: false + track-merge-message: true + regex: ^features?[/-](?.+) source-branches: - main + is-source-branch-for: [] + is-main-branch: false pre-release-weight: 30000 hotfix: + mode: ContinuousDelivery + label: '{BranchName}' increment: Patch - regex: ^hotfix(es)?[/-](?.+) prevent-increment: when-current-commit-tagged: false + regex: ^hotfix(es)?[/-](?.+) source-branches: - main + is-source-branch-for: [] + is-release-branch: true + is-main-branch: false pre-release-weight: 30000 pull-request: mode: ContinuousDelivery label: PullRequest increment: Inherit + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false label-number-pattern: '[/-](?\d+)' + track-merge-message: true regex: ^(pull|pull\-requests|pr)[/-] source-branches: - main + - feature + - hotfix + is-source-branch-for: [] pre-release-weight: 30000 unknown: increment: Patch - regex: (?.+) prevent-increment: when-current-commit-tagged: false + regex: (?.+) source-branches: - main + is-source-branch-for: [] pre-release-weight: 30000 ignore: sha: [] @@ -75,6 +94,8 @@ track-merge-target: false track-merge-message: true commit-message-incrementing: Enabled regex: '' +source-branches: [] +is-source-branch-for: [] tracks-release-branches: false is-release-branch: false is-main-branch: false diff --git a/src/GitVersion.Configuration.Tests/GitVersion.Configuration.Tests.csproj b/src/GitVersion.Configuration.Tests/GitVersion.Configuration.Tests.csproj index 2b5ddb0b6c..fdfd126300 100644 --- a/src/GitVersion.Configuration.Tests/GitVersion.Configuration.Tests.csproj +++ b/src/GitVersion.Configuration.Tests/GitVersion.Configuration.Tests.csproj @@ -3,4 +3,17 @@ + + + + + + + + + + diff --git a/src/GitVersion.Configuration.Tests/Workflows/WorkflowsTests.cs b/src/GitVersion.Configuration.Tests/Workflows/WorkflowsTests.cs new file mode 100644 index 0000000000..801d5239c4 --- /dev/null +++ b/src/GitVersion.Configuration.Tests/Workflows/WorkflowsTests.cs @@ -0,0 +1,36 @@ +namespace GitVersion.Configuration.Tests.Configuration; + +[TestFixture] +public class WorkflowsTests +{ + private readonly ConfigurationSerializer serializer = new(); + + private static readonly object[][] Workflows = + [ + ["GitFlow/v1", GitFlowConfigurationBuilder.New], + ["GitHubFlow/v1", GitHubFlowConfigurationBuilder.New], + ["TrunkBased/preview1", TrunkBasedConfigurationBuilder.New] + ]; + + [Test(Description = "This test is to ensure that the configuration for workflow is up to date")] + [TestCaseSource(nameof(Workflows))] + public void CheckWorkflowsAreUpdated(string workflow, IConfigurationBuilder configurationBuilder) + { + var configuration = configurationBuilder.Build(); + + var serializedConfiguration = serializer.Serialize(configuration); + var segments = workflow.Split("/"); + var folderName = segments[0]; + var fileName = segments[^1]; + + serializedConfiguration.ShouldMatchApproved(builder => builder + .WithFilenameGenerator((_, _, type, extension) => FilenameGenerator(fileName, type, extension)) + .WithFileExtension("yml") + .SubFolder($"approved/{folderName}")); + } + + private static string FilenameGenerator(string fileName, string type, string ext) => + type == "approved" + ? $"{fileName}.{ext}" + : $"{fileName}.{type}.{ext}"; +} diff --git a/src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml b/src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml new file mode 100644 index 0000000000..f839b27b94 --- /dev/null +++ b/src/GitVersion.Configuration.Tests/Workflows/approved/GitFlow/v1.yml @@ -0,0 +1,167 @@ +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +tag-prefix: '[vV]?' +version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* +major-version-bump-message: '\+semver:\s?(breaking|major)' +minor-version-bump-message: '\+semver:\s?(feature|minor)' +patch-version-bump-message: '\+semver:\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +tag-pre-release-weight: 60000 +commit-date-format: yyyy-MM-dd +merge-message-formats: {} +update-build-number: true +semantic-version-format: Strict +strategies: +- Fallback +- ConfiguredNextVersion +- MergeMessage +- TaggedCommit +- TrackReleaseBranches +- VersionInBranchName +branches: + develop: + mode: ContinuousDelivery + label: alpha + increment: Minor + prevent-increment: + when-current-commit-tagged: false + track-merge-target: true + track-merge-message: true + regex: ^dev(elop)?(ment)?$ + source-branches: + - main + is-source-branch-for: [] + tracks-release-branches: true + is-release-branch: false + is-main-branch: false + pre-release-weight: 0 + main: + label: '' + increment: Patch + prevent-increment: + of-merged-branch: true + track-merge-target: false + track-merge-message: true + regex: ^master$|^main$ + source-branches: [] + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: false + is-main-branch: true + pre-release-weight: 55000 + release: + mode: ManualDeployment + label: beta + increment: Minor + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false + track-merge-target: false + regex: ^releases?[/-](?.+) + source-branches: + - main + - support + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: true + is-main-branch: false + pre-release-weight: 30000 + feature: + mode: ManualDeployment + label: '{BranchName}' + increment: Inherit + prevent-increment: + when-current-commit-tagged: false + track-merge-message: true + regex: ^features?[/-](?.+) + source-branches: + - develop + - main + - release + - support + - hotfix + is-source-branch-for: [] + is-main-branch: false + pre-release-weight: 30000 + pull-request: + mode: ContinuousDelivery + label: PullRequest + increment: Inherit + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false + label-number-pattern: '[/-](?\d+)' + track-merge-message: true + regex: ^(pull|pull\-requests|pr)[/-] + source-branches: + - develop + - main + - release + - feature + - support + - hotfix + is-source-branch-for: [] + pre-release-weight: 30000 + hotfix: + mode: ManualDeployment + label: beta + increment: Inherit + prevent-increment: + when-current-commit-tagged: false + regex: ^hotfix(es)?[/-](?.+) + source-branches: + - main + - support + is-source-branch-for: [] + is-release-branch: true + is-main-branch: false + pre-release-weight: 30000 + support: + label: '' + increment: Patch + prevent-increment: + of-merged-branch: true + track-merge-target: false + regex: ^support[/-](?.+) + source-branches: + - main + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: false + is-main-branch: true + pre-release-weight: 55000 + unknown: + mode: ManualDeployment + label: '{BranchName}' + increment: Inherit + prevent-increment: + when-current-commit-tagged: true + regex: (?.+) + source-branches: + - main + - develop + - release + - feature + - pull-request + - hotfix + - support + is-source-branch-for: [] + is-main-branch: false +ignore: + sha: [] +mode: ContinuousDelivery +label: '{BranchName}' +increment: Inherit +prevent-increment: + of-merged-branch: false + when-branch-merged: false + when-current-commit-tagged: true +track-merge-target: false +track-merge-message: true +commit-message-incrementing: Enabled +regex: '' +source-branches: [] +is-source-branch-for: [] +tracks-release-branches: false +is-release-branch: false +is-main-branch: false diff --git a/src/GitVersion.Configuration.Tests/Workflows/approved/GitHubFlow/v1.yml b/src/GitVersion.Configuration.Tests/Workflows/approved/GitHubFlow/v1.yml new file mode 100644 index 0000000000..822fe7991f --- /dev/null +++ b/src/GitVersion.Configuration.Tests/Workflows/approved/GitHubFlow/v1.yml @@ -0,0 +1,116 @@ +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +tag-prefix: '[vV]?' +version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* +major-version-bump-message: '\+semver:\s?(breaking|major)' +minor-version-bump-message: '\+semver:\s?(feature|minor)' +patch-version-bump-message: '\+semver:\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +tag-pre-release-weight: 60000 +commit-date-format: yyyy-MM-dd +merge-message-formats: {} +update-build-number: true +semantic-version-format: Strict +strategies: +- Fallback +- ConfiguredNextVersion +- MergeMessage +- TaggedCommit +- TrackReleaseBranches +- VersionInBranchName +branches: + main: + label: '' + increment: Patch + prevent-increment: + of-merged-branch: true + track-merge-target: false + track-merge-message: true + regex: ^master$|^main$ + source-branches: [] + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: false + is-main-branch: true + pre-release-weight: 55000 + release: + mode: ManualDeployment + label: beta + increment: Patch + prevent-increment: + of-merged-branch: true + when-branch-merged: false + when-current-commit-tagged: false + track-merge-target: false + track-merge-message: true + regex: ^releases?[/-](?.+) + source-branches: + - main + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: true + is-main-branch: false + pre-release-weight: 30000 + feature: + mode: ManualDeployment + label: '{BranchName}' + increment: Inherit + prevent-increment: + when-current-commit-tagged: false + track-merge-message: true + regex: ^features?[/-](?.+) + source-branches: + - main + - release + is-source-branch-for: [] + is-main-branch: false + pre-release-weight: 30000 + pull-request: + mode: ContinuousDelivery + label: PullRequest + increment: Inherit + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false + label-number-pattern: '[/-](?\d+)' + track-merge-message: true + regex: ^(pull|pull\-requests|pr)[/-] + source-branches: + - main + - release + - feature + is-source-branch-for: [] + pre-release-weight: 30000 + unknown: + mode: ManualDeployment + label: '{BranchName}' + increment: Inherit + prevent-increment: + when-current-commit-tagged: false + track-merge-message: false + regex: (?.+) + source-branches: + - main + - release + - feature + - pull-request + is-source-branch-for: [] + is-main-branch: false +ignore: + sha: [] +mode: ContinuousDelivery +label: '{BranchName}' +increment: Inherit +prevent-increment: + of-merged-branch: false + when-branch-merged: false + when-current-commit-tagged: true +track-merge-target: false +track-merge-message: true +commit-message-incrementing: Enabled +regex: '' +source-branches: [] +is-source-branch-for: [] +tracks-release-branches: false +is-release-branch: false +is-main-branch: false diff --git a/src/GitVersion.Configuration.Tests/Workflows/approved/TrunkBased/preview1.yml b/src/GitVersion.Configuration.Tests/Workflows/approved/TrunkBased/preview1.yml new file mode 100644 index 0000000000..07012e4dd6 --- /dev/null +++ b/src/GitVersion.Configuration.Tests/Workflows/approved/TrunkBased/preview1.yml @@ -0,0 +1,101 @@ +assembly-versioning-scheme: MajorMinorPatch +assembly-file-versioning-scheme: MajorMinorPatch +tag-prefix: '[vV]?' +version-in-branch-pattern: (?[vV]?\d+(\.\d+)?(\.\d+)?).* +major-version-bump-message: '\+semver:\s?(breaking|major)' +minor-version-bump-message: '\+semver:\s?(feature|minor)' +patch-version-bump-message: '\+semver:\s?(fix|patch)' +no-bump-message: '\+semver:\s?(none|skip)' +tag-pre-release-weight: 60000 +commit-date-format: yyyy-MM-dd +merge-message-formats: {} +update-build-number: true +semantic-version-format: Strict +strategies: +- ConfiguredNextVersion +- Mainline +branches: + main: + mode: ContinuousDeployment + label: '' + increment: Patch + prevent-increment: + of-merged-branch: true + track-merge-target: false + track-merge-message: true + regex: ^master$|^main$ + source-branches: [] + is-source-branch-for: [] + tracks-release-branches: false + is-release-branch: false + is-main-branch: true + pre-release-weight: 55000 + feature: + mode: ContinuousDelivery + label: '{BranchName}' + increment: Minor + prevent-increment: + when-current-commit-tagged: false + track-merge-message: true + regex: ^features?[/-](?.+) + source-branches: + - main + is-source-branch-for: [] + is-main-branch: false + pre-release-weight: 30000 + hotfix: + mode: ContinuousDelivery + label: '{BranchName}' + increment: Patch + prevent-increment: + when-current-commit-tagged: false + regex: ^hotfix(es)?[/-](?.+) + source-branches: + - main + is-source-branch-for: [] + is-release-branch: true + is-main-branch: false + pre-release-weight: 30000 + pull-request: + mode: ContinuousDelivery + label: PullRequest + increment: Inherit + prevent-increment: + of-merged-branch: true + when-current-commit-tagged: false + label-number-pattern: '[/-](?\d+)' + track-merge-message: true + regex: ^(pull|pull\-requests|pr)[/-] + source-branches: + - main + - feature + - hotfix + is-source-branch-for: [] + pre-release-weight: 30000 + unknown: + increment: Patch + prevent-increment: + when-current-commit-tagged: false + regex: (?.+) + source-branches: + - main + is-source-branch-for: [] + pre-release-weight: 30000 +ignore: + sha: [] +mode: ContinuousDelivery +label: '{BranchName}' +increment: Inherit +prevent-increment: + of-merged-branch: false + when-branch-merged: false + when-current-commit-tagged: true +track-merge-target: false +track-merge-message: true +commit-message-incrementing: Enabled +regex: '' +source-branches: [] +is-source-branch-for: [] +tracks-release-branches: false +is-release-branch: false +is-main-branch: false diff --git a/src/GitVersion.Configuration/GitVersion.Configuration.csproj b/src/GitVersion.Configuration/GitVersion.Configuration.csproj index cf3b09fcfe..75a9ad34e1 100644 --- a/src/GitVersion.Configuration/GitVersion.Configuration.csproj +++ b/src/GitVersion.Configuration/GitVersion.Configuration.csproj @@ -30,20 +30,7 @@ - - - - - - - - - - - - - - - + + diff --git a/src/GitVersion.Core/Configuration/IConfigurationBuilder.cs b/src/GitVersion.Core/Configuration/IConfigurationBuilder.cs index 1eabfff749..e6827f7a0a 100644 --- a/src/GitVersion.Core/Configuration/IConfigurationBuilder.cs +++ b/src/GitVersion.Core/Configuration/IConfigurationBuilder.cs @@ -1,6 +1,6 @@ namespace GitVersion.Configuration; -internal interface IConfigurationBuilder +public interface IConfigurationBuilder { void AddOverride(IReadOnlyDictionary value); diff --git a/src/GitVersion.Core/PublicAPI.Shipped.txt b/src/GitVersion.Core/PublicAPI.Shipped.txt index 55ad0b8489..78e07b591c 100644 --- a/src/GitVersion.Core/PublicAPI.Shipped.txt +++ b/src/GitVersion.Core/PublicAPI.Shipped.txt @@ -107,6 +107,9 @@ GitVersion.Configuration.IBranchConfiguration.SourceBranches.get -> System.Colle GitVersion.Configuration.IBranchConfiguration.TrackMergeMessage.get -> bool? GitVersion.Configuration.IBranchConfiguration.TrackMergeTarget.get -> bool? GitVersion.Configuration.IBranchConfiguration.TracksReleaseBranches.get -> bool? +GitVersion.Configuration.IConfigurationBuilder +GitVersion.Configuration.IConfigurationBuilder.AddOverride(System.Collections.Generic.IReadOnlyDictionary! value) -> void +GitVersion.Configuration.IConfigurationBuilder.Build() -> GitVersion.Configuration.IGitVersionConfiguration! GitVersion.Configuration.IConfigurationFileLocator GitVersion.Configuration.IConfigurationFileLocator.GetConfigurationFile(string? directory) -> string? GitVersion.Configuration.IConfigurationFileLocator.Verify(string? workingDirectory, string? projectRootDirectory) -> void