Repository navigation
Expand file tree
/
Copy pathVelopack.cake
More file actions
111 lines (96 loc) · 3.68 KB
/
Copy pathVelopack.cake
File metadata and controls
111 lines (96 loc) · 3.68 KB
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
public static class Velopack
{
// the #tool-pinned vpk (build.cake), not whatever global vpk is on PATH
private static FilePath VpkPath(ICakeContext context) =>
context.Tools.Resolve("vpk.exe") ?? context.Tools.Resolve("vpk") ?? new FilePath("vpk");
// StartProcess only returns the exit code, so a failure would otherwise pass unnoticed
private static void Run(ICakeContext context, string command, ProcessArgumentBuilder arguments)
{
var exitCode = context.StartProcess(VpkPath(context), new ProcessSettings
{
Arguments = arguments
});
if (exitCode != 0)
{
throw new CakeException($"vpk {command} failed with exit code {exitCode}");
}
}
public static void Pack(ICakeContext context, VpkPackParams @params)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var arguments = new ProcessArgumentBuilder()
.Append("pack")
.Append("-u").Append(@params.Id)
.Append("--packTitle").AppendQuoted(@params.Title)
.Append("--icon").AppendQuoted(@params.Icon)
.Append("--releaseNotes").Append(@params.ReleaseNotes)
.Append("--channel").Append(@params.Channel)
.Append("-v").AppendQuoted(@params.Version)
.Append("-p").AppendQuoted(@params.PublishDirectory)
.Append("-o").AppendQuoted(@params.ReleaseDirectory)
.Append("-e").AppendQuoted(@params.ExeName);
if (!string.IsNullOrEmpty(@params.Framework))
{
arguments.Append("--framework").AppendQuoted(@params.Framework);
}
if (!string.IsNullOrEmpty(@params.SplashImage))
{
arguments.Append("--splashImage").AppendQuoted(@params.SplashImage);
}
if (!string.IsNullOrEmpty(@params.Aumid))
{
arguments.Append("--aumid").AppendQuoted(@params.Aumid);
}
//Information("Running Vpk Pack with arguments: " + arguments.Render());
Run(context, "pack", arguments);
}
public static void UploadGithub(ICakeContext context, VpkUploadParams @params)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
var arguments = new ProcessArgumentBuilder()
.Append("upload").Append("github")
.Append("--outputDir").AppendQuoted(@params.ReleaseDirectory)
.Append("--channel").AppendQuoted(@params.Channel)
.Append("--repoUrl").AppendQuoted(@params.Repository)
.Append("--token").AppendQuoted(@params.Token);
if (@params.IsPrelease)
{
arguments.Append("--pre");
}
if (@params.Merge)
{
arguments.Append("--merge");
}
Run(context, "upload", arguments);
}
}
public class VpkUploadParams
{
public string? ReleaseDirectory { get; set; }
public string? Channel { get; set; }
public string? Token { get; set; }
public string? Repository { get; set; }
public bool IsPrelease { get; set; } = false;
public bool Merge { get; set; } = true;
}
public class VpkPackParams
{
public string? Id { get; set; }
public string? Title { get; set; }
public string? Icon { get; set; }
public string? ReleaseNotes { get; set; }
public string? Channel { get; set; }
public string? Version { get; set; }
public string? PublishDirectory { get; set; }
public string? ReleaseDirectory { get; set; }
public string? ExeName { get; set; }
public string? Framework { get; set; }
public string? SplashImage { get; set; }
public string? Aumid { get; set; }
}