Skip to content

Commit 11312d6

Browse files
committed
Merge branch 'develop' into main
2 parents e7ca43b + e28d8b2 commit 11312d6

6 files changed

Lines changed: 121 additions & 38 deletions

File tree

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_release --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: release
18+
19+
on:
20+
push:
21+
tags:
22+
- v[0-9]+.[0-9]+.[0-9]+
23+
24+
jobs:
25+
ubuntu-latest:
26+
name: ubuntu-latest
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0
32+
lfs: true
33+
- name: Cache .nuke/temp, ~/.nuget/packages
34+
uses: actions/cache@v3
35+
with:
36+
path: |
37+
.nuke/temp
38+
~/.nuget/packages
39+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
40+
- name: Run './build.cmd Pack'
41+
run: ./build.cmd Pack
42+
env:
43+
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
- name: Test Report
46+
uses: dorny/test-reporter@v1
47+
if: always()
48+
with:
49+
name: Test Report
50+
path: '**/test-results.trx'
51+
reporter: dotnet-trx
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
#
1010
# - To trigger manual generation invoke:
1111
#
12-
# nuke --generate-configuration GitHubActions_build --host GitHubActions
12+
# nuke --generate-configuration GitHubActions_test --host GitHubActions
1313
#
1414
# </auto-generated>
1515
# ------------------------------------------------------------------------------
1616

17-
name: build
17+
name: test
1818

1919
on:
2020
push:
2121
branches:
22-
- main
23-
- develop
22+
- '**'
2423

2524
jobs:
2625
ubuntu-latest:

.nuke/build.schema.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
"enum": [
8080
"Clean",
8181
"Compile",
82+
"Pack",
8283
"Test"
8384
]
8485
}
@@ -95,6 +96,7 @@
9596
"enum": [
9697
"Clean",
9798
"Compile",
99+
"Pack",
98100
"Test"
99101
]
100102
}

VoxReader.UnitTests/VoxReader.UnitTests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="FluentAssertions" Version="5.10.3" />
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
12-
<PackageReference Include="SharpCompress" Version="0.29.0" />
13-
<PackageReference Include="xunit" Version="2.4.1" />
14-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
10+
<PackageReference Include="FluentAssertions" Version="6.8.0" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
12+
<PackageReference Include="SharpCompress" Version="0.32.2" />
13+
<PackageReference Include="xunit" Version="2.4.2" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
<PrivateAssets>all</PrivateAssets>
1717
</PackageReference>
18-
<PackageReference Include="coverlet.collector" Version="1.3.0">
18+
<PackageReference Include="coverlet.collector" Version="3.2.0">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>
2121
</PackageReference>

build/Build.cs

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,48 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
34
using Microsoft.AspNetCore.StaticFiles;
45
using NuGet.Versioning;
56
using Nuke.Common;
67
using Nuke.Common.CI.GitHubActions;
78
using Nuke.Common.Execution;
9+
using Nuke.Common.Git;
810
using Nuke.Common.IO;
911
using Nuke.Common.ProjectModel;
1012
using Nuke.Common.Tooling;
1113
using Nuke.Common.Tools.DotNet;
1214
using Nuke.Common.Tools.GitHub;
15+
using Nuke.Common.Utilities.Collections;
1316
using Octokit;
17+
using Serilog;
1418
using static Nuke.Common.IO.FileSystemTasks;
1519

