-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.cake
107 lines (94 loc) · 2.96 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
97
98
99
100
101
102
103
104
105
106
107
#addin "nuget:?package=Cake.MinVer&version=1.0.1"
#addin "nuget:?package=Cake.Args&version=1.0.1"
var target = ArgumentOrDefault<string>("target") ?? "pack";
var buildVersion = MinVer(s => s.WithTagPrefix("v").WithDefaultPreReleasePhase("preview"));
Task("clean")
.Does(() =>
{
CleanDirectories("./artifacts/**");
CleanDirectories("./**/^{bin,obj}");
});
Task("restore")
.IsDependentOn("clean")
.Does(() =>
{
DotNetCoreRestore("./Cake.AWS.ElasticBeanstalk.sln", new DotNetCoreRestoreSettings
{
LockedMode = true,
});
});
Task("build")
.IsDependentOn("restore")
.DoesForEach(new[] { "Debug", "Release" }, (configuration) =>
{
DotNetCoreBuild("./Cake.AWS.ElasticBeanstalk.sln", new DotNetCoreBuildSettings
{
Configuration = configuration,
NoRestore = true,
NoIncremental = false,
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:AssemblyVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:FileVersion={buildVersion.FileVersion}")
.AppendQuoted($"-p:ContinuousIntegrationBuild=true")
});
});
Task("test")
.IsDependentOn("build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
};
var projectFiles = GetFiles("./test/**/*.csproj");
foreach (var file in projectFiles)
{
DotNetCoreTest(file.FullPath, settings);
}
});
Task("pack")
.IsDependentOn("test")
.Does(() =>
{
var releaseNotes = $"https://github.com/cake-contrib/Cake.AWS.ElasticBeanstalk/releases/tag/v{buildVersion.Version}";
DotNetCorePack("./src/Cake.AWS.ElasticBeanstalk/Cake.AWS.ElasticBeanstalk.csproj", new DotNetCorePackSettings
{
Configuration = "Release",
NoRestore = true,
NoBuild = true,
OutputDirectory = "./artifacts/nuget",
ArgumentCustomization = args =>
args.AppendQuoted($"-p:Version={buildVersion.Version}")
.AppendQuoted($"-p:PackageReleaseNotes={releaseNotes}")
});
});
Task("publish")
.IsDependentOn("pack")
.Does(context =>
{
var url = context.EnvironmentVariable("NUGET_URL");
if (string.IsNullOrWhiteSpace(url))
{
context.Information("No NuGet URL specified. Skipping publishing of NuGet packages");
return;
}
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey))
{
context.Information("No NuGet API key specified. Skipping publishing of NuGet packages");
return;
}
var nugetPushSettings = new DotNetCoreNuGetPushSettings
{
Source = url,
ApiKey = apiKey,
};
foreach (var nugetPackageFile in GetFiles("./artifacts/nuget/*.nupkg"))
{
DotNetCoreNuGetPush(nugetPackageFile.FullPath, nugetPushSettings);
}
});
RunTarget(target);