Skip to content

Commit

Permalink
Generating CI file now for Github.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmwebb-lv committed Apr 19, 2024
1 parent a0b9f2f commit 24362d8
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 29 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# ------------------------------------------------------------------------------
# <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 --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: ci

on:
push:
paths:
- 'Src/**'
- 'Build/**'
pull_request:
branches:
- main

jobs:
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
- name: 'Run: Compile, Pack, Push'
run: ./build.cmd Compile Pack Push
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
2 changes: 2 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"Pack",
"Print",
"Print_Net_SDK",
"Push",
"Restore"
]
}
Expand All @@ -106,6 +107,7 @@
"Pack",
"Print",
"Print_Net_SDK",
"Push",
"Restore"
]
}
Expand Down
3 changes: 2 additions & 1 deletion .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "./build.schema.json",
"Solution": "Src/RCommon.sln"
"Solution": "Src/RCommon.sln",
"Configuration": "Release"
}
56 changes: 28 additions & 28 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using GlobExpressions;
using Microsoft.Build.Evaluation;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitHubActions;
Expand All @@ -20,17 +21,16 @@
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;

[GitHubActions(
"continuous",
[GitHubActions("ci",
GitHubActionsImage.UbuntuLatest,
On = new[] { GitHubActionsTrigger.Push },
InvokedTargets = new[] { nameof(Compile) },
InvokedTargets = new[] { nameof(Compile), nameof(Pack), nameof(Push) },
OnPushIncludePaths = new[] {
"Src/**",
"Build/**"
},
OnPushBranches = new[] { "main" },
AutoGenerate = false)]
OnPullRequestBranches = new[] { "main" },
AutoGenerate = true,
ImportSecrets = new[] {"NuGetApiKey"})]
[ShutdownDotNetAfterServerBuild]
class Build : NukeBuild
{
Expand All @@ -40,7 +40,7 @@ class Build : NukeBuild
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode

public static int Main () => Execute<Build>(x => x.Compile, x => x.Pack);
public static int Main () => Execute<Build>(build => build.Compile, build => build.Pack, build => build.Push);

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
Expand Down Expand Up @@ -102,7 +102,7 @@ protected override void OnBuildInitialized()
{
Log.Information("Cleaning solution");
Directory_Src.GlobDirectories("**/bin", "**/obj")
.ForEach(DeleteDirectory);
.ForEach(x => x.DeleteDirectory());
});

Target Restore => _ => _
Expand Down Expand Up @@ -468,26 +468,26 @@ protected override void OnBuildInitialized()
});


//Target Push => _ => _
// //.DependsOn(Pack)
// .Requires(() => NuGetApiUrl)
// .Requires(() => NuGetApiKey)
// .Requires(() => Configuration.Equals(Configuration.Release))
// .Executes(() =>
// {
// Glob.Files(Directory_NuGet, "*.nupkg")
// .NotEmpty()
// .Where(x => !x.EndsWith("symbols.nupkg"))
// .ForEach(x =>
// {
// DotNetTasks
// .DotNetNuGetPush(s => s
// .SetTargetPath(x)
// .SetSource(NuGetApiUrl)
// .SetApiKey(NuGetApiKey)
// );
// });
// });
Target Push => _ => _
.DependsOn(Pack)
.Requires(() => NuGetApiUrl)
.Requires(() => NuGetApiKey)
.Requires(() => Configuration.Equals(Configuration.Release))
.Executes(() =>
{
Assert.NotNull(Glob.Files(Directory_NuGet, "*.nupkg", GlobOptions.MatchFullPath))
.Where(x => !x.EndsWith("symbols.nupkg"))
.ForEach(file =>
{
Log.Information("Pushing nuget from path: {0}", Directory_NuGet/file);
DotNetTasks
.DotNetNuGetPush(s => s
.SetTargetPath(Directory_NuGet/file)
.SetSource(NuGetApiUrl)
.SetApiKey(NuGetApiKey)
);
});
});

//Target CreateRelease => _ => _
// .DependsOn(Pack)
Expand Down
24 changes: 24 additions & 0 deletions Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,28 @@
<PackageDownload Include="GitVersion.Tool" Version="[5.12.0]" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-16-52.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-36-15.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-42-12.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-51-19.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-52-29.log" />
</ItemGroup>

<ItemGroup>
<None Remove="..\.nuke\temp\build.2024-04-18_22-53-22.log" />
</ItemGroup>

</Project>

0 comments on commit 24362d8

Please sign in to comment.