1620
[GitHubActions(
17-
"build",
21+
"test",
1822
GitHubActionsImage.UbuntuLatest,
1923
AutoGenerate = false,
2024
FetchDepth = 0,
21-
OnPushBranches = new[]{"main", "develop"},
22-
InvokedTargets = new[]{nameof(Test)},
25+
OnPushBranches = new[] { "**" },
26+
InvokedTargets = new[] { nameof(Test) },
2327
EnableGitHubToken = true,
24-
ImportSecrets = new[]{nameof(NuGetApiKey)})]
28+
ImportSecrets = new[] { nameof(NuGetApiKey) })]
29+
[GitHubActions(
30+
"release",
31+
GitHubActionsImage.UbuntuLatest,
32+
AutoGenerate = false,
33+
FetchDepth = 0,
34+
OnPushTags = new[] { "v[0-9]+.[0-9]+.[0-9]+" },
35+
InvokedTargets = new[] { nameof(Pack) },
36+
EnableGitHubToken = true,
37+
ImportSecrets = new[] { nameof(NuGetApiKey) })]
2538
class Build : NukeBuild
2639
{
27-
public static int Main() => Execute<Build>(x => x.Test);
40+
public static int Main() => Execute<Build>(x => x.Pack);
2841

2942
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
3043

3144
// [Parameter] readonly string GitHubAccessToken;
32-
45+
3346
[Parameter("NuGet API Key"), Secret] readonly string NuGetApiKey;
3447

3548
[Solution(GenerateProjects = true)] readonly Solution Solution;
@@ -40,47 +53,44 @@ class Build : NukeBuild
4053

4154
SemanticVersion PackageVersion;
4255

43-
// [Parameter("The branch or tag name on which the build is executed (GitLab)")] readonly string CI_COMMIT_REF_NAME = string.Empty;
44-
45-
// bool IsOnMasterBranch => CI_COMMIT_REF_NAME == "master";
46-
// bool IsOnDevelopBranch => CI_COMMIT_REF_NAME == "develop";
47-
48-
// bool IsOnVersionTag => Helper.IsValidVersionTag(CI_COMMIT_REF_NAME, out SemanticVersion _);
56+
[GitRepository]
57+
readonly GitRepository GitRepository;
4958

5059
Target Clean => _ => _
5160
.Executes(() =>
5261
{
5362
EnsureCleanDirectory(PackOutputPath);
54-
// DotNetTasks.DotNetClean(s => s.SetProject(Solution));
55-
DotNetTasks.DotNetClean();
63+
DotNetTasks.DotNetClean(s => s
64+
.SetProject(Solution));
5665
});
5766

5867
Target Compile => _ => _
5968
.DependsOn(Clean)
6069
.Executes(() =>
6170
{
62-
// DotNetTasks.DotNetBuild(s => s.SetProjectFile(Solution.VoxReader));
63-
DotNetTasks.DotNetBuild(s => s.SetConfiguration(Configuration));
71+
DotNetTasks.DotNetBuild(s => s
72+
.SetProjectFile(Solution)
73+
.SetConfiguration(Configuration));
6474
});
6575

6676
Target Test => _ => _
6777
.DependsOn(Compile)
6878
.Executes(() =>
6979
{
70-
// DotNetTasks.DotNetTest(s => s.SetProcessWorkingDirectory(RootDirectory));
71-
DotNetTasks.DotNetTest(s => s.SetConfiguration(Configuration).SetLoggers("trx;logfilename=test-results.trx"));
80+
DotNetTasks.DotNetTest(s => s
81+
.SetProjectFile(Solution)
82+
.SetConfiguration(Configuration)
83+
.SetLoggers("trx;logfilename=test-results.trx"));
7284
});
7385

74-
// Target ExtractVersionFromTag => _ => _
75-
// .Executes(() =>
76-
// {
77-
// bool success = Helper.IsValidVersionTag(CI_COMMIT_REF_NAME, out PackageVersion);
78-
//
79-
// if (!success)
80-
// Logger.Normal($"Could not extract version from '{CI_COMMIT_REF_NAME}'");
81-
//
82-
// Logger.Info($"Package Version: {PackageVersion.ToString()}");
83-
// });
86+
Target Pack => _ => _
87+
.DependsOn(Test)
88+
.OnlyWhenStatic(() => GitRepository.CurrentCommitHasVersionTag())
89+
// .OnlyWhenStatic(() => Configuration == Configuration.Release)
90+
.Executes(() =>
91+
{
92+
Log.Information("Version: {Version}", GitRepository.GetLatestVersionTag());
93+
});
8494

8595
// Target Pack => _ => _
8696
// .DependsOn(Test)

build/GitRepositoryExtensions.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Linq;
2+
using NuGet.Versioning;
3+
using Nuke.Common.Git;
4+
using Nuke.Common.Utilities.Collections;
5+
6+
public static class GitRepositoryExtensions
7+
{
8+
public static bool CurrentCommitHasVersionTag(this GitRepository gitRepository)
9+
{
10+
var versionTagsOnCurrentCommit = gitRepository.Tags.Select(t => SemanticVersion.TryParse(t.TrimStart('v'), out SemanticVersion v) ? v : null).WhereNotNull();
11+
12+
return versionTagsOnCurrentCommit.Any();
13+
}
14+
15+
public static SemanticVersion GetLatestVersionTag(this GitRepository gitRepository)
16+
{
17+
var versionTagsOnCurrentCommit = gitRepository.Tags.Select(t => SemanticVersion.TryParse(t.TrimStart('v'), out SemanticVersion v) ? v : null).WhereNotNull().OrderByDescending(t => t);
18+
19+
return versionTagsOnCurrentCommit.First();
20+
}
21+
}

0 commit comments

Comments
 (0)