-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDeployNugetsToGithubTask.cs
More file actions
30 lines (25 loc) · 1000 Bytes
/
DeployNugetsToGithubTask.cs
File metadata and controls
30 lines (25 loc) · 1000 Bytes
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
using Cake.Common;
using Cake.Common.Build;
using Cake.Common.IO;
using Cake.Common.Tools.DotNet;
using Cake.Common.Tools.DotNet.NuGet.Push;
using Cake.Core.IO;
using Cake.Frosting;
namespace AsepriteDotNet.Build;
[TaskName("DeployNugetsToGithub")]
[IsDependentOn(typeof(DownloadArtifactsTask))]
public sealed class DeployNugetsToGitHubTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.BuildSystem().IsRunningOnGitHubActions;
public override void Run(BuildContext context)
{
ArgumentNullException.ThrowIfNull(context);
string repositoryOwner = context.GitHubActions().Environment.Workflow.RepositoryOwner;
DotNetNuGetPushSettings settings = new DotNetNuGetPushSettings()
{
ApiKey = context.EnvironmentVariable("GITHUB_TOKEN"),
Source = $"https://nuget.pkg.github.com/{repositoryOwner}/index.json"
};
context.DotNetNuGetPush("nugets/*.nupkg", settings);
}
}