Skip to content

Commit c19ca7f

Browse files
committed
Add workflow
1 parent 7a32f9f commit c19ca7f

11 files changed

Lines changed: 298 additions & 28 deletions

.github/workflows/continuous.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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_continuous --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: continuous
18+
19+
on: [push]
20+
21+
jobs:
22+
ubuntu-latest:
23+
name: ubuntu-latest
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
30+
uses: actions/cache@v4
31+
with:
32+
path: |
33+
.nuke/temp
34+
~/.nuget/packages
35+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
36+
- name: 'Run: Compile, Pack'
37+
run: ./build.cmd Compile Pack
38+
- name: 'Publish: packages'
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: packages
42+
path: artifacts/packages

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
- '\d+\.\d+\.\d+'
23+
24+
jobs:
25+
ubuntu-latest:
26+
name: ubuntu-latest
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
.nuke/temp
37+
~/.nuget/packages
38+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
39+
- name: 'Run: Push, PushGithubNuget'
40+
run: ./build.cmd Push PushGithubNuget
41+
env:
42+
NugetKey: ${{ secrets.NUGET_KEY }}
43+
GithubToken: ${{ secrets.GITHUB_TOKEN }}
44+
- name: 'Publish: packages'
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: packages
48+
path: artifacts/packages

.nuke/build.schema.json

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"properties": {
4+
"Configuration": {
5+
"type": "string",
6+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
7+
"enum": [
8+
"Debug",
9+
"Release"
10+
]
11+
},
12+
"GithubToken": {
13+
"type": "string",
14+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
15+
},
16+
"NugetApiUrl": {
17+
"type": "string"
18+
},
19+
"NugetKey": {
20+
"type": "string",
21+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
22+
},
23+
"Solution": {
24+
"type": "string",
25+
"description": "Path to a solution file that is automatically loaded"
26+
}
27+
},
28+
"definitions": {
29+
"Host": {
30+
"type": "string",
31+
"enum": [
32+
"AppVeyor",
33+
"AzurePipelines",
34+
"Bamboo",
35+
"Bitbucket",
36+
"Bitrise",
37+
"GitHubActions",
38+
"GitLab",
39+
"Jenkins",
40+
"Rider",
41+
"SpaceAutomation",
42+
"TeamCity",
43+
"Terminal",
44+
"TravisCI",
45+
"VisualStudio",
46+
"VSCode"
47+
]
48+
},
49+
"ExecutableTarget": {
50+
"type": "string",
51+
"enum": [
52+
"Clean",
53+
"Compile",
54+
"Pack",
55+
"Push",
56+
"PushGithubNuget",
57+
"Restore",
58+
"VerifyFormat"
59+
]
60+
},
61+
"Verbosity": {
62+
"type": "string",
63+
"description": "",
64+
"enum": [
65+
"Verbose",
66+
"Normal",
67+
"Minimal",
68+
"Quiet"
69+
]
70+
},
71+
"NukeBuild": {
72+
"properties": {
73+
"Continue": {
74+
"type": "boolean",
75+
"description": "Indicates to continue a previously failed build attempt"
76+
},
77+
"Help": {
78+
"type": "boolean",
79+
"description": "Shows the help text for this build assembly"
80+
},
81+
"Host": {
82+
"description": "Host for execution. Default is 'automatic'",
83+
"$ref": "#/definitions/Host"
84+
},
85+
"NoLogo": {
86+
"type": "boolean",
87+
"description": "Disables displaying the NUKE logo"
88+
},
89+
"Partition": {
90+
"type": "string",
91+
"description": "Partition to use on CI"
92+
},
93+
"Plan": {
94+
"type": "boolean",
95+
"description": "Shows the execution plan (HTML)"
96+
},
97+
"Profile": {
98+
"type": "array",
99+
"description": "Defines the profiles to load",
100+
"items": {
101+
"type": "string"
102+
}
103+
},
104+
"Root": {
105+
"type": "string",
106+
"description": "Root directory during build execution"
107+
},
108+
"Skip": {
109+
"type": "array",
110+
"description": "List of targets to be skipped. Empty list skips all dependencies",
111+
"items": {
112+
"$ref": "#/definitions/ExecutableTarget"
113+
}
114+
},
115+
"Target": {
116+
"type": "array",
117+
"description": "List of targets to be invoked. Default is '{default_target}'",
118+
"items": {
119+
"$ref": "#/definitions/ExecutableTarget"
120+
}
121+
},
122+
"Verbosity": {
123+
"description": "Logging verbosity during build execution. Default is 'Normal'",
124+
"$ref": "#/definitions/Verbosity"
125+
}
126+
}
127+
}
128+
},
129+
"$ref": "#/definitions/NukeBuild"
130+
}

