Skip to content

Commit

Permalink
Merge pull request #1298 from nunit/issue-1296
Browse files Browse the repository at this point in the history
Use NUnit-specific environment variable names
  • Loading branch information
CharliePoole committed Jan 7, 2023
2 parents 2fe59e7 + 06447e4 commit abc8668
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ artifacts:
- path: package\*.zip

environment:
MYGET_API_KEY:
NUNIT_MYGET_API_KEY:
secure: wtAvJDVl2tfwiVcyLExFHLvZVfUWiQRHsfdHBFCNEATeCHo1Nd8JP642PfY8xhji
NUGET_API_KEY:
secure: PVHROoT0SmGkr9CHgrKapuA0/CcJGHSP63M3fZaNLvcEVbBnzYLeCwpc0PZHhdvD
CHOCO_API_KEY:
NUNIT_NUGET_API_KEY:
secure: xwXh6lXIun0EFVNqJV03DX3DuT1yW9419ljqNPrkm6SdsKoJm13QqoxY4EuqzyVs
NUNIT_CHOCO_API_KEY:
secure: aDsu1U+umVYFVybjkBVtVQsatSj3QKbD7VkGQci9mNF3493g9Giao/GABISIaHjT
GITHUB_ACCESS_TOKEN:
secure: RJ6sKRBZzwXz8JQvj8zcp45mkHNDad1UlvmfCsiVx63V9/pXHcm2Y2Lg/G/Vyhlz
20 changes: 17 additions & 3 deletions cake/build-settings.cake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class BuildSettings

BuildVersion = new BuildVersion(context);

MyGetApiKey = GetApiKey(MYGET_API_KEY, FALLBACK_MYGET_API_KEY);
NuGetApiKey = GetApiKey(NUGET_API_KEY, FALLBACK_NUGET_API_KEY);
ChocolateyApiKey = GetApiKey(CHOCO_API_KEY, FALLBACK_CHOCO_API_KEY);

Net35Test = new PackageTest(
"Net35Test",
"Run mock-assembly.dll under .NET 3.5",
Expand Down Expand Up @@ -175,9 +179,9 @@ public class BuildSettings
public bool ShouldPublishToChocolatey => !IsPreRelease || LABELS_WE_PUBLISH_ON_CHOCOLATEY.Contains(PreReleaseLabel);
public bool IsProductionRelease => !IsPreRelease || LABELS_WE_RELEASE_ON_GITHUB.Contains(PreReleaseLabel);

public string MyGetApiKey => _context.EnvironmentVariable(MYGET_API_KEY);
public string NuGetApiKey => _context.EnvironmentVariable(NUGET_API_KEY);
public string ChocolateyApiKey => _context.EnvironmentVariable(CHOCO_API_KEY);
public string MyGetApiKey { get; }
public string NuGetApiKey { get; }
public string ChocolateyApiKey { get; }

public string GitHubAccessToken => _context.EnvironmentVariable(GITHUB_ACCESS_TOKEN);

Expand Down Expand Up @@ -291,6 +295,16 @@ public class BuildSettings
Console.WriteLine($" NetCore Runner: {NETCORE_CONSOLE_PROJECT}");
}

private string GetApiKey(string name, string fallback=null)
{
var apikey = _context.EnvironmentVariable(name);

if (string.IsNullOrEmpty(apikey) && fallback != null)
apikey = _context.EnvironmentVariable(fallback);

return apikey;
}

private void ShowApiKeyAvailability(string apikey)
{
if (string.IsNullOrEmpty(apikey))
Expand Down
9 changes: 6 additions & 3 deletions cake/constants.cake
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ private const string NUGET_PUSH_URL = "https://api.nuget.org/v3/index.json";
private const string CHOCO_PUSH_URL = "https://push.chocolatey.org/";

// Environment Variable names holding API keys
private const string MYGET_API_KEY = "MYGET_API_KEY";
private const string NUGET_API_KEY = "NUGET_API_KEY";
private const string CHOCO_API_KEY = "CHOCO_API_KEY";
private const string MYGET_API_KEY = "NUNIT_MYGET_API_KEY";
private const string NUGET_API_KEY = "NUNIT_NUGET_API_KEY";
private const string CHOCO_API_KEY = "NUNIT_CHOCO_API_KEY";
private const string FALLBACK_MYGET_API_KEY = "MYGET_API_KEY";
private const string FALLBACK_NUGET_API_KEY = "NUGET_API_KEY";
private const string FALLBACK_CHOCO_API_KEY = "CHOCO_API_KEY";

// GitHub Information
private const string GITHUB_OWNER = "nunit";
Expand Down

0 comments on commit abc8668

Please sign in to comment.