-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.cake
112 lines (98 loc) · 3.87 KB
/
setup.cake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#tool paket:?package=xunit.runner.console&version=2.4.1
#tool paket:?package=OpenCover&version=4.7.922
#tool paket:?package=Codecov&version=1.7.1
#tool paket:?package=GitVersion.CommandLine&version=5.0
#tool paket:?package=GitReleaseManager&version=0.8
#addin paket:?package=Cake.Figlet&version=1.3
#addin paket:?package=Cake.Paket&version=4.0
#addin paket:?package=Cake.Codecov&version=0.6
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var msbuild = Argument("msbuild", false);
Task("Clean").Does(() =>
{
Information(Figlet("Cake.Paket"));
if(FileExists("./coverage.xml"))
{
DeleteFile("./coverage.xml");
}
var cakePaketAddin = string.Format("./Source/Cake.Paket.Addin/bin/{0}", configuration);
var cakePaketModule = string.Format("./Source/Cake.Paket.Module/bin/{0}", configuration);
CleanDirectories(new[] {"./nuspec", cakePaketAddin, cakePaketModule});
});
Task("Build").IsDependentOn("Clean").Does(() =>
{
PaketRestore();
var cakePaket = "./Source/Cake.Paket.sln";
if (msbuild)
{
var settings = new DotNetCoreMSBuildSettings
{
NoLogo = true,
MaxCpuCount = -1,
ArgumentCustomization = args => args.Append("/restore")
}
.SetConfiguration(configuration);
DotNetCoreMSBuild(cakePaket, settings);
}
else
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration
};
DotNetCoreBuild(cakePaket, settings);
}
});
Task("Run-Unit-Tests").IsDependentOn("Build").WithCriteria(IsRunningOnWindows()).Does(() =>
{
OpenCover(
tool => tool.DotNetCoreTest(
"./Source/Cake.Paket.UnitTests/Cake.Paket.UnitTests.csproj",
new DotNetCoreTestSettings() { Configuration = "Debug" }),
new FilePath("./coverage.xml"),
new OpenCoverSettings()
{
OldStyle = true,
ReturnTargetCodeOffset = 0
}
.WithFilter("+[Cake.Paket.Addin]*")
.WithFilter("+[Cake.Paket.Module]*")
.WithFilter("-[Cake.Paket.UnitTests]*"));
});
Task("Publish-Coverage-Report").IsDependentOn("Run-Unit-Tests").WithCriteria(AppVeyor.IsRunningOnAppVeyor).Does(() =>
{
Codecov("./coverage.xml");
});
Task("Update-SolutionInfo").Does(() =>
{
var solutionInfo = "./Source/SolutionInfo.cs";
GitVersion(new GitVersionSettings { UpdateAssemblyInfo = true, UpdateAssemblyInfoFilePath = solutionInfo});
});
Task("Run-GitReleaseManager").WithCriteria(ShouldRunRelease()).Does(() =>
{
var version = GitVersion();
var githubUsername = EnvironmentVariable("GITHUB_USERNAME");
var githubPassword = EnvironmentVariable("GITHUB_PASSWORD");
GitReleaseManagerCreate(githubUsername, githubPassword, githubUsername, "Cake.Paket", new GitReleaseManagerCreateSettings {Milestone = version.MajorMinorPatch});
GitReleaseManagerClose(githubUsername, githubPassword, githubUsername, "Cake.Paket", version.MajorMinorPatch);
GitReleaseManagerPublish(githubUsername, githubPassword, githubUsername, "Cake.Paket", version.MajorMinorPatch);
});
Task("Paket-Pack").WithCriteria(ShouldRunRelease()).Does(() =>
{
var version = GitVersion();
EnsureDirectoryExists("./nuspec");
PaketPack("./nuspec", new PaketPackSettings { Version = version.MajorMinorPatch });
});
Task("Paket-Push").WithCriteria(ShouldRunRelease()).Does(() =>
{
var apiKey = EnvironmentVariable("NUGET_API_KEY");
PaketPush(GetFiles("./nuspec/*.nupkg"), new PaketPushSettings { Url = "https://www.nuget.org/api/v2/package", ApiKey = apiKey });
});
Task("Default").IsDependentOn("Publish-Coverage-Report").IsDependentOn("Run-GitReleaseManager").IsDependentOn("Paket-Pack").IsDependentOn("Paket-Push");
Task("Pre-Release").IsDependentOn("Update-SolutionInfo");
RunTarget(target);
private bool ShouldRunRelease()
{
return AppVeyor.IsRunningOnAppVeyor && AppVeyor.Environment.Repository.Tag.IsTag;
}