-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbuild.cake
96 lines (85 loc) · 2.69 KB
/
build.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
#tool "dotnet:?package=GitVersion.Tool"
GitVersion versionInfo = null;
var target = Argument("target", "Default");
var outputDir = "./artifacts/";
var configuration = Argument("configuration", "Release");
var nugetFeedUrl = "https://api.nuget.org/v3/index.json";
var nugetApiKey = EnvironmentVariable("Nuget_ApiKey");
var isTaggedBuild = Convert.ToBoolean(EnvironmentVariable("APPVEYOR_REPO_TAG"));
Task("Clean")
.Does(() => {
if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, new DeleteDirectorySettings { Recursive = true });
}
CreateDirectory(outputDir);
});
Task("Version")
.IsDependentOn("Clean")
.Does(() => {
GitVersion(new GitVersionSettings
{
UpdateAssemblyInfo = true,
OutputType = GitVersionOutput.BuildServer,
NoFetch = true,
});
versionInfo = GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json,
NoFetch = true
});
});
Task("Build")
.IsDependentOn("Version")
.Does(() => {
DotNetBuild(".", new DotNetBuildSettings
{
Configuration = configuration,
ArgumentCustomization = args => args.Append("/p:SemVer=" + versionInfo.NuGetVersion)
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
var testProjects = GetFiles("./test/**/*.csproj");
foreach(var proj in testProjects)
{
DotNetTest(proj.FullPath, new DotNetTestSettings
{
Configuration = configuration,
NoBuild = true,
});
}
});
Task("Package")
.IsDependentOn("Test")
.Does(() => {
var settings = new DotNetPackSettings
{
OutputDirectory = outputDir,
NoBuild = true,
Configuration = configuration,
ArgumentCustomization = args => args.Append("/p:SemVer=" + versionInfo.NuGetVersion)
};
DotNetPack("src/TwentyTwenty.Storage/", settings);
DotNetPack("src/TwentyTwenty.Storage.Amazon/", settings);
DotNetPack("src/TwentyTwenty.Storage.Azure/", settings);
DotNetPack("src/TwentyTwenty.Storage.Google/", settings);
DotNetPack("src/TwentyTwenty.Storage.Local/", settings);
});
Task("Publish")
.IsDependentOn("Package")
.Does(() => {
if (isTaggedBuild)
{
var settings = new DotNetNuGetPushSettings
{
Source = nugetFeedUrl,
ApiKey = nugetApiKey,
};
DotNetNuGetPush(outputDir + "*.nupkg", settings);
}
});
Task("Default")
.IsDependentOn("Publish");
RunTarget(target);