build/Build.cs

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
"continuous",
2222
GitHubActionsImage.UbuntuLatest,
2323
FetchDepth = 0,
24-
On = new[] { GitHubActionsTrigger.Push },
24+
On = [GitHubActionsTrigger.Push],
2525
PublishArtifacts = true,
26-
InvokedTargets = new[] { nameof(Compile), nameof(Pack) })]
26+
InvokedTargets = [nameof(Compile), nameof(Pack)])]
2727
[GitHubActions(
2828
"release",
2929
GitHubActionsImage.UbuntuLatest,
3030
FetchDepth = 0,
31-
OnPushTags = new[] { @"\d+\.\d+\.\d+" },
31+
OnPushTags = [@"\d+\.\d+\.\d+"],
3232
PublishArtifacts = true,
33-
InvokedTargets = new[] { nameof(Push), nameof(PushGithubNuget) },
34-
ImportSecrets = new[] { nameof(NuGetApiKey), nameof(PersonalAccessToken) })]
33+
InvokedTargets = [nameof(Push), nameof(PushGithubNuget)],
34+
ImportSecrets = [nameof(NugetKey), nameof(GithubToken)])]
3535
class Build : NukeBuild
3636
{
3737
/// Support plugins are available for:
@@ -40,19 +40,19 @@ class Build : NukeBuild
4040
/// - Microsoft VisualStudio https://nuke.build/visualstudio
4141
/// - Microsoft VSCode https://nuke.build/vscode
4242

43-
public static int Main () => Execute<Build>(x => x.Compile);
43+
public static int Main() => Execute<Build>(x => x.Compile);
4444

4545
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
4646
readonly Configuration Configuration = Configuration.Release;
4747

48+
[Parameter] readonly string NugetApiUrl = "https://api.nuget.org/v3/index.json"; //default
49+
[Parameter][Secret] readonly string NugetKey;
50+
[Parameter][Secret] readonly string GithubToken;
4851

49-
[Parameter] string NugetApiUrl = "https://api.nuget.org/v3/index.json"; //default
52+
bool RunFormatAnalyzers => false;
5053

5154
bool IsTag => GitHubActions.Instance?.Ref?.StartsWith("refs/tags/") ?? false;
5255

53-
[Parameter][Secret] readonly string NuGetApiKey;
54-
[Parameter][Secret] readonly string PersonalAccessToken;
55-
5656
[Solution] readonly Solution Solution;
5757
[GitRepository] readonly GitRepository GitRepository;
5858

@@ -78,8 +78,23 @@ class Build : NukeBuild
7878
.SetProjectFile(Solution));
7979
});
8080

