Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit cf5996e

Browse files
+ local branch,
+ Default-CI always pushed to dev nuget feed
1 parent 1bc9d77 commit cf5996e

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

Build/build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
{
4444
"Target": "scripts",
4545
"TargetFiles": [
46-
"bin/debug/scripts/SubPointSolutions.CakeBuild.Core.cake"
46+
"bin/debug/scripts/SubPointSolutions.CakeBuild.Core.cake",
47+
"bin/debug/scripts/build-template.json"
4748
]
4849
}
4950
]

SubPointSolutions.CakeBuildTools/Scripts/SubPointSolutions.CakeBuild.Core.cake

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,15 @@ NuSpecDependency[] ResolveDependenciesForPackage(string id) {
462462

463463
// CI related environment
464464
// * dev / beta / master versioning and publishing
465-
var ciBranch = GetGlobalEnvironmentVariable("ci.activebranch") ?? "dev";
465+
var ciBranch = GetGlobalEnvironmentVariable("ci.activebranch") ?? "local";
466466

467467
// override under CI run
468468
var ciBranchOverride = GetGlobalEnvironmentVariable("APPVEYOR_REPO_BRANCH");
469469
if(!String.IsNullOrEmpty(ciBranchOverride))
470+
{
471+
Information(String.Format("Detected APPVEYOR build. Reverting to APPVEYOR_REPO_BRANCH varibale:[{0}]", ciBranchOverride));
470472
ciBranch = ciBranchOverride;
473+
}
471474

472475
var ciNuGetSource = GetGlobalEnvironmentVariable("ci.nuget.source") ?? String.Empty;
473476
var ciNuGetKey = GetGlobalEnvironmentVariable("ci.nuget.key") ?? String.Empty;
@@ -601,22 +604,49 @@ var defaultActionAPINuGetPackaging =Task("Action-API-NuGet-Packaging")
601604
}
602605
});
603606

607+
bool ShouldPublishAPINuGet(string branch) {
608+
609+
// always publish dev branch
610+
// the rest comes from 'ciNuGetShouldPublish' -> 'ci.nuget.shouldpublish' environment variable
611+
if(branch == "dev")
612+
return true;
613+
614+
return ciNuGetShouldPublish;
615+
}
616+
604617
var defaultActionAPINuGetPublishing = Task("Action-API-NuGet-Publishing")
605618
// all packaged should be compiled by NuGet-Packaging task into 'defaultNuGetPackagesDirectory' folder
606619
.Does(() =>
607620
{
608-
if(!ciNuGetShouldPublish) {
609-
Information("Skipping NuGet publishing as ciNuGetShouldPublish is false.");
621+
Information(String.Format("API NuGet publishing enabled? branch:[{0}]", ciBranch));
622+
var shouldPublish = ShouldPublishAPINuGet(ciBranch);
623+
624+
var nugetSource = String.Empty;
625+
var nugetKey = String.Empty;
626+
627+
if(!shouldPublish) {
628+
Information("Skipping NuGet publishing.");
610629
return;
630+
} else {
631+
Information("Fetching NuGet feed creds.");
632+
633+
var feedSourceVariableName = String.Format("ci.nuget.{0}-source", ciBranch);
634+
var feedKeyVariableName = String.Format("ci.nuget.{0}-key", ciBranch);
635+
636+
var feedSourceValue = GetGlobalEnvironmentVariable(feedSourceVariableName);
637+
var feedKeyValue = GetGlobalEnvironmentVariable(feedKeyVariableName);
638+
639+
if(String.IsNullOrEmpty(feedSourceValue))
640+
throw new Exception(String.Format("environment variable is null or empty:[{0}]", feedSourceVariableName));
641+
642+
if(String.IsNullOrEmpty(feedKeyValue))
643+
throw new Exception(String.Format("environment variable is null or empty:[{0}]", feedKeyVariableName));
611644
}
612645

613646
Information("Publishing NuGet packages to repository: [{0}]", new []{
614-
ciNuGetSource
647+
nugetSource
615648
});
616649

617-
var nugetSource = ciNuGetSource;
618-
var nugetKey = ciNuGetKey;
619-
620650
var nuGetPackages = System.IO.Directory.GetFiles(defaultNuGetPackagesDirectory, "*.nupkg");
621651

622652
foreach(var packageFilePath in nuGetPackages)
@@ -968,4 +998,8 @@ var taskDefaultCI = Task("Default-CI")
968998
.IsDependentOn("Action-API-NuGet-Packaging")
969999
.IsDependentOn("Action-CLI-Zip-Packaging")
9701000
.IsDependentOn("Action-CLI-Chocolatey-Packaging")
1001+
// always 'push'
1002+
// the action checks if the current branch has to be published (dev always, the rest goes via 'ci.nuget.shouldpublish')
1003+
.IsDependentOn("Action-API-NuGet-Publishing")
1004+
9711005
.IsDependentOn("Action-Docs-Merge");

0 commit comments

Comments
 (0)