Skip to content

Commit c203169

Browse files
committed
(GH-2120) pushing nuget to GitHub Packages
1 parent 660454f commit c203169

File tree

1 file changed

+32
-22
lines changed

1 file changed

+32
-22
lines changed

build/publish.cake

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,32 +105,42 @@ Task("Publish-NuGet-Internal")
105105
ApiKey = apiKey,
106106
Source = apiUrl
107107
});
108+
}
109+
}
108110

109-
// Push the package to GitHub Packages
110-
if (parameters.IsRunningOnGitHubActions) {
111-
var token = parameters.Credentials.GitHub.Token;
112-
if(string.IsNullOrEmpty(token)) {
113-
throw new InvalidOperationException("Could not resolve Github token.");
114-
}
115-
var userName = parameters.Credentials.GitHub.UserName;
116-
if(string.IsNullOrEmpty(userName)) {
117-
throw new InvalidOperationException("Could not resolve Github userName.");
118-
}
111+
// Push the package to GitHub Packages
112+
if (parameters.IsRunningOnGitHubActions)
113+
{
114+
Information("Publishing nuget to GitHub Packages");
119115

120-
var source = $"https://nuget.pkg.github.com/{BuildParameters.MainRepoOwner}/index.json";
116+
var token = parameters.Credentials.GitHub.Token;
117+
if(string.IsNullOrEmpty(token)) {
118+
throw new InvalidOperationException("Could not resolve Github token.");
119+
}
120+
var userName = parameters.Credentials.GitHub.UserName;
121+
if(string.IsNullOrEmpty(userName)) {
122+
throw new InvalidOperationException("Could not resolve Github userName.");
123+
}
121124

122-
var nugetSourceSettings = new NuGetSourcesSettings
123-
{
124-
UserName = parameters.Credentials.GitHub.UserName,
125-
Password = token
126-
};
125+
var source = $"https://nuget.pkg.github.com/{BuildParameters.MainRepoOwner}/index.json";
127126

128-
Information("Adding NuGet source with user/pass...");
129-
NuGetAddSource("GitHub", source, nugetSourceSettings);
130-
NuGetPush(package.PackagePath, new NuGetPushSettings
131-
{
132-
Source = source
133-
});
127+
var nugetSourceSettings = new NuGetSourcesSettings
128+
{
129+
UserName = userName,
130+
Password = token
131+
};
132+
133+
Information("Adding NuGet source with user/pass...");
134+
NuGetAddSource("GitHub", source, nugetSourceSettings);
135+
136+
foreach(var package in parameters.Packages.Nuget)
137+
{
138+
if (FileExists(package.PackagePath))
139+
{
140+
NuGetPush(package.PackagePath, new NuGetPushSettings
141+
{
142+
Source = source
143+
});
134144
}
135145
}
136146
}

0 commit comments

Comments
 (0)