Skip to content

Commit 28c6c6a

Browse files
authored
Merge pull request #11 from rafek1241/feature/ugrade-workflows
Feature/ugrade workflows
2 parents 278f074 + 48816ba commit 28c6c6a

File tree

3 files changed

+131
-159
lines changed

3 files changed

+131
-159
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_continous-integration --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: continous-integration
18+
19+
on:
20+
push:
21+
branches:
22+
- master
23+
pull_request:
24+
branches:
25+
- *
26+
27+
jobs:
28+
ubuntu-latest:
29+
name: ubuntu-latest
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v1
33+
- name: Run './build.cmd ContinousIntegration'
34+
run: ./build.cmd ContinousIntegration
35+
env:
36+
NugetApiKey: ${{ secrets.NugetApiKey }}

.github/workflows/dotnet.yml

Lines changed: 0 additions & 138 deletions
This file was deleted.

build/Build.cs

Lines changed: 95 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Linq;
33
using Nuke.Common;
44
using Nuke.Common.CI;
5+
using Nuke.Common.CI.GitHubActions;
56
using Nuke.Common.Execution;
67
using Nuke.Common.Git;
78
using Nuke.Common.IO;
@@ -17,54 +18,127 @@
1718

1819
[CheckBuildProjectConfigurations]
1920
[ShutdownDotNetAfterServerBuild]
21+
[GitHubActions("continous-integration",
22+
GitHubActionsImage.UbuntuLatest,
23+
AutoGenerate = true,
24+
OnPushBranches = new[] { "master" },
25+
OnPullRequestBranches= new[] { "*" },
26+
InvokedTargets = new[] { nameof(ContinousIntegration) },
27+
ImportSecrets = new[] { nameof(NugetApiKey) }
28+
)]
2029
class Build : NukeBuild
2130
{
2231
/// Support plugins are available for:
2332
/// - JetBrains ReSharper https://nuke.build/resharper
2433
/// - JetBrains Rider https://nuke.build/rider
2534
/// - Microsoft VisualStudio https://nuke.build/visualstudio
2635
/// - Microsoft VSCode https://nuke.build/vscode
27-
28-
public static int Main () => Execute<Build>(x => x.Compile);
36+
public static int Main() => Execute<Build>(x => x.Compile);
2937

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

41+
[Parameter] string NugetApiUrl = "https://api.nuget.org/v3/index.json"; //default
42+
[Parameter] string NugetApiKey;
43+
3344
[Solution] readonly Solution Solution;
3445
[GitRepository] readonly GitRepository GitRepository;
3546
[GitVersion(Framework = "netcoreapp3.1")] readonly GitVersion GitVersion;
3647

3748
AbsolutePath SourceDirectory => RootDirectory / "src";
3849
AbsolutePath TestsDirectory => RootDirectory / "tests";
3950
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
51+
AbsolutePath NugetDestinationDirectory => ArtifactsDirectory / "nuget";
52+
AbsolutePath TestsResultDirectory => ArtifactsDirectory / "tests";
4053

4154
Target Clean => _ => _
4255
.Before(Restore)
4356
.Executes(() =>
44-
{
45-
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
46-
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
47-
EnsureCleanDirectory(ArtifactsDirectory);
48-
});
57+
{
58+
SourceDirectory.GlobDirectories("**/bin", "**/obj")
59+
.ForEach(DeleteDirectory);
60+
TestsDirectory.GlobDirectories("**/bin", "**/obj")
61+
.ForEach(DeleteDirectory);
62+
EnsureCleanDirectory(ArtifactsDirectory);
63+
}
64+
);
4965

5066
Target Restore => _ => _
5167
.Executes(() =>
52-
{
53-
DotNetRestore(s => s
54-
.SetProjectFile(Solution));
55-
});
68+
{
69+
DotNetRestore(s => s
70+
.SetProjectFile(Solution)
71+
);
72+
}
73+
);
5674

5775
Target Compile => _ => _
5876
.DependsOn(Restore)
5977
.Executes(() =>
60-
{
61-
DotNetBuild(s => s
62-
.SetProjectFile(Solution)
63-
.SetConfiguration(Configuration)
64-
.SetAssemblyVersion(GitVersion.AssemblySemVer)
65-
.SetFileVersion(GitVersion.AssemblySemFileVer)
66-
.SetInformationalVersion(GitVersion.InformationalVersion)
67-
.EnableNoRestore());
68-
});
78+
{
79+
DotNetBuild(s => s
80+
.SetProjectFile(Solution)
81+
.SetConfiguration(Configuration)
82+
.SetAssemblyVersion(GitVersion.AssemblySemVer)
83+
.SetFileVersion(GitVersion.AssemblySemFileVer)
84+
.SetInformationalVersion(GitVersion.InformationalVersion)
85+
.EnableNoRestore()
86+
);
87+
}
88+
);
89+
90+
Target Test => _ => _
91+
.DependsOn(Compile)
92+
.Executes(() =>
93+
{
94+
DotNetTest(s => s
95+
.SetProjectFile(TestsDirectory)
96+
.SetConfiguration(Configuration)
97+
.EnableNoBuild()
98+
.EnableNoRestore()
99+
.SetResultsDirectory(TestsResultDirectory)
100+
);
101+
}
102+
);
103+
104+
Target Pack => _ => _
105+
.DependsOn(Compile)
106+
.Executes(() =>
107+
{
108+
DotNetPack(s => s
109+
.SetProject(Solution)
110+
.SetConfiguration(Configuration)
111+
.EnableNoBuild()
112+
.EnableNoRestore()
113+
.SetVersion(GitVersion.NuGetVersionV2)
114+
.SetOutputDirectory(NugetDestinationDirectory)
115+
);
116+
}
117+
);
118+
119+
Target Deploy => _ => _
120+
.DependsOn(Pack)
121+
.OnlyWhenStatic(() => GitRepository.Branch == "refs/heads/master")
122+
.Requires(() => NugetApiUrl)
123+
.Requires(() => NugetApiKey)
124+
.Requires(() => Configuration.Equals(Configuration.Release))
125+
.Executes(() =>
126+
{
127+
GlobFiles(NugetDestinationDirectory, "*.nupkg")
128+
.NotEmpty()
129+
.Where(x => !x.EndsWith("symbols.nupkg"))
130+
.ForEach(x =>
131+
{
132+
DotNetNuGetPush(s => s
133+
.SetSource(NugetApiUrl)
134+
.SetApiKey(NugetApiKey)
135+
.SetSkipDuplicate(true)
136+
);
137+
}
138+
);
139+
}
140+
);
69141

70-
}
142+
Target ContinousIntegration => _ => _
143+
.DependsOn(Deploy);
144+
}

0 commit comments

Comments
 (0)