Skip to content

Commit 6feed9c

Browse files
committed
Merge branch 'main' into develop
# Conflicts: # .github/workflows/Compile.yml
2 parents a56dfca + 28dab1f commit 6feed9c

29 files changed

Lines changed: 289 additions & 275 deletions

.github/workflows/Compile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414

1515
- name: Checkout
1616
uses: actions/checkout@v5
17+
18+
- name: Setup .NET 10.0.x SDK
19+
uses: actions/setup-dotnet@v5
20+
with:
21+
dotnet-version: 10.0.x
1722

1823
- name: Cache NuGet
1924
uses: actions/cache@v4

.github/workflows/Publish Release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ jobs:
1414
- name: Checkout
1515
uses: actions/checkout@v5
1616

17+
- name: Setup .NET 10.0.x SDK
18+
uses: actions/setup-dotnet@v5
19+
with:
20+
dotnet-version: 10.0.x
21+
1722
- name: Cache NuGet
1823
uses: actions/cache@v4
1924
with:

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<Nullable>enable</Nullable>
5+
<LangVersion>latest</LangVersion>
6+
<ImplicitUsings>true</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
</Project>

build/Build.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<Nullable>enable</Nullable>
54
<OutputType>Exe</OutputType>
6-
<LangVersion>latest</LangVersion>
7-
<ImplicitUsings>true</ImplicitUsings>
8-
<TargetFramework>net10.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
96
</PropertyGroup>
107

118
<ItemGroup>

build/Modules/CreateGitHubChangelogModule.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
using System.Text;
2-
using ModularPipelines.Context;
3-
using ModularPipelines.Modules;
2+
using Build.Options;
3+
using Microsoft.Extensions.Options;
44
using ModularPipelines.Attributes;
5-
using ModularPipelines.Git.Extensions;
6-
using ModularPipelines.Git.Options;
5+
using ModularPipelines.Context;
76
using ModularPipelines.GitHub.Extensions;
7+
using ModularPipelines.Modules;
88

99
namespace Build.Modules;
1010

