|
14 | 14 | using static Nuke.Common.Tools.MSBuild.MSBuildTasks;
|
15 | 15 | using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
16 | 16 | using static Nuke.Common.IO.FileSystemTasks;
|
| 17 | +using static Nuke.Common.Tooling.ProcessTasks; |
17 | 18 |
|
18 | 19 | [CheckBuildProjectConfigurations]
|
19 | 20 | [UnsetVisualStudioEnvironmentVariables]
|
@@ -77,6 +78,8 @@ bool HasDesktopMsBuild
|
77 | 78 | [Parameter("NuGet feed")] readonly string NugetFeed = "https://api.nuget.org/v3/index.json";
|
78 | 79 | [Parameter("NuGet username")] readonly string NugetUsername;
|
79 | 80 | [Parameter("NuGet password")] readonly string NugetPassword;
|
| 81 | + [Parameter("Code-signing service username")] readonly string SignUsername; |
| 82 | + [Parameter("Code-signing service password")] readonly string SignPassword; |
80 | 83 | [Parameter("Extra properties passed to MSBuild commands")]
|
81 | 84 | readonly string[] MsbuildProperties = Array.Empty<string>();
|
82 | 85 |
|
@@ -223,8 +226,8 @@ Dictionary<string, object> ProcessedMsbuildProperties
|
223 | 226 | {
|
224 | 227 | var silkDroid = SourceDirectory / "Windowing" / "Android" / "SilkDroid";
|
225 | 228 | using var process = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|
226 |
| - ? ProcessTasks.StartProcess("bash", "-c \"./gradlew clean\"", silkDroid) |
227 |
| - : ProcessTasks.StartProcess("cmd", "/c \".\\gradlew clean\"", silkDroid); |
| 229 | + ? StartProcess("bash", "-c \"./gradlew clean\"", silkDroid) |
| 230 | + : StartProcess("cmd", "/c \".\\gradlew clean\"", silkDroid); |
228 | 231 | process.AssertZeroExitCode();
|
229 | 232 | return process.Output;
|
230 | 233 | }
|
@@ -365,8 +368,8 @@ Dictionary<string, object> ProcessedMsbuildProperties
|
365 | 368 | }
|
366 | 369 |
|
367 | 370 | using var process = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|
368 |
| - ? ProcessTasks.StartProcess("bash", "-c \"./gradlew build\"", silkDroid) |
369 |
| - : ProcessTasks.StartProcess("cmd", "/c \".\\gradlew build\"", silkDroid); |
| 371 | + ? StartProcess("bash", "-c \"./gradlew build\"", silkDroid) |
| 372 | + : StartProcess("cmd", "/c \".\\gradlew build\"", silkDroid); |
370 | 373 | process.AssertZeroExitCode();
|
371 | 374 | var ret = process.Output;
|
372 | 375 | CopyFile
|
@@ -417,19 +420,46 @@ Dictionary<string, object> ProcessedMsbuildProperties
|
417 | 420 | Target FullPack => _ => _
|
418 | 421 | .DependsOn(BuildLibSilkDroid, RegenerateBindings, Pack);
|
419 | 422 |
|
420 |
| - Target PushToNuGet => _ => _ |
| 423 | + Target PushToNuGet => _ => _ |
421 | 424 | .DependsOn(Pack)
|
422 | 425 | .Executes(PushPackages);
|
423 | 426 |
|
424 | 427 | Target FullPushToNuGet => _ => _
|
425 | 428 | .DependsOn(FullPack, PushToNuGet);
|
426 | 429 |
|
| 430 | + static string PackageDirectory => RootDirectory / "build" / "output_packages"; |
| 431 | + static IEnumerable<string> Packages => Directory.GetFiles(PackageDirectory, "*.nupkg") |
| 432 | + .Where(x => Path.GetFileName(x).StartsWith("Silk.NET") || Path.GetFileName(x).StartsWith("Ultz.Native")); |
| 433 | + |
427 | 434 | async Task PushPackages()
|
428 | 435 | {
|
429 | 436 | const int rateLimit = 300;
|
430 |
| - var allFiles = Directory.GetFiles(RootDirectory / "build" / "output_packages", "*.nupkg") |
431 |
| - .Where(x => Path.GetFileName(x).StartsWith("Silk.NET") || Path.GetFileName(x).StartsWith("Ultz.Native")) |
432 |
| - .Select((x, i) => new {Index = i, Value = x}) |
| 437 | + if (!string.IsNullOrWhiteSpace(SignUsername) && !string.IsNullOrWhiteSpace(SignPassword)) |
| 438 | + { |
| 439 | + var basePath = RootDirectory / "build" / "codesigning"; |
| 440 | + var execPath = basePath / "tool" / (OperatingSystem.IsWindows() ? "SignClient.exe" : "SignClient"); |
| 441 | + if (!File.Exists(execPath)) |
| 442 | + { |
| 443 | + DotNetToolInstall(s => s.SetToolInstallationPath(basePath / "tool").SetPackageName("SignClient")); |
| 444 | + } |
| 445 | + |
| 446 | + StartProcess |
| 447 | + ( |
| 448 | + execPath, |
| 449 | + "sign " + |
| 450 | + $"--baseDirectory {PackageDirectory} " + |
| 451 | + "--input \"**/*.nupkg\" " + |
| 452 | + $"--config \"{basePath / "config.json"}\" " + |
| 453 | + $"--filelist \"{basePath / "filelist.txt"}\" " + |
| 454 | + $"--user \"{SignUsername}\" " + |
| 455 | + $"--secret \"{SignPassword}\" " + |
| 456 | + "--name \"Silk.NET\" " + |
| 457 | + "--description \"Silk.NET\" " + |
| 458 | + "--descriptionUrl \"https://github.com/dotnet/Silk.NET\"" |
| 459 | + ).AssertZeroExitCode(); |
| 460 | + } |
| 461 | + |
| 462 | + var allFiles = Packages.Select((x, i) => new {Index = i, Value = x}) |
433 | 463 | .GroupBy(x => x.Index / rateLimit)
|
434 | 464 | .Select(x => x.Select(v => v.Value).ToList())
|
435 | 465 | .ToList();
|
|
0 commit comments