Skip to content

Commit

Permalink
Merge pull request #7 from DavidRogersDev/release/1.2.0
Browse files Browse the repository at this point in the history
Release/1.2.0 ➡️ main
  • Loading branch information
DavidRogersDev authored Jan 27, 2025
2 parents e759c63 + b17fb69 commit 0101901
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 127 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@ on:
- main
- release/**
- develop/**
tags:
- '\d+\.\d+\.\d+'

paths-ignore:
- '**/*.md'
- 'LICENCE'

jobs:
build:
name: Build and Release 🏗️
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
dotnet-version: ['8.0.x']
dotnet-version: ['9.0.x']
steps:
- name: Setup .NET ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
- name: Checkout Code 🛒
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET ${{ matrix.dotnet-version }} 👟👟
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Display dotnet version
- name: Display dotnet version 🆚
run: dotnet --version
- name: Check out Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run nuke
- name: Run nuke 🚀
shell: bash
env:
PackagesNugetApiKey: ${{ secrets.NUGET_API_KEY }}
Expand Down
170 changes: 90 additions & 80 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/build",
"title": "Build Schema",
"definitions": {
"build": {
"type": "object",
"Host": {
"type": "string",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"ExecutableTarget": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Pack",
"Print",
"Push",
"Restore",
"Test"
]
},
"Verbosity": {
"type": "string",
"description": "",
"enum": [
"Verbose",
"Normal",
"Minimal",
"Quiet"
]
},
"NukeBuild": {
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
Expand All @@ -23,47 +54,13 @@
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"IgnoreFailedSources": {
"type": "boolean"
"$ref": "#/definitions/Host"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NugetOrgNugetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NugetOrgNugetApiUrl": {
"type": "string"
},
"PackagesNugetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"PackagesNugetApiUrl": {
"type": "string"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
Expand All @@ -79,9 +76,6 @@
"type": "string"
}
},
"ReleaseNotes": {
"type": "string"
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
Expand All @@ -90,49 +84,65 @@
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Pack",
"Print",
"Push",
"Restore",
"Test"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"Pack",
"Print",
"Push",
"Restore",
"Test"
]
"$ref": "#/definitions/ExecutableTarget"
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"$ref": "#/definitions/Verbosity"
}
}
}
},
"allOf": [
{
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
"Debug",
"Release"
]
},
"IgnoreFailedSources": {
"type": "boolean"
},
"LocalPackOk": {
"type": "boolean"
},
"NugetOrgNugetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"NugetOrgNugetApiUrl": {
"type": "string"
},
"PackagesNugetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"PackagesNugetApiUrl": {
"type": "string"
},
"ReleaseNotes": {
"type": "string"
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
}
}
},
{
"$ref": "#/definitions/NukeBuild"
}
}
]
}
59 changes: 31 additions & 28 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using _build;
using Invariants;
using Nuke.Common;
using Nuke.Common.CI.AzurePipelines;
Expand All @@ -15,22 +16,31 @@

class Build : NukeBuild
{
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
/// - JetBrains Rider https://nuke.build/rider
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
ReleaseGuard _releaseGuard;

public static int Main() => Execute<Build>(b => b.Push);
public static int Main() => IsLocalBuild
? Execute<Build>(t => t.Pack)
: Execute<Build>(t => t.Push);

protected override void OnBuildInitialized()
{
base.OnBuildInitialized();

_releaseGuard = new ReleaseGuard(GitVersion,
new PackagePublishConfig(NugetOrgNugetApiKey, NugetOrgNugetApiUrl),
new PackagePublishConfig(PackagesNugetApiKey, PackagesNugetApiUrl));
}

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


[Solution(GenerateProjects = true)]
readonly Solution Solution;

[Parameter]
readonly bool LocalPackOk;

[Parameter]
readonly bool IgnoreFailedSources;

Expand Down Expand Up @@ -67,7 +77,7 @@ class Build : NukeBuild
Log.Information(LogMessage.PreReleaseLabel, GitVersion?.PreReleaseLabel ?? ProjectValue.NoValue);
Log.Information(LogMessage.Configuration, Configuration?.ToString() ?? ProjectValue.NoValue);

IsPublishableBranch = GitVersion.BranchName.StartsWith(Branch.Release, StringComparison.OrdinalIgnoreCase);

});