81+
Target VerifyFormat => _ => _
82+
.After(Restore)
83+
.Description("Verify code formatting for the solution.")
84+
.Executes(() =>
85+
{
86+
DotNet($"format whitespace {Solution.Path} --verify-no-changes ");
87+
88+
DotNet($"format style {Solution.Path} --verify-no-changes ");
89+
90+
if (RunFormatAnalyzers)
91+
{
92+
DotNet($"format analyzers {Solution.Path} --verify-no-changes ");
93+
}
94+
});
95+
8196
Target Compile => _ => _
82-
.DependsOn(Restore)
97+
.DependsOn(Restore, VerifyFormat)
8398
.Executes(() =>
8499
{
85100
DotNetBuild(s => s
@@ -93,7 +108,8 @@ class Build : NukeBuild
93108
.Produces(PackagesDirectory / "*.nupkg")
94109
.Produces(PackagesDirectory / "*.snupkg")
95110
.Requires(() => Configuration.Equals(Configuration.Release))
96-
.Executes(() => {
111+
.Executes(() =>
112+
{
97113
DotNetPack(_ => _
98114
.Apply(PackSettings));
99115

@@ -104,13 +120,13 @@ class Build : NukeBuild
104120
Target Push => _ => _
105121
.DependsOn(Pack)
106122
.OnlyWhenStatic(() => IsTag && IsServerBuild)
107-
.Requires(() => NuGetApiKey)
123+
.Requires(() => NugetKey)
108124
.Requires(() => Configuration.Equals(Configuration.Release))
109125
.Executes(() =>
110126
{
111127
Log.Information("Running push to packages directory.");
112128

113-
Assert.True(!string.IsNullOrEmpty(NuGetApiKey));
129+
Assert.True(!string.IsNullOrEmpty(NugetKey));
114130

115131
PackagesDirectory.GlobFiles("*.nupkg")
116132
.ForEach(x =>
@@ -120,7 +136,7 @@ class Build : NukeBuild
120136
DotNetNuGetPush(s => s
121137
.SetTargetPath(x)
122138
.SetSource(NugetApiUrl)
123-
.SetApiKey(NuGetApiKey)
139+
.SetApiKey(NugetKey)
124140
.EnableSkipDuplicate()
125141
);
126142
});
@@ -130,7 +146,7 @@ class Build : NukeBuild
130146
Target PushGithubNuget => _ => _
131147
.DependsOn(Pack)
132148
.OnlyWhenStatic(() => IsTag && IsServerBuild)
133-
.Requires(() => PersonalAccessToken)
149+
.Requires(() => GithubToken)
134150
.Requires(() => Configuration.Equals(Configuration.Release))
135151
.Executes(() =>
136152
{
@@ -141,12 +157,12 @@ class Build : NukeBuild
141157
{
142158
x.NotNull();
143159

144-
Assert.True(!string.IsNullOrEmpty(PersonalAccessToken));
160+
Assert.True(!string.IsNullOrEmpty(GithubToken));
145161

146162
DotNetNuGetPush(s => s
147163
.SetTargetPath(x)
148164
.SetSource($"https://nuget.pkg.github.com/{GitHubActions.Instance.RepositoryOwner}/index.json")
149-
.SetApiKey(PersonalAccessToken)
165+
.SetApiKey(GithubToken)
150166
.EnableSkipDuplicate()
151167
);
152168
});

src/Scarlet.System.Text.Json.DateTimeConverter/Converters/DateTimeConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Scarlet.System.Text.Json.DateTimeConverter.Converters;
77
/// <summary>
88
/// Converts <see cref="DateTime"/> objects to and from JSON using a specified date format.
99
/// </summary>
10-
internal class DateTimeConverter : JsonConverter<DateTime>
10+
internal sealed class DateTimeConverter : JsonConverter<DateTime>
1111
{
1212
private readonly string _format;
1313

src/Scarlet.System.Text.Json.DateTimeConverter/Converters/DateTimeNullableConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Scarlet.System.Text.Json.DateTimeConverter.Converters;
77
/// <summary>
88
/// Converts nullable <see cref="DateTime"/> objects to and from JSON using a specified date format.
99
/// </summary>
10-
internal class DateTimeNullableConverter : JsonConverter<DateTime?>
10+
internal sealed class DateTimeNullableConverter : JsonConverter<DateTime?>
1111
{
1212
private readonly string _format;
1313

src/Scarlet.System.Text.Json.DateTimeConverter/Converters/DateTimeOffsetConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Scarlet.System.Text.Json.DateTimeConverter.Converters;
77
/// <summary>
88
/// Converts <see cref="DateTimeOffsetConverter"/> objects to and from JSON using a specified date format.
99
/// </summary>
10-
internal class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
10+
internal sealed class DateTimeOffsetConverter : JsonConverter<DateTimeOffset>
1111
{
1212
private readonly string _format;
1313

src/Scarlet.System.Text.Json.DateTimeConverter/Converters/DateTimeOffsetNullableConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace Scarlet.System.Text.Json.DateTimeConverter.Converters;
77
/// <summary>
88
/// Converts nullable <see cref="DateTimeOffset"/> objects to and from JSON using a specified date format.
99
/// </summary>
10-
internal class DateTimeOffsetNullableConverter : JsonConverter<DateTimeOffset?>
10+
internal sealed class DateTimeOffsetNullableConverter : JsonConverter<DateTimeOffset?>
1111
{
1212
private readonly string _format;
1313

0 commit comments

Comments
 (0)