Skip to content

Commit

Permalink
Merge pull request #119 from The-Standard-Organization/users/cjdutoit…
Browse files Browse the repository at this point in the history
…/minorfoundation-publish-job

MINOR FOUNDATIONS: Created V2 of PublishJob which will allow you to set the dotnet target version
  • Loading branch information
glhays authored Nov 25, 2024
2 parents 1e24f7b + cff208a commit 9a62a34
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions ADotNet/Models/Pipelines/GithubPipelines/DotNets/PublishJobV2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// ---------------------------------------------------------------------------
// Copyright (c) Hassan Habib & Shri Humrudha Jagathisun All rights reserved.
// Licensed under the MIT License.
// See License.txt in the project root for license information.
// ---------------------------------------------------------------------------

using System.Collections.Generic;
using System.ComponentModel;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks;
using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s;
using YamlDotNet.Serialization;

namespace ADotNet.Models.Pipelines.GithubPipelines.DotNets
{
public class PublishJobV2 : Job
{
public PublishJobV2(
string runsOn,
string dependsOn,
string dotNetVersion,
string nugetApiKey)
{
RunsOn = runsOn;
Needs = new string[] { dependsOn };

If = $"needs.{dependsOn}.result == 'success'";

Steps = new List<GithubTask> {
new CheckoutTaskV3
{
Name = "Check out"
},

new SetupDotNetTaskV3
{
Name = "Setup .Net",

With = new TargetDotNetVersionV3
{
DotNetVersion = dotNetVersion
}
},

new RestoreTask
{
Name = "Restore"
},

new DotNetBuildReleaseTask
{
Name = "Build",
},

new PackNugetTaskWithSymbols
{
Name = "Pack NuGet Package",
},

new NugetPushTask(nugetApiKey)
{
Name = "Push NuGet Package",
}
};

}

[YamlMember(Order = 0, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Name { get; set; }

[YamlMember(Order = 1, Alias = "runs-on")]
public new string RunsOn { get; set; }

[YamlMember(Order = 2, Alias = "needs", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string[] Needs { get; set; }

[YamlMember(Order = 3, Alias = "if", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string If { get; set; }

[YamlMember(Order = 4, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new string Environment { get; set; }

[YamlMember(Order = 5, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new DefaultValues Defaults { get; set; }

[YamlMember(Order = 6)]
public new List<GithubTask> Steps { get; set; }

[DefaultValue(0)]
[YamlMember(Order = 7, Alias = "timeout-minutes", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new int TimeoutInMinutes { get; set; }

[YamlMember(Order = 8, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Strategy Strategy { get; set; }

[YamlMember(Order = 9, Alias = "env", DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> EnvironmentVariables { get; set; }

[YamlMember(Order = 10, DefaultValuesHandling = DefaultValuesHandling.OmitDefaults)]
public new Dictionary<string, string> Outputs { get; set; }
}
}

0 comments on commit 9a62a34

Please sign in to comment.