Skip to content

Commit

Permalink
Add ILocalAssetRelease to test AssetRelease
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Dec 18, 2024
1 parent 43c3f10 commit b9814b7
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
1 change: 1 addition & 0 deletions Build/.nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"CompileExample",
"GitPreRelease",
"GitRelease",
"LocalAssetRelease",
"Pack",
"PrePack",
"Release",
Expand Down
19 changes: 2 additions & 17 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,9 @@
using ricaun.Nuke;
using ricaun.Nuke.Components;

class AssetRelease : IAssetRelease
class Build : NukeBuild, IPublishPack, ICompileExample, ITest, IShowGitVersion, IAzureSignTool, IPrePack, ILocalAssetRelease
{
public void ReleaseAsset(ReleaseAssets releaseAssets)
{
Serilog.Log.Information($"Project: {releaseAssets.Project.Name}");
Serilog.Log.Information($"Version: {releaseAssets.Version}");
Serilog.Log.Information($"Notes: {releaseAssets.Notes}");
Serilog.Log.Information($"Prerelease: {releaseAssets.Prerelease}");
foreach (var file in releaseAssets.Files)
{
Serilog.Log.Information($"File: {file}");
}
}
}

class Build : NukeBuild, IPublishPack, ICompileExample, ITest, IShowGitVersion, IAzureSignTool, IPrePack
{
IAssetRelease IHazAssetRelease.AssetRelease => null;
IAssetRelease IHazAssetRelease.AssetRelease => new AssetRelease();
//bool IPack.UnlistNuget => true;
bool ITest.TestBuildStopWhenFailed => false;
public static int Main() => Execute<Build>(x => x.From<IPublishPack>().Build);
Expand Down
35 changes: 35 additions & 0 deletions Build/ILocalAssetRelease.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Nuke.Common;
using ricaun.Nuke.Components;
using ricaun.Nuke.Extensions;

class AssetRelease : IAssetRelease
{
public void ReleaseAsset(ReleaseAssets releaseAssets)
{
Serilog.Log.Information($"Project: {releaseAssets.Project.Name}");
Serilog.Log.Information($"Version: {releaseAssets.Version}");
Serilog.Log.Information($"Notes: {releaseAssets.Notes}");
Serilog.Log.Information($"Prerelease: {releaseAssets.Prerelease}");
foreach (var file in releaseAssets.Assets)
{
Serilog.Log.Information($"File: {file}");
}
}
}

public interface ILocalAssetRelease : IClean, ICompile, IHazAssetRelease
{
Target LocalAssetRelease => _ => _
.TriggeredBy(Clean)
.Before(Compile)
.Executes(() =>
{
var releaseAssets = new ReleaseAssets
{
Project = MainProject,
Version = "0.0.0",
Notes = "Release Notes",
};
ReleaseAsset(releaseAssets);
});
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Enable `IAssetRelease` to release assets before `GitRelease` and `GitPreRelease`.
### Build
- Add `IAzureSignTool` to check if `AzureSignToolUtils` is installed.
- Add `ILocalAssetRelease` to test `AssetRelease` assets before release.
### Updates
- Add version `Information` in the `CommonExtension`.
- Add `AzureSignToolUtils` to sign files using `AzureSignToolTasks` or `NuGetKeyVaultSignToolTasks`.
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.9.0-beta.7</Version>
<Version>1.9.0-beta.8</Version>
</PropertyGroup>
</Project>
8 changes: 4 additions & 4 deletions ricaun.Nuke/Components/IAssetRelease.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Nuke.Common.IO;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using ricaun.Nuke.IO;
using System.Collections.Generic;

namespace ricaun.Nuke.Components
{
Expand All @@ -28,7 +28,7 @@ public class ReleaseAssets
/// <summary>
/// Gets the collection of zip files to be released.
/// </summary>
public IReadOnlyCollection<AbsolutePath> Files { get; init; }
public AbsolutePath[] Assets { get; init; } = new AbsolutePath[] { };

/// <summary>
/// Gets a value indicating whether the release is a prerelease.
Expand All @@ -54,7 +54,7 @@ public void ReleaseAsset(ReleaseAssets releaseAssets)
{
if (AssetRelease is IAssetRelease assetRelease)
{
Serilog.Log.Information($"Asset Release {assetRelease}");
Serilog.Log.Information($"ReleaseAsset: {assetRelease}");
assetRelease.ReleaseAsset(releaseAssets);
}
}
Expand Down
3 changes: 2 additions & 1 deletion ricaun.Nuke/Components/IGitRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using ricaun.Nuke.Extensions;
using System;
using System.IO;
using System.Linq;

namespace ricaun.Nuke.Components
{
Expand Down Expand Up @@ -80,7 +81,7 @@ void ReleaseGitHubProject(Project project, bool releaseAsPrerelease = false)
Project = project,
Version = version,
Notes = releaseNotes,
Files = releaseFiles,
Assets = releaseFiles.ToArray(),
Prerelease = releaseAsPrerelease
};

Expand Down

0 comments on commit b9814b7

Please sign in to comment.