-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed Print task and moved it to OnInitialized event handler. Added…
… Global usings and code refactoring.
- Loading branch information
1 parent
2ba30eb
commit 04392cc
Showing
10 changed files
with
90 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
global using Invariants; | ||
global using Nuke.Common.ProjectModel; | ||
global using Nuke.Common.IO; | ||
global using Nuke.Common.Tooling; | ||
global using Nuke.Common.Tools.GitVersion; | ||
global using Nuke.Common.Utilities.Collections; | ||
global using Serilog; | ||
global using System; | ||
global using System.Linq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System; | ||
|
||
namespace Invariants | ||
namespace Invariants | ||
{ | ||
public static class PackageDetail | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
using System; | ||
|
||
namespace Invariants | ||
namespace Invariants | ||
{ | ||
public static class PackageValue | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,58 @@ | ||
using Invariants; | ||
using Nuke.Common.Tools.GitVersion; | ||
using Nuke.Common.Utilities.Collections; | ||
using Serilog; | ||
using System; | ||
using System.Configuration; | ||
using System.Configuration; | ||
|
||
|
||
public class ReleaseGuard | ||
public sealed class ReleaseGuard | ||
{ | ||
readonly GitVersion gitVersion; | ||
|
||
internal ReleaseGuard(GitVersion GitVersion) | ||
readonly PackagePublishConfig nugetOrg; | ||
readonly PackagePublishConfig githubPackages; | ||
|
||
internal ReleaseGuard(GitVersion GitVersion, PackagePublishConfig nugetOrg, PackagePublishConfig githubPackages) | ||
{ | ||
this.githubPackages = githubPackages; | ||
this.nugetOrg = nugetOrg; | ||
gitVersion = GitVersion ?? throw new ArgumentNullException(nameof(GitVersion)); | ||
} | ||
|
||
private bool IsPreReleaseBuild => | ||
gitVersion.PreReleaseLabel.Equals(BuildType.Ci, StringComparison.OrdinalIgnoreCase) || | ||
gitVersion.PreReleaseLabel.Equals(BuildType.Rc, StringComparison.OrdinalIgnoreCase); | ||
|
||
private bool IsReleaseOrMain => | ||
private bool IsReleaseOrMainBranch => | ||
gitVersion.BranchName.StartsWith(Branch.Release, StringComparison.OrdinalIgnoreCase) || | ||
gitVersion.BranchName.Equals(Branch.Main, StringComparison.OrdinalIgnoreCase); | ||
|
||
private bool IsReleaseBranch => | ||
gitVersion.BranchName.StartsWith(Branch.Release, StringComparison.OrdinalIgnoreCase); | ||
|
||
public bool IsTaggedBuild => gitVersion.PreReleaseTag.IsEmpty(); | ||
|
||
public bool BuildToBePacked(OverrideMode overrideMode = OverrideMode.Deny) => overrideMode == OverrideMode.Allow ? true : IsReleaseOrMain; | ||
public bool BuildToBePacked(OverrideMode? overrideMode = null) => overrideMode switch | ||
{ | ||
OverrideMode.Allow => true, | ||
OverrideMode.Deny => false, | ||
_ => IsReleaseOrMainBranch | ||
}; | ||
|
||
public bool BuildToBeReleasedToNugetOrg => | ||
IsTaggedBuild && | ||
gitVersion.BranchName.StartsWith(Branch.Release, StringComparison.OrdinalIgnoreCase); | ||
public bool BuildToBeReleasedToNugetOrg() => IsTaggedBuild && IsReleaseBranch; | ||
|
||
public bool BuildToBeReleasedToGitHub => IsPreReleaseBuild; | ||
public bool BuildToBeReleasedToGitHub() => IsPreReleaseBuild; | ||
|
||
public PackagePublishConfig ResolvePublishDestinationDetails() | ||
{ | ||
if (BuildToBeReleasedToNugetOrg()) | ||
{ | ||
return nugetOrg; | ||
} | ||
else if (BuildToBeReleasedToGitHub()) | ||
{ | ||
return githubPackages; | ||
} | ||
else | ||
{ | ||
return new PackagePublishConfig(string.Empty, string.Empty); | ||
} | ||
} | ||
} | ||
|
||
public record PackagePublishConfig(string Token, string Url); |