-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from smoogipoo/rename-assets
- Loading branch information
Showing
9 changed files
with
135 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace osu.Desktop.Deploy | ||
{ | ||
public class GitHubRelease | ||
{ | ||
[JsonProperty(@"id")] | ||
[JsonProperty("id")] | ||
public int Id; | ||
|
||
[JsonProperty(@"tag_name")] | ||
[JsonProperty("tag_name")] | ||
public string TagName => $"{Name}"; | ||
|
||
[JsonProperty(@"name")] | ||
[JsonProperty("name")] | ||
public string Name = string.Empty; | ||
|
||
[JsonProperty(@"draft")] | ||
[JsonProperty("draft")] | ||
public bool Draft; | ||
|
||
[JsonProperty(@"prerelease")] | ||
[JsonProperty("prerelease")] | ||
public bool PreRelease; | ||
|
||
[JsonProperty(@"upload_url")] | ||
[JsonProperty("upload_url")] | ||
public string UploadUrl = string.Empty; | ||
|
||
[JsonProperty("assets")] | ||
public GitHubAsset[] Assets = Array.Empty<GitHubAsset>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
namespace osu.Desktop.Deploy.Uploaders | ||
{ | ||
public class LinuxVelopackUploader : VelopackUploader | ||
{ | ||
private readonly string channel; | ||
|
||
public LinuxVelopackUploader(string applicationName, string operatingSystemName, string runtimeIdentifier, string channel, string? extraArgs = null, string? stagingPath = null) | ||
: base(applicationName, operatingSystemName, runtimeIdentifier, channel, extraArgs, stagingPath) | ||
{ | ||
this.channel = channel; | ||
} | ||
|
||
public override void PublishBuild(string version) | ||
{ | ||
base.PublishBuild(version); | ||
RenameAsset($"{Program.PackageName}-{channel}.AppImage", "osu.AppImage"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
|
||
namespace osu.Desktop.Deploy.Uploaders | ||
{ | ||
public class MacOSVelopackUploader : VelopackUploader | ||
{ | ||
private readonly string channel; | ||
|
||
public MacOSVelopackUploader(string applicationName, string operatingSystemName, string runtimeIdentifier, string channel, string? extraArgs = null, string? stagingPath = null) | ||
: base(applicationName, operatingSystemName, runtimeIdentifier, channel, extraArgs, stagingPath) | ||
{ | ||
this.channel = channel; | ||
} | ||
|
||
public override void PublishBuild(string version) | ||
{ | ||
base.PublishBuild(version); | ||
|
||
string suffix; | ||
|
||
switch (channel) | ||
{ | ||
case "osx-arm64": | ||
suffix = "Apple.Silicon"; | ||
break; | ||
|
||
case "osx-x64": | ||
suffix = "Intel"; | ||
break; | ||
|
||
default: | ||
throw new Exception($"Unrecognised channel: {channel}"); | ||
} | ||
|
||
RenameAsset($"{Program.PackageName}-{channel}-Portable.zip", $"osu.app.{suffix}.zip"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using osu.Framework.IO.Network; | ||
|
||
namespace osu.Desktop.Deploy.Uploaders | ||
{ | ||
public class VelopackUploader : Uploader | ||
|
@@ -63,5 +68,31 @@ public override void PublishBuild(string version) | |
useSolutionPath: false); | ||
} | ||
} | ||
|
||
protected void RenameAsset(string fromName, string toName) | ||
{ | ||
if (!Program.CanGitHub || !Program.GitHubUpload) | ||
return; | ||
|
||
Logger.Write($"Renaming asset '{fromName}' to '{toName}'"); | ||
|
||
GitHubRelease targetRelease = Program.GetLastGithubRelease(true) | ||
?? throw new Exception("Release not found."); | ||
|
||
GitHubAsset asset = targetRelease.Assets.SingleOrDefault(a => a.Name == fromName) | ||
?? throw new Exception($"Asset '{fromName}' not found in the release."); | ||
|
||
var req = new WebRequest(asset.Url) | ||
{ | ||
Method = HttpMethod.Patch, | ||
}; | ||
|
||
req.AddRaw( | ||
$$""" | ||
{ "name": "{{toName}}" } | ||
"""); | ||
|
||
req.AuthenticatedBlockingPerform(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
namespace osu.Desktop.Deploy.Uploaders | ||
{ | ||
public class WindowsVelopackUploader : VelopackUploader | ||
{ | ||
private readonly string channel; | ||
|
||
public WindowsVelopackUploader(string applicationName, string operatingSystemName, string runtimeIdentifier, string channel, string? extraArgs = null, string? stagingPath = null) | ||
: base(applicationName, operatingSystemName, runtimeIdentifier, channel, extraArgs, stagingPath) | ||
{ | ||
this.channel = channel; | ||
} | ||
|
||
public override void PublishBuild(string version) | ||
{ | ||
base.PublishBuild(version); | ||
RenameAsset($"{Program.PackageName}-{channel}-Setup.exe", "install.exe"); | ||
} | ||
} | ||
} |