From 0975fe8178a506019ee5558ffd732c4ed359baa6 Mon Sep 17 00:00:00 2001 From: Ben Olden-Cooligan Date: Mon, 26 Aug 2024 21:03:33 -0700 Subject: [PATCH] Tools: Fix upload command for betas --- .../Project/Releasing/UploadCommand.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/NAPS2.Tools/Project/Releasing/UploadCommand.cs b/NAPS2.Tools/Project/Releasing/UploadCommand.cs index 66b29a19fb..4d0883a40f 100644 --- a/NAPS2.Tools/Project/Releasing/UploadCommand.cs +++ b/NAPS2.Tools/Project/Releasing/UploadCommand.cs @@ -18,7 +18,7 @@ public class UploadCommand : ICommand public int Run(UploadOptions opts) { - string version = opts.Version ?? ProjectHelper.GetCurrentVersion(); + string version = opts.Version ?? ProjectHelper.GetCurrentVersionName(); if (opts.Target != "sdk") { // Validate all package files @@ -58,7 +58,7 @@ public int Run(UploadOptions opts) if (opts.Target is "all" or "apt") { Output.Info("Updating Apt metadata on downloads.naps2.com"); - UpdateAptMetadata(); + UpdateAptMetadata(version); didSomething = true; } if (opts.Target is "sdk") @@ -83,7 +83,8 @@ private async Task UploadToNuget() var repository = Repository.Factory.GetCoreV3("https://api.nuget.org/v3/index.json"); var resource = await repository.GetResourceAsync(); var v = ProjectHelper.GetSdkVersion(); - var packagePaths = ProjectHelper.GetSdkProjects().Select(x => $"{GetProjectFolder(x)}/bin/Release/{x}.{v}.nupkg").ToList(); + var packagePaths = ProjectHelper.GetSdkProjects() + .Select(x => $"{GetProjectFolder(x)}/bin/Release/{x}.{v}.nupkg").ToList(); var key = await File.ReadAllTextAsync(Path.Combine(Paths.Naps2UserFolder, "nuget")); await resource.Push( packagePaths, @@ -179,6 +180,11 @@ private async Task UploadToSourceForge(string version) client.UploadFile(stream, $"/home/frs/project/naps2/{version}/{Path.GetFileName(path)}"); } } + if (version.Contains('b')) + { + Output.Verbose("Skipping default downloads for beta"); + return; + } Output.Verbose($"Setting default downloads"); var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); @@ -232,8 +238,14 @@ private void UploadToStaticSite(string version, string? packageType) Output.Info($"Uploaded files."); } - private void UpdateAptMetadata() + private void UpdateAptMetadata(string version) { + if (version.Contains('b')) + { + Output.Verbose("Skipping APT metadata for beta"); + return; + } + var aptTemp = Path.Combine(Paths.SetupObj, "apt"); if (Directory.Exists(aptTemp)) { @@ -243,9 +255,12 @@ private void UpdateAptMetadata() Cli.Run("ssh", "user@downloads.naps2.com \"mkdir -p /home/user/apt-temp-packages/\""); Cli.Run("ssh", "user@downloads.naps2.com \"mkdir -p /home/user/apt-temp-release/\""); - Cli.Run("ssh", "user@downloads.naps2.com \"cd /var/www/html/ ; apt-ftparchive packages . > /home/user/apt-temp-packages/Packages\" ; apt-ftparchive release /home/user/apt-temp-packages/ > /home/user/apt-temp-release/Release\""); - Cli.Run("scp", $"user@downloads.naps2.com:/home/user/apt-temp-packages/Packages {Path.Combine(aptTemp, "Packages")}"); - Cli.Run("scp", $"user@downloads.naps2.com:/home/user/apt-temp-release/Release {Path.Combine(aptTemp, "Release")}"); + Cli.Run("ssh", + "user@downloads.naps2.com \"cd /var/www/html/ ; apt-ftparchive packages . > /home/user/apt-temp-packages/Packages\" ; apt-ftparchive release /home/user/apt-temp-packages/ > /home/user/apt-temp-release/Release\""); + Cli.Run("scp", + $"user@downloads.naps2.com:/home/user/apt-temp-packages/Packages {Path.Combine(aptTemp, "Packages")}"); + Cli.Run("scp", + $"user@downloads.naps2.com:/home/user/apt-temp-release/Release {Path.Combine(aptTemp, "Release")}"); Cli.Run("gpg", $"--output {Path.Combine(aptTemp, "Release.gpg")} --sign {Path.Combine(aptTemp, "Release")}"); Cli.Run("gpg", $"--output {Path.Combine(aptTemp, "InRelease")} --clearsign {Path.Combine(aptTemp, "Release")}"); Cli.Run("scp", $"{Path.Combine(aptTemp, "Packages")} user@downloads.naps2.com:/var/www/html/Packages");