Skip to content

Commit 2cc34e3

Browse files
committed
(ci) - redefine the IsStableRelease, IsTaggedPreRelease and IsInternalPreRelease
1 parent c7e1ca9 commit 2cc34e3

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

build/build/Tasks/Test/PublishCoverage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public override bool ShouldRun(BuildContext context)
1212
{
1313
var shouldRun = true;
1414
shouldRun &= context.ShouldRun(context.IsOnWindows, $"{nameof(PublishCoverage)} works only on Windows agents.");
15-
shouldRun &= context.ShouldRun(context.IsOnMainOrSupportBranchOriginalRepo, $"{nameof(PublishCoverage)} works only for on main or release branch original repository.");
15+
shouldRun &= context.ShouldRun(context.IsReleaseBranchOriginalRepo, $"{nameof(PublishCoverage)} works only for main or release branch, original repository.");
1616

1717
return shouldRun;
1818
}

build/common/Utilities/BuildContextBase.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ protected BuildContextBase(ICakeContext context) : base(context)
1919
public bool IsOnWindows { get; set; }
2020
public bool IsOnLinux { get; set; }
2121
public bool IsOnMacOS { get; set; }
22-
public bool IsOnMainOrSupportBranchOriginalRepo => !IsLocalBuild && IsOriginalRepo && (IsMainBranch || IsSupportBranch) && !IsPullRequest;
23-
public bool IsStableRelease => IsOnMainOrSupportBranchOriginalRepo && IsTagged && Version?.IsPreRelease == false;
24-
public bool IsPreRelease => IsOnMainOrSupportBranchOriginalRepo && !IsTagged;
22+
public bool IsReleaseBranchOriginalRepo => !IsLocalBuild && IsOriginalRepo && (IsMainBranch || IsSupportBranch) && !IsPullRequest;
23+
public bool IsStableRelease => IsReleaseBranchOriginalRepo && IsTagged && Version?.IsPreRelease == false;
24+
public bool IsTaggedPreRelease => IsReleaseBranchOriginalRepo && IsTagged && Version?.IsPreRelease == true;
25+
public bool IsInternalPreRelease => IsReleaseBranchOriginalRepo && IsGitHubActionsBuild;
2526
}

build/docker/Tasks/DockerManifest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public override bool ShouldRun(BuildContext context)
3030

3131
if (context.DockerRegistry == DockerRegistry.GitHub)
3232
{
33-
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsPreRelease, $"{nameof(DockerPublish)} to GitHub Package Registry works only for releases.");
33+
shouldRun &= context.ShouldRun(context.IsInternalPreRelease, $"{nameof(DockerPublish)} to GitHub Package Registry works only internal releases.");
3434
}
3535
if (context.DockerRegistry == DockerRegistry.DockerHub)
3636
{
37-
shouldRun &= context.ShouldRun(context.IsStableRelease, $"{nameof(DockerPublish)} DockerHub works only for tagged releases.");
37+
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsTaggedPreRelease, $"{nameof(DockerPublish)} to DockerHub works only for tagged releases.");
3838
}
3939

4040
return shouldRun;

build/docker/Tasks/DockerPublish.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public override bool ShouldRun(BuildContext context)
3131
shouldRun &= context.ShouldRun(context.IsDockerOnLinux, $"{nameof(DockerPublish)} works only on Docker on Linux agents.");
3232
if (context.DockerRegistry == DockerRegistry.GitHub)
3333
{
34-
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsPreRelease, $"{nameof(DockerPublish)} to GitHub Package Registry works only for releases.");
34+
shouldRun &= context.ShouldRun(context.IsInternalPreRelease, $"{nameof(DockerPublish)} to GitHub Package Registry works only for internal releases.");
3535
}
3636
if (context.DockerRegistry == DockerRegistry.DockerHub)
3737
{
38-
shouldRun &= context.ShouldRun(context.IsStableRelease, $"{nameof(DockerPublish)} DockerHub works only for tagged releases.");
38+
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsTaggedPreRelease, $"{nameof(DockerPublish)} to DockerHub works only for tagged releases.");
3939
}
4040

4141
return shouldRun;

build/publish/Tasks/PublishChocolatey.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override bool ShouldRun(BuildContext context)
2020
var shouldRun = true;
2121
shouldRun &= context.ShouldRun(context.IsGitHubActionsBuild, $"{nameof(PublishChocolatey)} works only on GitHub Actions.");
2222
shouldRun &= context.ShouldRun(context.IsOnWindows, $"{nameof(PublishChocolatey)} works only on windows.");
23-
shouldRun &= context.ShouldRun(context.IsStableRelease, $"{nameof(PublishChocolatey)} works only for stable releases.");
23+
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsTaggedPreRelease, $"{nameof(PublishChocolatey)} works only for tagged releases.");
2424

2525
return shouldRun;
2626
}

build/publish/Tasks/PublishNuget.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public override bool ShouldRun(BuildContext context)
1818
{
1919
var shouldRun = true;
2020
shouldRun &= context.ShouldRun(context.IsGitHubActionsBuild, $"{nameof(PublishNuget)} works only on GitHub Actions.");
21-
shouldRun &= context.ShouldRun(context.IsPreRelease || context.IsStableRelease, $"{nameof(PublishNuget)} works only for releases.");
21+
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsTaggedPreRelease || context.IsInternalPreRelease, $"{nameof(PublishNuget)} works only for releases.");
2222

2323
return shouldRun;
2424
}
2525

2626
public override void Run(BuildContext context)
2727
{
2828
// publish to github packages for commits on main and on original repo
29-
if (context is { IsGitHubActionsBuild: true, IsOnMainOrSupportBranchOriginalRepo: true })
29+
if (context.IsInternalPreRelease)
3030
{
3131
var apiKey = context.Credentials?.GitHub?.Token;
3232
if (string.IsNullOrEmpty(apiKey))
@@ -35,8 +35,8 @@ public override void Run(BuildContext context)
3535
}
3636
PublishToNugetRepo(context, apiKey, Constants.GithubPackagesUrl);
3737
}
38-
// publish to nuget.org for stable releases
39-
if (context.IsStableRelease)
38+
// publish to nuget.org for tagged releases
39+
if (context.IsStableRelease || context.IsTaggedPreRelease)
4040
{
4141
var apiKey = context.Credentials?.Nuget?.ApiKey;
4242
if (string.IsNullOrEmpty(apiKey))

build/release/Tasks/PublishRelease.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override bool ShouldRun(BuildContext context)
2020
{
2121
var shouldRun = true;
2222
shouldRun &= context.ShouldRun(context.IsGitHubActionsBuild, $"{nameof(PublishRelease)} works only on GitHub Actions.");
23-
shouldRun &= context.ShouldRun(context.IsStableRelease, $"{nameof(PublishRelease)} works only for releases.");
23+
shouldRun &= context.ShouldRun(context.IsStableRelease || context.IsTaggedPreRelease, $"{nameof(PublishRelease)} works only for tagged releases.");
2424

2525
return shouldRun;
2626
}

0 commit comments

Comments
 (0)