Skip to content

Commit 8c36f4c

Browse files
committed
Enable SkipForked
1 parent a395540 commit 8c36f4c

File tree

11 files changed

+124
-48
lines changed

11 files changed

+124
-48
lines changed

Build/.nuke/build.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@
111111
"allOf": [
112112
{
113113
"properties": {
114+
"EnableForkedRepository": {
115+
"type": "boolean"
116+
},
114117
"Folder": {
115118
"type": "string"
116119
},

Build/IShowGitVersion.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
using Nuke.Common;
2+
using Nuke.Common.Git;
23
using ricaun.Nuke.Components;
34
using ricaun.Nuke.Extensions;
45

5-
public interface IShowGitVersion : IHazGitVersion, IHazChangelog, IClean, ICompile
6+
public interface IShowGitVersion : IHazGitVersion, IHazGitRepository, IHazChangelog, IClean, ICompile
67
{
78
Target ShowGitVersion => _ => _
89
.TriggeredBy(Clean)
@@ -23,5 +24,23 @@ public interface IShowGitVersion : IHazGitVersion, IHazChangelog, IClean, ICompi
2324
System.IO.Path.Combine(BuildAssemblyDirectory, $"latest.json"));
2425
}
2526
catch { }
27+
28+
29+
Serilog.Log.Information("Commit = {Value}", GitRepository.Commit);
30+
Serilog.Log.Information("Branch = {Value}", GitRepository.Branch);
31+
Serilog.Log.Information("Tags = {Value}", GitRepository.Tags);
32+
Serilog.Log.Information("Head = {Value}", GitRepository.Head);
33+
Serilog.Log.Information("Identifier = {Value}", GitRepository.Identifier);
34+
35+
Serilog.Log.Information("IsForked = {Value}", GitRepository.IsForked());
36+
37+
Serilog.Log.Information("main branch = {Value}", GitRepository.IsOnMainBranch());
38+
Serilog.Log.Information("main/master branch = {Value}", GitRepository.IsOnMainOrMasterBranch());
39+
Serilog.Log.Information("release/* branch = {Value}", GitRepository.IsOnReleaseBranch());
40+
Serilog.Log.Information("hotfix/* branch = {Value}", GitRepository.IsOnHotfixBranch());
41+
42+
Serilog.Log.Information("Https URL = {Value}", GitRepository.HttpsUrl);
43+
Serilog.Log.Information("SSH URL = {Value}", GitRepository.SshUrl);
44+
2645
});
2746
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
### Features
99
- Enable sign files using `Azure Key Vault`.
1010
- Enable `IAssetRelease` to release assets before `GitRelease` and `GitPreRelease`.
11+
- Enable `SkipForked` to skip release if forked repository.
1112
### Build
1213
- Add `IAzureSignTool` to check if `AzureSignToolUtils` is installed.
1314
- Add `ILocalAssetRelease` to test `AssetRelease` assets before release.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>1.9.0-beta.9</Version>
3+
<Version>1.9.0-rc</Version>
44
</PropertyGroup>
55
</Project>

ricaun.Nuke.Example.Tests/ricaun.Nuke.Example.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
17-
<TargetFramework>net7.0</TargetFramework>
17+
<TargetFramework>net8.0</TargetFramework>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

