Skip to content

Commit f884d90

Browse files
committed
👷‍♀️ gen github actions
1 parent 4b907dd commit f884d90

File tree

6 files changed

+121
-14
lines changed

6 files changed

+121
-14
lines changed

.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+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
.nuke/temp
32+
~/.nuget/packages
33+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
34+
- name: 'Run: Publish'
35+
run: ./build.cmd Publish
36+
env:
37+
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
38+
- name: 'Publish: artifacts'
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: artifacts
42+
path: artifacts

.github/workflows/pr.yml

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

.nuke/build.schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"enum": [
2727
"Clean",
2828
"Compile",
29+
"Info",
2930
"Pack",
3031
"Publish",
3132
"Test"
@@ -102,7 +103,7 @@
102103
"allOf": [
103104
{
104105
"properties": {
105-
"NugetApiKey": {
106+
"NuGetApiKey": {
106107
"type": "string",
107108
"description": "NuGet API key - Required for target Publish",
108109
"default": "Secrets must be entered via 'nuke :secrets [profile]'"

Json5.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HostApplicationBuilder", "e
3333
EndProject
3434
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplicationBuilder", "examples\WebApplicationBuilder\WebApplicationBuilder.csproj", "{3CEBF5ED-5382-48E1-9EBE-2E9BE643B802}"
3535
EndProject
36-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{B12F10A0-A3FC-41FA-95BC-BE48DC5E9092}"
37-
EndProject
3836
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "build\Build.csproj", "{B18F53B4-4A1A-4B7F-9BFD-CA136F920F2B}"
3937
EndProject
4038
Global
@@ -78,6 +76,5 @@ Global
7876
{6A90617F-47D5-433D-A5CC-D5E2769A4C6D} = {58D535B0-AE32-4202-8D70-B9206667D248}
7977
{7CAEE71D-8BAA-44EC-B82D-699C43F9F23F} = {58D535B0-AE32-4202-8D70-B9206667D248}
8078
{3CEBF5ED-5382-48E1-9EBE-2E9BE643B802} = {58D535B0-AE32-4202-8D70-B9206667D248}
81-
{B18F53B4-4A1A-4B7F-9BFD-CA136F920F2B} = {B12F10A0-A3FC-41FA-95BC-BE48DC5E9092}
8279
EndGlobalSection
8380
EndGlobal

Json5/Internal/JsonSpecNumFormat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public static NumberLiteral Clone(
129129
nl.SuffixChar4);
130130

131131
/// <summary>
132-
/// Creates a left-alinged sliding window of size 2 over the input string. Basically
132+
/// Creates a left-aligned sliding window of size 2 over the input string. Basically
133133
/// a fixed-size version of MoreLINQ's <c>WindowLeft(int)</c>, but only for strings.
134134
/// </summary>
135135
/// <param name="str">The input string.</param>

build/Build.cs

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
using Nuke.Common;
2+
using Nuke.Common.CI.GitHubActions;
23
using Nuke.Common.Git;
34
using Nuke.Common.IO;
45
using Nuke.Common.ProjectModel;
56
using Nuke.Common.Tooling;
67
using Nuke.Common.Tools.DotNet;
78
using Nuke.Common.Utilities;
8-
using Nuke.Common.Utilities.Collections;
99

1010
using Serilog;
1111

1212
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1313

14+
[GitHubActions(
15+
"continuous",
16+
GitHubActionsImage.UbuntuLatest,
17+
On = [GitHubActionsTrigger.Push],
18+
ImportSecrets = [nameof(NuGetApiKey)],
19+
InvokedTargets = [nameof(Publish)])]
20+
[GitHubActions(
21+
"pr",
22+
GitHubActionsImage.UbuntuLatest,
23+
On = [GitHubActionsTrigger.PullRequest],
24+
InvokedTargets = [nameof(Test), nameof(Pack)])]
1425
class Build : NukeBuild {
1526
public static int Main() => Execute<Build>(x => x.Compile);
1627

@@ -19,15 +30,29 @@ class Build : NukeBuild {
1930
[PathVariable] readonly Tool Git = null!;
2031

2132
[Parameter($"NuGet API key - Required for target {nameof(Publish)}"), Secret]
22-
readonly string NugetApiKey = null!;
33+
readonly string NuGetApiKey = null!;
2334

24-
string SemVer => Repository.Tags.SingleOrError($"Last commit {Repository.Commit[..7]} wasn't tagged.");
25-
string PrevSemVer => Git("describe --tags --abbrev=0 HEAD^").Single().Text;
26-
string CommitMsgsSinceLastSemVer => Git($"log {PrevSemVer}..HEAD --format=%s").Select(o => o.Text).Join(Environment.NewLine);
35+
string? CurrSemVer => Repository.Tags.SingleOrDefault();
36+
37+
string? prevSemVer;
38+
string PrevSemVer => prevSemVer ??= Git($"describe --tags --abbrev=0 HEAD^").Single().Text;
39+
40+
string SemVer => CurrSemVer ?? $"{PrevSemVer}-{Repository.Branch}-{Repository.Commit[..7]}";
41+
42+
string? releaseNotes;
43+
string ReleaseNotes => releaseNotes ??= Git($"log {PrevSemVer}.. --format=%s").Select(o => o.Text).Join(Environment.NewLine);
2744

2845
AbsolutePath ArtifactsDir => RootDirectory / "artifacts";
2946
AbsolutePath PackagePath => ArtifactsDir / $"{Solution.Json5.Name}.{SemVer}.nupkg";
3047

48+
Target Info => t => t
49+
.Executes(() => {
50+
Log.Information("CurrSemVer {0}", CurrSemVer);
51+
Log.Information("PrevSemVer {0}", PrevSemVer);
52+
Log.Information("SemVer {0}", SemVer);
53+
Log.Information("ReleaseNotes {0}", ReleaseNotes);
54+
});
55+
3156
Target Clean => t => t
3257
.Executes(() => ArtifactsDir.DeleteDirectory());
3358

@@ -44,6 +69,7 @@ class Build : NukeBuild {
4469

4570
Target Pack => t => t
4671
.DependsOn(Clean, Compile)
72+
.Produces(ArtifactsDir / "*.nupkg", ArtifactsDir / "*.snupkg")
4773
.Executes(() => DotNetPack(opts => opts
4874
.SetProject(Solution.Json5)
4975
.SetNoBuild(true)
@@ -52,7 +78,7 @@ class Build : NukeBuild {
5278
.SetTitle("JSON5")
5379
.SetDescription("JSON5 for your dotnet appsettings files.")
5480
.SetPackageTags("JSON5 JSON parser translator deserializer appsettings configuration hosting")
55-
.SetPackageReleaseNotes(CommitMsgsSinceLastSemVer)
81+
.SetPackageReleaseNotes(ReleaseNotes)
5682
.SetAuthors("Robert Hofmann")
5783
.AddProcessAdditionalArguments("-p:PackageLicenseExpression=MIT")
5884
.SetRepositoryUrl("https://github.com/bert2/json5-dotnet.git")
@@ -65,10 +91,11 @@ class Build : NukeBuild {
6591
Target Publish => t => t
6692
.DependsOn(Test, Pack)
6793
.Requires(() => Repository.IsOnMainBranch())
68-
.Requires(() => NugetApiKey)
94+
.Requires(() => NuGetApiKey)
95+
.OnlyWhenDynamic(() => Repository.Tags.Count != 0)
6996
.Executes(() => /*DotNetNuGetPush(opts => opts
7097
.SetTargetPath(PackagePath)
71-
.SetSource("https://www.nuget.org/")
98+
.SetSource("https://api.nuget.org/v3/index.json")
7299
.SetApiKey(NugetApiKey)));*/
73-
Log.Information($"{string.Join(",", Repository.Tags)} dotnet nuget push {PackagePath} --source https://www.nuget.org/ --api-key {NugetApiKey}"));
100+
Log.Information($"{string.Join(",", Repository.Tags)} dotnet nuget push {PackagePath} --source https://api.nuget.org/v3/index.json --api-key {NuGetApiKey}"));
74101
}

0 commit comments

Comments
 (0)