Skip to content

Commit

Permalink
[Build/GitHub] Added manual workflow dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingpie committed Jul 12, 2024
1 parent 25f118d commit edf0abc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 38 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ on:
push:
branches:
- master
workflow_dispatch:
inputs:
name:
description: "name"
required: false

jobs:
windows-latest:
Expand All @@ -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
Expand Down
6 changes: 2 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@
"PublishWin64Aot",
"PublishWin64FrameworkDependent",
"PublishWin64SelfContained",
"ReportInfo",
"Restore"
"ReportInfo"
]
}
},
Expand All @@ -109,8 +108,7 @@
"PublishWin64Aot",
"PublishWin64FrameworkDependent",
"PublishWin64SelfContained",
"ReportInfo",
"Restore"
"ReportInfo"
]
}
},
Expand Down
60 changes: 26 additions & 34 deletions src/01-Build/NukeBuild/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -94,21 +97,38 @@ public sealed class Build : NukeBuild
});

/// <summary>
/// NuGet restore.
/// Windows x64 AOT.
/// </summary>
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);
});

/// <summary>
/// Windows x64 framework dependent.
/// </summary>
private Target PublishWin64FrameworkDependent => _ => _
.DependsOn(Restore)
.DependsOn(Clean)
.Produces(PathToWin64FrameworkDependentZip)
.Executes(() =>
{
Expand Down Expand Up @@ -136,7 +156,7 @@ public sealed class Build : NukeBuild
/// Windows x64 self contained.
/// </summary>
private Target PublishWin64SelfContained => _ => _
.DependsOn(Restore)
.DependsOn(Clean)
.Produces(PathToWin64SelfContainedZip)
.Executes(() =>
{
Expand All @@ -160,34 +180,6 @@ public sealed class Build : NukeBuild
fileMode: System.IO.FileMode.CreateNew);
});

/// <summary>
/// Windows x64 AOT.
/// </summary>
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);
});

/// <summary>
/// Scoop manifest.
/// </summary>
Expand Down

0 comments on commit edf0abc

Please sign in to comment.