-
Notifications
You must be signed in to change notification settings - Fork 1
/
PackContext.cs
46 lines (33 loc) · 1.25 KB
/
PackContext.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
35
36
37
38
39
40
41
42
43
44
45
46
using NuGet.Protocol.Core.Types;
namespace BuildScripts;
public class PackContext
{
public string ToolName { get; }
public string CommandName { get; }
public string ExecutableName { get; }
public string LicensePath { get; }
public string? RepositoryOwner { get; }
public string? RepositoryUrl { get; }
public string Version { get; }
public bool IsTag { get; }
public PackContext(ICakeContext context)
{
ToolName = context.Argument("toolname", "X");
CommandName = context.Argument("commandname", "X");
ExecutableName = context.Argument("executablename", "X");
LicensePath = context.Argument("licensepath", "");
Version = context.Argument("version", "1.0.0");
RepositoryUrl = "X";
IsTag = false;
if (context.BuildSystem().IsRunningOnGitHubActions)
{
RepositoryOwner = context.EnvironmentVariable("GITHUB_REPOSITORY_OWNER");
RepositoryUrl = $"https://github.com/{context.EnvironmentVariable("GITHUB_REPOSITORY")}";
IsTag = context.EnvironmentVariable("GITHUB_REF_TYPE") == "tag";
if (IsTag)
{
Version = context.EnvironmentVariable("GITHUB_REF_NAME");
}
}
}
}