Skip to content

Commit 2cf8ab1

Browse files
committed
(build) publish to nuget.org/chocolatey only for stable releases, to GitHub Packages for previews
1 parent 1e9bc82 commit 2cf8ab1

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

build/publish.cake

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,29 @@ Task("Publish-NuGet-Internal")
5757
.IsDependentOnWhen("Pack-NuGet", singleStageRun)
5858
.Does<BuildParameters>((parameters) =>
5959
{
60-
var apiKey = parameters.Credentials.Nuget.ApiKey;
61-
if(string.IsNullOrEmpty(apiKey)) {
62-
throw new InvalidOperationException("Could not resolve NuGet API key.");
63-
}
60+
if (parameters.IsStableRelease())
61+
{
62+
var apiKey = parameters.Credentials.Nuget.ApiKey;
63+
if(string.IsNullOrEmpty(apiKey)) {
64+
throw new InvalidOperationException("Could not resolve NuGet API key.");
65+
}
6466

65-
var apiUrl = parameters.Credentials.Nuget.ApiUrl;
66-
if(string.IsNullOrEmpty(apiUrl)) {
67-
throw new InvalidOperationException("Could not resolve NuGet API url.");
68-
}
67+
var apiUrl = parameters.Credentials.Nuget.ApiUrl;
68+
if(string.IsNullOrEmpty(apiUrl)) {
69+
throw new InvalidOperationException("Could not resolve NuGet API url.");
70+
}
6971

70-
foreach(var package in parameters.Packages.Nuget)
71-
{
72-
if (FileExists(package.PackagePath))
72+
foreach(var package in parameters.Packages.Nuget)
7373
{
74-
// Push the package to nuget.org
75-
NuGetPush(package.PackagePath, new NuGetPushSettings
74+
if (FileExists(package.PackagePath))
7675
{
77-
ApiKey = apiKey,
78-
Source = apiUrl
79-
});
76+
// Push the package to nuget.org
77+
NuGetPush(package.PackagePath, new NuGetPushSettings
78+
{
79+
ApiKey = apiKey,
80+
Source = apiUrl
81+
});
82+
}
8083
}
8184
}
8285

@@ -128,7 +131,7 @@ Task("Publish-Chocolatey-Internal")
128131
.WithCriteria<BuildParameters>((context, parameters) => parameters.EnabledPublishChocolatey, "Publish-Chocolatey was disabled.")
129132
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsRunningOnWindows, "Publish-Chocolatey works only on Windows agents.")
130133
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsReleasingCI, "Publish-Chocolatey works only on Releasing CI.")
131-
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsStableRelease() || parameters.IsPreRelease(), "Publish-Chocolatey works only for releases.")
134+
.WithCriteria<BuildParameters>((context, parameters) => parameters.IsStableRelease(), "Publish-Chocolatey works only for releases.")
132135
.IsDependentOnWhen("Pack-Chocolatey", singleStageRun)
133136
.Does<BuildParameters>((parameters) =>
134137
{

0 commit comments

Comments
 (0)