forked from cake-contrib/Cake.Paket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.cake
88 lines (75 loc) · 3.33 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
#tool paket:?package=xunit.runner.console
#tool paket:?package=OpenCover
#tool paket:?package=Codecov
#tool paket:?package=GitVersion.CommandLine
#tool paket:?package=gitreleasemanager
#addin paket:?package=Cake.Figlet
#addin paket:?package=Cake.Paket
#addin paket:?package=Cake.Codecov
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
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(IsRunningOnWindows())
{
MSBuild(cakePaket, settings => settings.SetConfiguration(configuration));
}
else
{
XBuild(cakePaket, settings => settings.SetConfiguration(configuration));
}
});
Task("Run-Unit-Tests").IsDependentOn("Build").WithCriteria(IsRunningOnWindows()).Does(() =>
{
var cakePaketUnitTests = string.Format("./Source/Cake.Paket.UnitTests/bin/{0}/*.UnitTests.dll", configuration);
OpenCover(tool => tool.XUnit2(cakePaketUnitTests, new XUnit2Settings {ShadowCopy = false}), new FilePath("./coverage.xml"), new OpenCoverSettings().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;
}