Skip to content

Commit

Permalink
dogfood GitVersion to handle breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Dec 21, 2022
1 parent 3ec073d commit 9623cc4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 34 deletions.
4 changes: 2 additions & 2 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
assembly-versioning-scheme: MajorMinorPatch
branches:
main:
tag: beta
label: beta
support:
tag: beta
label: beta
1 change: 0 additions & 1 deletion build/build/Tasks/ValidateVersion.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Build.Utilities;
using Common.Utilities;

namespace Build.Tasks;
Expand Down
34 changes: 31 additions & 3 deletions build/common/Lifetime/BuildLifetimeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ public override void Setup(T context, ISetupContext info)
context.IsOnLinux = context.IsRunningOnLinux();
context.IsOnMacOS = context.IsRunningOnMacOs();

var gitVersion = context.GitVersion(new GitVersionSettings
BuildSolution(context);

var gitversionTool = context.GetGitVersionToolLocation();
var gitVersionSettings = new GitVersionSettings
{
OutputTypes = new HashSet<GitVersionOutput> { GitVersionOutput.Json, GitVersionOutput.BuildServer }
});
OutputTypes = new HashSet<GitVersionOutput> { GitVersionOutput.Json, GitVersionOutput.BuildServer },
ToolPath = context.Tools.Resolve(new[] { "dotnet.exe", "dotnet" }),
ArgumentCustomization = args => args.Prepend(gitversionTool!.FullPath)
};

var gitVersion = context.GitVersion(gitVersionSettings);

context.Version = BuildVersion.Calculate(gitVersion);
}
Expand Down Expand Up @@ -69,4 +76,25 @@ protected void LogBuildInformation(T context)
context.Information("Support Branch: {0}", context.IsSupportBranch);
context.Information("Tagged: {0}", context.IsTagged);
}
private static void BuildSolution(T context)
{
context.Information("Builds solution...");

const string sln = "./src/GitVersion.sln";

context.DotNetRestore(sln,
new()
{
Verbosity = DotNetVerbosity.Minimal,
Sources = new[] { "https://api.nuget.org/v3/index.json" },
});

context.DotNetBuild(sln,
new()
{
Verbosity = DotNetVerbosity.Minimal,
Configuration = Constants.DefaultConfiguration,
NoRestore = true,
});
}
}
50 changes: 22 additions & 28 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
{
"version": 1,
"isRoot": true,
"tools": {
"codecov.tool": {
"version": "1.13.0",
"commands": [
"codecov"
]
},
"gitversion.tool": {
"version": "5.11.1",
"commands": [
"dotnet-gitversion"
]
},
"gitreleasemanager.tool": {
"version": "0.13.0",
"commands": [
"dotnet-gitreleasemanager"
]
},
"Wyam2": {
"version": "3.0.0",
"commands": [
"wyam2"
]
}
"version": 1,
"isRoot": true,
"tools": {
"codecov.tool": {
"version": "1.13.0",
"commands": [
"codecov"
]
},
"gitreleasemanager.tool": {
"version": "0.13.0",
"commands": [
"dotnet-gitreleasemanager"
]
},
"wyam2": {
"version": "3.0.0",
"commands": [
"wyam2"
]
}
}
}
}

0 comments on commit 9623cc4

Please sign in to comment.