Skip to content

Commit

Permalink
Tools: Fix upload command for betas
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Aug 27, 2024
1 parent aa4bcf8 commit 0975fe8
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions NAPS2.Tools/Project/Releasing/UploadCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class UploadCommand : ICommand<UploadOptions>

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
Expand Down Expand Up @@ -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")
Expand All @@ -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<PackageUpdateResource>();
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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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))
{
Expand All @@ -243,9 +255,12 @@ private void UpdateAptMetadata()

Cli.Run("ssh", "[email protected] \"mkdir -p /home/user/apt-temp-packages/\"");
Cli.Run("ssh", "[email protected] \"mkdir -p /home/user/apt-temp-release/\"");
Cli.Run("ssh", "[email protected] \"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", $"[email protected]:/home/user/apt-temp-packages/Packages {Path.Combine(aptTemp, "Packages")}");
Cli.Run("scp", $"[email protected]:/home/user/apt-temp-release/Release {Path.Combine(aptTemp, "Release")}");
Cli.Run("ssh",
"[email protected] \"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",
$"[email protected]:/home/user/apt-temp-packages/Packages {Path.Combine(aptTemp, "Packages")}");
Cli.Run("scp",
$"[email protected]:/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")} [email protected]:/var/www/html/Packages");
Expand Down

0 comments on commit 0975fe8

Please sign in to comment.