ricaun.Nuke/Components/IGitPreRelease.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public bool HasPreReleaseFilter(string version)
3838
.OnlyWhenStatic(() => GitHubToken.SkipEmpty())
3939
.OnlyWhenStatic(() => IsServerBuild)
4040
.OnlyWhenDynamic(() => GitRepository.IsOnDevelopBranch())
41+
.OnlyWhenDynamic(() => SkipForked())
4142
.Executes(() =>
4243
{
4344
var project = MainProject;

ricaun.Nuke/Components/IGitRelease.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public interface IGitRelease : IRelease, IHazGitRepository, IHazGitVersion, IHaz
2626
.OnlyWhenStatic(() => GitHubToken.SkipEmpty())
2727
.OnlyWhenStatic(() => IsServerBuild)
2828
.OnlyWhenDynamic(() => GitRepository.IsOnMainOrMasterBranch())
29+
.OnlyWhenDynamic(() => SkipForked())
2930
.Executes(() =>
3031
{
3132
var project = MainProject;

ricaun.Nuke/Components/IHazGitRepository.cs

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,72 @@
1-
using Nuke.Common;
2-
using Nuke.Common.Git;
3-
4-
namespace ricaun.Nuke.Components
5-
{
6-
/// <summary>
7-
/// IHazGitRepository
8-
/// </summary>
9-
public interface IHazGitRepository : INukeBuild
10-
{
11-
/// <summary>
12-
/// GitHubToken
13-
/// </summary>
14-
[Secret][Parameter] public string GitHubToken => TryGetValue(() => GitHubToken);
15-
16-
/// <summary>
17-
/// GitRepository
18-
/// </summary>
19-
[GitRepository] GitRepository GitRepository => TryGetValue(() => GitRepository);
20-
21-
/// <summary>
22-
/// GetGitRepositoryPackageUrl (default: https://nuget.pkg.github.com/repository_owner/index.json)
23-
/// </summary>
24-
/// <returns></returns>
25-
public string GetGitRepositoryPackageUrl()
26-
{
27-
if (GitRepository == null)
28-
{
29-
Serilog.Log.Warning($"GitRepository not found.");
30-
return "";
31-
}
32-
return $@"https://nuget.pkg.github.com/{GetGitRepositoryOwner()}/index.json";
33-
}
34-
35-
/// <summary>
36-
/// GetGitRepositoryOwner based on the GitRepository.Identifier
37-
/// </summary>
38-
/// <returns></returns>
39-
public string GetGitRepositoryOwner()
40-
{
41-
if (GitRepository == null) return "";
42-
return GitRepository.Identifier?.Split("/")[0];
43-
}
44-
}
45-
}
1+
using Nuke.Common;
2+
using Nuke.Common.Git;
3+
using ricaun.Nuke.Extensions;
4+
5+
namespace ricaun.Nuke.Components
6+
{
7+
/// <summary>
8+
/// IHazGitRepository
9+
/// </summary>
10+
public interface IHazGitRepository : INukeBuild
11+
{
12+
/// <summary>
13+
/// GitHubToken
14+
/// </summary>
15+
[Secret][Parameter] public string GitHubToken => TryGetValue(() => GitHubToken);
16+
17+
/// <summary>
18+
/// GitRepository
19+
/// </summary>
20+
[GitRepository] GitRepository GitRepository => TryGetValue(() => GitRepository);
21+
22+
/// <summary>
23+
/// GetGitRepositoryPackageUrl (default: https://nuget.pkg.github.com/repository_owner/index.json)
24+
/// </summary>
25+
/// <returns></returns>
26+
public string GetGitRepositoryPackageUrl()
27+
{
28+
if (GitRepository == null)
29+
{
30+
Serilog.Log.Warning($"GitRepository not found.");
31+
return "";
32+
}
33+
return $@"https://nuget.pkg.github.com/{GetGitRepositoryOwner()}/index.json";
34+
}
35+
36+
/// <summary>
37+
/// GetGitRepositoryOwner based on the GitRepository.Identifier
38+
/// </summary>
39+
/// <returns></returns>
40+
public string GetGitRepositoryOwner()
41+
{
42+
if (GitRepository == null) return "";
43+
return GitRepository.Identifier?.Split("/")[0];
44+
}
45+
46+
/// <summary>
47+
/// Indicates whether the forked repository is enabled.
48+
/// </summary>
49+
[Parameter]
50+
bool EnableForkedRepository => TryGetValue<bool?>(() => EnableForkedRepository) ?? false;
51+
52+
/// <summary>
53+
/// Determines if the forked repository should be skipped.
54+
/// </summary>
55+
/// <returns>True if the forked repository should be skipped; otherwise, false.</returns>
56+
public bool SkipForked()
57+
{
58+
if (EnableForkedRepository)
59+
return false;
60+
61+
return IsGitRepositoryForked();
62+
}
63+
/// <summary>
64+
/// IsGitRepositoryForked
65+
/// </summary>
66+
/// <returns></returns>
67+
public bool IsGitRepositoryForked()
68+
{
69+
return GitRepository.IsForked();
70+
}
71+
}
72+
}

ricaun.Nuke/Components/IPack.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public interface IPack : IHazPack, IGitRelease
2929
.OnlyWhenStatic(() => NugetApiKey.SkipEmpty())
3030
.OnlyWhenStatic(() => IsServerBuild)
3131
.OnlyWhenDynamic(() => GitRepository.IsOnMainOrMasterBranch())
32+
.OnlyWhenDynamic(() => SkipForked())
3233
.Executes(() =>
3334
{
3435
var releaseDirectory = GetReleaseDirectory(MainProject);

ricaun.Nuke/Components/IPrePack.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public interface IPrePack : IPack, IGitPreRelease
2424
.OnlyWhenStatic(() => NugetApiKey.SkipEmpty())
2525
.OnlyWhenStatic(() => IsServerBuild)
2626
.OnlyWhenDynamic(() => GitRepository.IsOnDevelopBranch())
27+
.OnlyWhenDynamic(() => SkipForked())
2728
.Executes(() =>
2829
{
2930
var version = MainProject.GetInformationalVersion();

0 commit comments

Comments
 (0)