From 7e0b7e6566cb759f4d74290290edea3dd5bbb690 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Tue, 10 Sep 2024 07:50:28 +0300 Subject: [PATCH] Upgrade to NUKE 8.1 --- .github/workflows/build.yml | 14 +-- .github/workflows/pr.yml | 14 +-- .nuke/build.schema.json | 157 ++++++++++++++++---------------- build/Build.CI.GitHubActions.cs | 10 +- build/Build.Pack.cs | 5 +- build/Build.cs | 11 +-- build/_build.csproj | 6 +- 7 files changed, 107 insertions(+), 110 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 37dead028a..ae31954217 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,7 +44,7 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish env: @@ -53,22 +53,22 @@ jobs: CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }} NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - name: 'Publish: NSwag.zip' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwag.zip path: artifacts/NSwag.zip - name: 'Publish: NSwag.Npm.zip' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwag.Npm.zip path: artifacts/NSwag.Npm.zip - name: 'Publish: NSwagStudio.msi' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwagStudio.msi path: artifacts/NSwagStudio.msi - name: 'Publish: NuGet Packages' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NuGet Packages path: artifacts/*.nupkg @@ -80,7 +80,7 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish env: @@ -96,7 +96,7 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack, Publish' run: ./build.cmd Compile Test Pack Publish env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e0c1805f53..b69e670e2f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -42,26 +42,26 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack - name: 'Publish: NSwag.zip' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwag.zip path: artifacts/NSwag.zip - name: 'Publish: NSwag.Npm.zip' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwag.Npm.zip path: artifacts/NSwag.Npm.zip - name: 'Publish: NSwagStudio.msi' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NSwagStudio.msi path: artifacts/NSwagStudio.msi - name: 'Publish: NuGet Packages' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: NuGet Packages path: artifacts/*.nupkg @@ -73,7 +73,7 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack macos-latest: @@ -84,6 +84,6 @@ jobs: with: dotnet-version: | 6.0 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Run: Compile, Test, Pack' run: ./build.cmd Compile Test Pack diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 57501ad2b6..1776f5569a 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,23 +1,80 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$ref": "#/definitions/build", - "title": "Build Schema", + "properties": { + "ChocoApiKey": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", + "enum": [ + "Debug", + "Release" + ] + }, + "MyGetApiKey": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "NpmAuthToken": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "NuGetApiKey": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" + } + }, "definitions": { - "build": { - "type": "object", + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Clean", + "Compile", + "InstallDependencies", + "Pack", + "Publish", + "Restore", + "Test" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { "properties": { - "ChocoApiKey": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" - }, - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", - "enum": [ - "Debug", - "Release" - ] - }, "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" @@ -27,42 +84,13 @@ "description": "Shows the help text for this build assembly" }, "Host": { - "type": "string", "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitbucket", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] - }, - "MyGetApiKey": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" + "$ref": "#/definitions/Host" }, "NoLogo": { "type": "boolean", "description": "Disables displaying the NUKE logo" }, - "NpmAuthToken": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" - }, - "NuGetApiKey": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secrets [profile]'" - }, "Partition": { "type": "string", "description": "Partition to use on CI" @@ -86,49 +114,22 @@ "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", "items": { - "type": "string", - "enum": [ - "Clean", - "Compile", - "InstallDependencies", - "Pack", - "Publish", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, - "Solution": { - "type": "string", - "description": "Path to a solution file that is automatically loaded" - }, "Target": { "type": "array", "description": "List of targets to be invoked. Default is '{default_target}'", "items": { - "type": "string", - "enum": [ - "Clean", - "Compile", - "InstallDependencies", - "Pack", - "Publish", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, "Verbosity": { - "type": "string", "description": "Logging verbosity during build execution. Default is 'Normal'", - "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" - ] + "$ref": "#/definitions/Verbosity" } } } - } + }, + "$ref": "#/definitions/NukeBuild" } diff --git a/build/Build.CI.GitHubActions.cs b/build/Build.CI.GitHubActions.cs index bbf5ea69d1..993647d548 100644 --- a/build/Build.CI.GitHubActions.cs +++ b/build/Build.CI.GitHubActions.cs @@ -15,8 +15,8 @@ OnPullRequestExcludePaths = ["**/*.md"], PublishArtifacts = true, InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack)], - CacheKeyFiles = new string[0], - JobConcurrencyCancelInProgress = false), + CacheKeyFiles = [], + ConcurrencyCancelInProgress = false), ] [CustomGitHubActions( "build", @@ -30,11 +30,9 @@ PublishArtifacts = true, InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish)], ImportSecrets = ["NUGET_API_KEY", "MYGET_API_KEY", "CHOCO_API_KEY", "NPM_AUTH_TOKEN"], - CacheKeyFiles = new string[0]) + CacheKeyFiles = []) ] -public partial class Build -{ -} +public partial class Build; class CustomGitHubActionsAttribute : GitHubActionsAttribute { diff --git a/build/Build.Pack.cs b/build/Build.Pack.cs index 7a0b4e0d76..4c1a971553 100644 --- a/build/Build.Pack.cs +++ b/build/Build.Pack.cs @@ -10,7 +10,6 @@ using Nuke.Common.Tools.MSBuild; using Nuke.Common.Tools.NuGet; -using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; using static Nuke.Common.Tools.MSBuild.MSBuildTasks; using static Nuke.Common.Tools.NuGet.NuGetTasks; @@ -115,7 +114,7 @@ public partial class Build foreach (var artifact in artifacts) { - CopyFileToDirectory(artifact, ArtifactsDirectory); + artifact.CopyToDirectory(ArtifactsDirectory); } // patch npm version @@ -129,7 +128,7 @@ public partial class Build ZipFile.CreateFromDirectory(NSwagStudioBinaries, ArtifactsDirectory / "NSwag.zip"); // NSwagStudio.msi - CopyFileToDirectory(ArtifactsDirectory / "bin" / "NSwagStudio.Installer" / Configuration / "NSwagStudio.msi", ArtifactsDirectory); + (ArtifactsDirectory / "bin" / "NSwagStudio.Installer" / Configuration / "NSwagStudio.msi").CopyToDirectory(ArtifactsDirectory); }); } diff --git a/build/Build.cs b/build/Build.cs index 7e42cbdb7c..9d94c7b99e 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -14,7 +14,6 @@ using Nuke.Common.Tools.Npm; using Nuke.Common.Utilities.Collections; -using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.Tools.Chocolatey.ChocolateyTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks; using static Nuke.Common.Tools.MSBuild.MSBuildTasks; @@ -278,14 +277,14 @@ void CopyConsoleBinaries(AbsolutePath target) if (IsRunningOnWindows) { var consoleX86Directory = ArtifactsDirectory / "publish" / consoleX86Project.Name / configuration; - CopyFileToDirectory(consoleX86Directory / "NSwag.x86.exe", target / "Win"); - CopyFileToDirectory(consoleX86Directory / "NSwag.x86.exe.config", target / "Win"); + (consoleX86Directory / "NSwag.x86.exe").CopyToDirectory(target / "Win"); + (consoleX86Directory / "NSwag.x86.exe.config").CopyToDirectory(target / "Win"); - CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleProject.Name / configuration, target / "Win", DirectoryExistsPolicy.Merge); + (ArtifactsDirectory / "publish" / consoleProject.Name / configuration).Copy(target / "Win", ExistsPolicy.DirectoryMerge); } - CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net6.0"), target / "Net60"); - CopyDirectoryRecursively(ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net8.0"), target / "Net80"); + (ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net6.0")).Copy(target / "Net60"); + (ArtifactsDirectory / "publish" / consoleCoreProject.Name / (configuration + "_net8.0")).Copy(target / "Net80"); } if (IsRunningOnWindows) diff --git a/build/_build.csproj b/build/_build.csproj index feca84c4f1..8762b669da 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -16,12 +16,12 @@ - + - - + +