1111
[DependsOn<CreateChangelogModule>]
12-
public sealed class CreateGitHubChangelogModule : Module<string>
12+
public sealed class CreateGitHubChangelogModule(IOptions<BuildOptions> buildOptions) : Module<string>
1313
{
1414
protected override async Task<string?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
1515
{
@@ -19,24 +19,15 @@ public sealed class CreateGitHubChangelogModule : Module<string>
1919
return changelog.ToString();
2020
}
2121

22-
private static async Task<StringBuilder> AppendGitHubCompareUrlAsync(IPipelineContext context, StringBuilder changelog)
22+
private async Task<StringBuilder> AppendGitHubCompareUrlAsync(IPipelineContext context, StringBuilder changelog)
2323
{
24-
var tagCommand = await context.Git().Commands.Tag(new GitTagOptions
25-
{
26-
List = true,
27-
Sort = "v:refname"
28-
});
29-
30-
var tags = tagCommand.StandardOutput.Split(Environment.NewLine);
31-
if (tags.Length < 2) return changelog;
32-
33-
var repositoryName = context.GitHub().RepositoryInfo.Identifier;
34-
var previousTag = tags[^2];
35-
var latestTag = tags[^1];
24+
var repositoryInfo = context.GitHub().RepositoryInfo;
25+
var repositoryId = long.Parse(context.GitHub().EnvironmentVariables.RepositoryId!);
26+
var latestRelease = await context.GitHub().Client.Repository.Release.GetLatest(repositoryId);
3627

3728
if (changelog[^1] != '\r' || changelog[^1] != '\n') changelog.AppendLine(Environment.NewLine);
3829
changelog.Append("Full changelog: ");
39-
changelog.Append($"https://github.com/{repositoryName}/compare/{previousTag}...{latestTag}");
30+
changelog.Append($"https://github.com/{repositoryInfo.Identifier}/compare/{latestRelease.TagName}...{buildOptions.Value.Version}");
4031

4132
return changelog;
4233
}

build/Modules/PackProjectsModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Build.Modules;
1616
[DependsOn<CreatePackageReadmeModule>]
1717
[DependsOn<CreatePackageChangelogModule>]
1818
[DependsOn<ParseSolutionConfigurationsModule>]
19-
public sealed class PackProjectsModule(IOptions<BuildOptions> buildOptions,IOptions<PackOptions> packOptions) : Module
19+
public sealed class PackProjectsModule(IOptions<BuildOptions> buildOptions, IOptions<PackOptions> packOptions) : Module
2020
{
2121
protected override async Task<IDictionary<string, object>?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
2222
{
@@ -26,7 +26,7 @@ public sealed class PackProjectsModule(IOptions<BuildOptions> buildOptions,IOpti
2626

2727
foreach (var configuration in configurations.Value!)
2828
{
29-
await SubModule(configuration, async () => await PackAsync(context, configuration, outputFolder, changelog.Value!, cancellationToken));
29+
await SubModule(configuration, async () => await PackAsync(context, configuration, outputFolder.Path, changelog.Value!, cancellationToken));
3030
}
3131

3232
return await NothingAsync();

build/Modules/ParseSolutionConfigurationsModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class ParseSolutionConfigurationsModule(IOptions<BuildOptions> bui
2020
.Where(configuration => FileSystemName.MatchesSimpleExpression(buildOptions.Value.ConfigurationFilter, configuration))
2121
.ToArray();
2222

23-
configurations.Length.ShouldBePositive("No solution configurations have been found");
23+
configurations.ShouldNotBeEmpty("No solution configurations have been found");
2424

2525
return configurations;
2626
}
@@ -33,7 +33,7 @@ private static async Task<SolutionModel> LoadSolutionModelAsync(IPipelineContext
3333
return await SolutionSerializers.SlnXml.OpenAsync(solution.GetStream(), cancellationToken);
3434
}
3535

36-
context.Logger.LogInformation("Solution file not found. Trying to find fallback .sln");
36+
context.Logger.LogInformation("Solution .slnx file not found. Trying to find fallback .sln");
3737

3838
solution = context.Git().RootDirectory.FindFile(file => file.Extension == ".sln");
3939
solution.ShouldNotBeNull("Solution file not found.");

build/Modules/PublishGithubModule.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ public sealed class PublishGithubModule(IOptions<BuildOptions> buildOptions, IOp
2424
var changelog = await GetModule<CreateGitHubChangelogModule>();
2525
var outputFolder = context.Git().RootDirectory.GetFolder(packOptions.Value.OutputDirectory);
2626
var targetFiles = outputFolder.ListFiles().ToArray();
27-
targetFiles.Length.ShouldBePositive("No artifacts were found to create the Release");
27+
targetFiles.ShouldNotBeEmpty("No artifacts were found to create the Release");
2828

2929
var repositoryInfo = context.GitHub().RepositoryInfo;
3030
var newRelease = new NewRelease(buildOptions.Value.Version)
3131
{
3232
Name = buildOptions.Value.Version,
3333
Body = changelog.Value,
3434
TargetCommitish = context.Git().Information.LastCommitSha,
35-
Prerelease = buildOptions.Value.Version.Contains("preview")
35+
Prerelease = buildOptions.Value.Version.Contains('-')
3636
};
37+
3738
var release = await context.GitHub().Client.Repository.Release.Create(repositoryInfo.Owner, repositoryInfo.RepositoryName, newRelease);
3839
return await targetFiles
3940
.SelectAsync(async file =>

build/Modules/PublishNugetModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public sealed class PublishNugetModule(IOptions<PackOptions> packOptions, IOptio
1919
{
2020
var outputFolder = context.Git().RootDirectory.GetFolder(packOptions.Value.OutputDirectory);
2121
var targetPackages = outputFolder.GetFiles(file => file.Extension == ".nupkg").ToArray();
22-
targetPackages.Length.ShouldBePositive("No NuGet packages were found to publish");
22+
targetPackages.ShouldNotBeEmpty("No NuGet packages were found to publish");
2323

2424
return await targetPackages
2525
.SelectAsync(async file => await context.DotNet().Nuget.Push(new DotNetNugetPushOptions

build/Options/BuildOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace Build.Options;
44

5-
public sealed class BuildOptions
5+
[Serializable]
6+
public sealed record BuildOptions
67
{
78
[Required] public string ConfigurationFilter { get; init; } = null!;
89
[Required] public string Version { get; init; } = null!;

0 commit comments

Comments
 (0)