Setup release 2.5.0 with automated build and pre-releases

This commit is contained in:
Keivn Sommer 2021-05-15 01:13:47 +02:00
parent 20c264be58
commit 7ced211758
5 changed files with 79 additions and 12 deletions

View File

@ -17,12 +17,10 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master
- 'releases/*'
jobs:
ubuntu-latest:

33
.github/workflows/ci_publish.yml vendored Normal file
View File

@ -0,0 +1,33 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_ci_publish --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------
name: ci_publish
on:
push:
branches:
- 'releases/*'
jobs:
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run './build.cmd CiPublish'
run: ./build.cmd CiPublish
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

View File

@ -43,6 +43,9 @@
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NUGET_API_KEY": {
"type": "string"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
@ -65,9 +68,11 @@
"type": "string",
"enum": [
"Ci",
"CiPublish",
"Clean",
"Compile",
"Package",
"Publish",
"Restore",
"Test"
]
@ -84,9 +89,11 @@
"type": "string",
"enum": [
"Ci",
"CiPublish",
"Clean",
"Compile",
"Package",
"Publish",
"Restore",
"Test"
]

View File

@ -0,0 +1,3 @@
branches:
release:
mode: ContinuousDeployment

View File

@ -1,4 +1,5 @@
using System.Linq;
using GlobExpressions;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitHubActions;
@ -8,17 +9,23 @@ using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
[CheckBuildProjectConfigurations]
[ShutdownDotNetAfterServerBuild]
[GitHubActions("ci", GitHubActionsImage.UbuntuLatest,
OnPushBranches = new[] {"master"},
OnPullRequestBranches = new[] {"master"},
OnPullRequestBranches = new[] {"master", "releases/*"},
AutoGenerate = true,
InvokedTargets = new[] {nameof(Ci)},
CacheKeyFiles = new string[0])]
[GitHubActions("ci_publish", GitHubActionsImage.UbuntuLatest,
OnPushBranches = new[] {"releases/*"},
AutoGenerate = true,
InvokedTargets = new[] {nameof(CiPublish)},
CacheKeyFiles = new string[0],
ImportSecrets = new[] {"NUGET_API_KEY"})]
class Build : NukeBuild
{
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
@ -30,6 +37,9 @@ class Build : NukeBuild
[Solution] readonly Solution Solution;
// ReSharper disable once InconsistentNaming
[Parameter] string NUGET_API_KEY;
Project SieveProject => Solution.AllProjects.First(p => p.Name == "Sieve");
AbsolutePath OutputDirectory => RootDirectory / "output";
@ -83,13 +93,29 @@ class Build : NukeBuild
.EnableNoBuild());
});
Target Ci => _ => _
.DependsOn(Package);
Target Publish => _ => _
.DependsOn(Package)
.Requires(() => IsServerBuild)
.Requires(() => NUGET_API_KEY)
.Requires(() => Configuration.Equals(Configuration.Release))
.Executes(() =>
{
Glob.Files(OutputDirectory, "*.nupkg")
.NotEmpty()
.ForEach(x =>
{
DotNetNuGetPush(s => s
.SetTargetPath(OutputDirectory / x)
.SetSource("https://api.nuget.org/v3/index.json")
.SetApiKey(NUGET_API_KEY));
});
});
Target Ci => _ => _
.DependsOn(Test);
Target CiPublish => _ => _
.DependsOn(Publish);
/// 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
public static int Main() => Execute<Build>(x => x.Package);
}