-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
110 lines (89 loc) · 2.51 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
108
109
110
#nullable enable
// Arguments
var target = Argument("t", "default");
// Environment
var nugetToken = EnvironmentVariable("NUGET_TOKEN");
// Paths
var root = Context.Environment.WorkingDirectory;
var zigToolsetsProj = root.CombineWithFilePath("zig-toolsets.proj");
var @out = root.Combine("out");
var outLog = @out.Combine("log");
// Globs
var nugetGlob = new GlobPattern(@out.Combine("pkg").Combine("release").CombineWithFilePath("*.nupkg").FullPath);
// Utilities
DotNetMSBuildSettings ConfigureMSBuild(string target)
{
var prefix = $"{target}_{Environment.UserName}_{Environment.MachineName}_";
var time = DateTime.Now;
string name;
do
{
name = $"{prefix}{time:yyyy-MM-dd_HH_mm_ss}.binlog";
time = time.AddSeconds(1);
}
while (System.IO.File.Exists(name));
return new()
{
// TODO: https://github.com/dotnet/msbuild/issues/6756
NoLogo = true,
BinaryLogger = new()
{
Enabled = true,
FileName = outLog.CombineWithFilePath(name).FullPath,
},
ConsoleLoggerSettings = new()
{
NoSummary = true,
},
ArgumentCustomization = args => args.Append("-ds:false"),
};
}
// Tasks
Task("default")
.IsDependentOn("pack");
Task("default-editor")
.IsDependentOn("pack");
Task("restore")
.Does(() =>
DotNetRestore(
zigToolsetsProj.FullPath,
new()
{
MSBuildSettings = ConfigureMSBuild("restore"),
}));
Task("build")
.IsDependentOn("restore")
.Does(() =>
DotNetBuild(
zigToolsetsProj.FullPath,
new()
{
MSBuildSettings = ConfigureMSBuild("build"),
NoRestore = true,
}));
Task("pack")
.IsDependentOn("build")
.Does(() =>
DotNetPack(
zigToolsetsProj.FullPath,
new()
{
MSBuildSettings = ConfigureMSBuild("pack"),
NoBuild = true,
}));
Task("upload")
.WithCriteria(BuildSystem.GitHubActions.Environment.Workflow.Ref.StartsWith("refs/tags/v"))
.IsDependentOn("pack")
.Does(() =>
{
foreach (var pkg in GetFiles(nugetGlob))
DotNetNuGetPush(
pkg,
new()
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = nugetToken,
SkipDuplicate = true,
});
});
RunTarget(target);