From edf0abcd117f4a2c64e117811d73a0dcb63d2ffb Mon Sep 17 00:00:00 2001 From: Marco van den Oever Date: Fri, 12 Jul 2024 21:27:59 +0200 Subject: [PATCH] [Build/GitHub] Added manual workflow dispatch --- .github/workflows/ci.yml | 6 ++++ .nuke/build.schema.json | 6 ++-- src/01-Build/NukeBuild/Build.cs | 60 ++++++++++++++------------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73c374f..3d90d6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,11 @@ on: push: branches: - master + workflow_dispatch: + inputs: + name: + description: "name" + required: false jobs: windows-latest: @@ -39,6 +44,7 @@ jobs: - name: 'Run: PublishRelease' run: ./src/build.cmd PublishRelease env: + name: ${{ github.event.inputs.name }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: win-x64_self-contained.zip' uses: actions/upload-artifact@v3 diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 9fb4556..496250f 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -85,8 +85,7 @@ "PublishWin64Aot", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "ReportInfo", - "Restore" + "ReportInfo" ] } }, @@ -109,8 +108,7 @@ "PublishWin64Aot", "PublishWin64FrameworkDependent", "PublishWin64SelfContained", - "ReportInfo", - "Restore" + "ReportInfo" ] } }, diff --git a/src/01-Build/NukeBuild/Build.cs b/src/01-Build/NukeBuild/Build.cs index f1fbb43..f580183 100644 --- a/src/01-Build/NukeBuild/Build.cs +++ b/src/01-Build/NukeBuild/Build.cs @@ -24,6 +24,7 @@ GitHubActionsImage.WindowsLatest, FetchDepth = 0, OnPushBranches = ["master"], + OnWorkflowDispatchOptionalInputs = [ "name" ], EnableGitHubToken = true, InvokedTargets = [nameof(PublishRelease)])] [SuppressMessage("Major Bug", "S3903:Types should be defined in named namespaces", Justification = "MvdO: Build script.")] @@ -54,6 +55,8 @@ public sealed class Build : NukeBuild [Solution(GenerateProjects = true, SuppressBuildProjectCheck = true)] private readonly Solution Solution; + private AbsolutePath PathToWin64AotZip => ArtifactsDirectory / $"win-x64_aot.zip"; + private AbsolutePath PathToWin64FrameworkDependentZip => ArtifactsDirectory / $"win-x64_framework-dependent.zip"; private AbsolutePath PathToWin64SelfContainedZip => ArtifactsDirectory / $"win-x64_self-contained.zip"; @@ -94,21 +97,38 @@ public sealed class Build : NukeBuild }); /// - /// NuGet restore. + /// Windows x64 AOT. /// - public Target Restore => _ => _ + private Target PublishWin64Aot => _ => _ .DependsOn(Clean) + .Produces(PathToWin64AotZip) .Executes(() => { - DotNetRestore(_ => _ - .SetProcessWorkingDirectory(Solution.Directory)); + var staging = StagingDirectory / "win-x64_aot"; + + DotNetPublish(_ => _ + .SetAssemblyVersion(AssemblyVersion) + .SetInformationalVersion(InformationalVersion) + .SetConfiguration(Configuration) + .SetFramework("net8.0-windows") + .SetProject(Solution._0_Host.Wtq_Host_Windows) + .SetOutput(staging) + .SetProperty("PublishAot", true) + .SetProperty("InvariantGlobalization", true) + .SetRuntime("win-x64")); + + staging.ZipTo( + PathToWin64AotZip, + filter: x => x.HasExtension(".exe", ".jsonc"), + compressionLevel: CompressionLevel.SmallestSize, + fileMode: System.IO.FileMode.CreateNew); }); /// /// Windows x64 framework dependent. /// private Target PublishWin64FrameworkDependent => _ => _ - .DependsOn(Restore) + .DependsOn(Clean) .Produces(PathToWin64FrameworkDependentZip) .Executes(() => { @@ -136,7 +156,7 @@ public sealed class Build : NukeBuild /// Windows x64 self contained. /// private Target PublishWin64SelfContained => _ => _ - .DependsOn(Restore) + .DependsOn(Clean) .Produces(PathToWin64SelfContainedZip) .Executes(() => { @@ -160,34 +180,6 @@ public sealed class Build : NukeBuild fileMode: System.IO.FileMode.CreateNew); }); - /// - /// Windows x64 AOT. - /// - private Target PublishWin64Aot => _ => _ - .DependsOn(Restore) - .Produces(PathToWin64SelfContainedZip) - .Executes(() => - { - var staging = StagingDirectory / "win-x64_aot"; - - DotNetPublish(_ => _ - .SetAssemblyVersion(AssemblyVersion) - .SetInformationalVersion(InformationalVersion) - .SetConfiguration(Configuration) - .SetFramework("net8.0-windows") - .SetProject(Solution._0_Host.Wtq_Host_Windows) - .SetOutput(staging) - .SetProperty("PublishAot", true) - .SetProperty("InvariantGlobalization", true) - .SetRuntime("win-x64")); - - staging.ZipTo( - PathToWin64SelfContainedZip, - filter: x => x.HasExtension(".exe", ".jsonc"), - compressionLevel: CompressionLevel.SmallestSize, - fileMode: System.IO.FileMode.CreateNew); - }); - /// /// Scoop manifest. ///