-
Notifications
You must be signed in to change notification settings - Fork 22
/
DeployTarget.cs
34 lines (29 loc) · 1.16 KB
/
DeployTarget.cs
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
// ReSharper disable ClassNeverInstantiated.Global
namespace Build;
internal class DeployTarget(
Settings settings,
Commands commands,
[Tag(typeof(PackTarget))] ITarget<IReadOnlyCollection<Package>> packTarget)
: IInitializable, ITarget<int>
{
public Task InitializeAsync(CancellationToken cancellationToken) => commands.RegisterAsync(
this, "Deploys packages", "deploy", "dp");
public async Task<int> RunAsync(CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(settings.NuGetKey))
{
Warning("The NuGet key was not specified, the packages will not be pushed.");
return 0;
}
var packages = await packTarget.RunAsync(cancellationToken);
foreach (var package in packages.Where(i => i.Deploy))
{
await new DotNetNuGetPush()
.WithSource("https://api.nuget.org/v3/index.json")
.WithPackage(package.Path).WithApiKey(settings.NuGetKey)
.WithShortName($"pushing the package {package.Path}")
.BuildAsync(cancellationToken: cancellationToken).EnsureSuccess();
}
return 0;
}
}