Target Clean => _ => _
Expand Down Expand Up @@ -136,6 +146,9 @@ from framework in project.GetTargetFrameworks()

Target Pack => _ => _
.Description(Description.Pack)
.OnlyWhenDynamic(() => LocalPackOk
? _releaseGuard.BuildToBePacked(System.Configuration.OverrideMode.Allow)
: _releaseGuard.BuildToBePacked()) // checked during run.
.DependsOn(Test)
.Executes(() => DotNetPack(s => s
.SetProject(Solution.BusinessValidation)
Expand Down Expand Up @@ -166,7 +179,8 @@ from framework in project.GetTargetFrameworks()
Target Push => _ => _
.Description(Description.Push)
.OnlyWhenStatic(() => IsServerBuild) // checked before the build steps run.
.OnlyWhenDynamic(() => IsPublishableBranch) // checked during run. This variable is set in the Print task.
.OnlyWhenStatic(() => Configuration.Equals(Configuration.Release))
.OnlyWhenDynamic(() => _releaseGuard.BuildToBePacked()) // checked during run.
.Requires(() => NugetOrgNugetApiKey)
.Requires(() => NugetOrgNugetApiUrl)
.Requires(() => PackagesNugetApiKey)
Expand All @@ -178,31 +192,20 @@ from framework in project.GetTargetFrameworks()

Assert.NotEmpty(nugetFiles, LogMessage.NoNugetFiles);

// if it is not a pre-release, publish to Nuget.org
if (string.IsNullOrWhiteSpace(GitVersion.PreReleaseLabel))
PackagePublishConfig record = _releaseGuard.ResolvePublishDestinationDetails();

if (record.HasNoValue)
{
// this publishes to the nuget.org package manager
nugetFiles.Where(filePath => !filePath.Name.EndsWith(FileSystem.Nuget.SymbolsPackages, StringComparison.OrdinalIgnoreCase))
.ForEach(x =>
{
DotNetNuGetPush(s => s
.SetTargetPath(x)
.SetSource(NugetOrgNugetApiUrl)
.SetApiKey(NugetOrgNugetApiKey)
);
});
Log.Information(LogMessage.NothingPushed);
}
else if (GitVersion.PreReleaseLabel.Equals(BuildType.Ci, StringComparison.OrdinalIgnoreCase) ||
GitVersion.PreReleaseLabel.Equals(BuildType.Rc, StringComparison.OrdinalIgnoreCase))
else
{
// this publishes to the github packages package manager
nugetFiles.Where(filePath => !filePath.Name.EndsWith(FileSystem.Nuget.SymbolsPackages))
.ForEach(x =>
nugetFiles.ForEach(x =>
{
DotNetNuGetPush(s => s
.SetTargetPath(x)
.SetSource(PackagesNugetApiUrl)
.SetApiKey(PackagesNugetApiKey)
.SetSource(record.Url)
.SetApiKey(record.Token)
);
});
}
Expand Down
3 changes: 2 additions & 1 deletion build/Invariants/LogMessage.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace Invariants
{
public sealed class LogMessage
public static class LogMessage
{
public const string CleaningBinaryDirectories = "Cleaning binary directories";
public const string Configuration = "Configuration = {Value}";
public const string MajorMinorPatch = "Major Minor Patch = {Value}";
public const string NoNugetFiles = "There are no Nuget files";
public const string NothingPushed = "Nothing pushed";
public const string NugetVersion = "NuGet Version = {Value}";
public const string PreReleaseLabel = "PreReleaseLabel = {Value}";
public const string ReleaseNotes = "Release Notes = {Value}";
Expand Down
Loading

0 comments on commit 0101901

Please sign in to comment.