-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecords.cs
More file actions
76 lines (65 loc) · 3.85 KB
/
records.cs
File metadata and controls
76 lines (65 loc) · 3.85 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
using System.Text.Json.Serialization;
/*****************************
* Records
*****************************/
public record BuildData(
string Version,
bool IsMainBranch,
bool ShouldNotPublish,
bool IsLocalBuild,
DirectoryPath ProjectRoot,
FilePath ProjectPath,
DotNetMSBuildSettings MSBuildSettings,
DirectoryPath ArtifactsPath,
DirectoryPath OutputPath
)
{
private const string IntegrationTest = "integrationtest",
Output = "output";
public DirectoryPath NuGetOutputPath { get; } = OutputPath.Combine("nuget");
public DirectoryPath BinaryOutputPath { get; } = OutputPath.Combine("bin");
public DirectoryPath IntegrationTestPath { get; } = OutputPath.Combine(IntegrationTest);
public string? GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string? GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GITHUB_TOKEN");
public bool ShouldPushGitHubPackages() => !ShouldNotPublish
&& !string.IsNullOrWhiteSpace(GitHubNuGetSource)
&& !string.IsNullOrWhiteSpace(GitHubNuGetApiKey);
public string? NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
public string? NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
public bool ShouldPushNuGetPackages() => IsMainBranch &&
!ShouldNotPublish &&
!string.IsNullOrWhiteSpace(NuGetSource) &&
!string.IsNullOrWhiteSpace(NuGetApiKey);
public ICollection<DirectoryPath> DirectoryPathsToClean = new []{
ArtifactsPath,
OutputPath,
OutputPath.Combine(IntegrationTest)
};
public AzureCredentials AzureCredentials { get; } = new AzureCredentials(
System.Environment.GetEnvironmentVariable("AZURE_TENANT_ID"),
System.Environment.GetEnvironmentVariable("AZURE_CLIENT_ID"),
System.Environment.GetEnvironmentVariable("AZURE_CLIENT_SECRET"),
System.Environment.GetEnvironmentVariable("AZURE_AUTHORITY_HOST")
);
public string? AzureStorageAccount { get; } = System.Environment.GetEnvironmentVariable("AZURE_STORAGE_ACCOUNT");
public string? AzureStorageAccountContainer { get; } = System.Environment.GetEnvironmentVariable("AZURE_STORAGE_ACCOUNT_CONTAINER");
public bool ShouldRunIntegrationTests() => !string.IsNullOrWhiteSpace(AzureStorageAccount) &&
!string.IsNullOrWhiteSpace(AzureStorageAccountContainer) &&
(
AzureCredentials.AzureCredentialsSpecified ||
IsLocalBuild
);
}
public record AzureCredentials(
string? TenantId,
string? ClientId,
string? ClientSecret,
string? AuthorityHost = "login.microsoftonline.com"
)
{
public bool AzureCredentialsSpecified { get; } = !string.IsNullOrWhiteSpace(TenantId) &&
!string.IsNullOrWhiteSpace(ClientId) &&
!string.IsNullOrWhiteSpace(ClientSecret) &&
!string.IsNullOrWhiteSpace(AuthorityHost);
}
internal record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);