mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-03-31 17:43:04 -06:00
Remove CliFx dependency from script to fix macOS CI timeout
Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Agent-Logs-Url: https://github.com/Tyrrrz/DiscordChatExporter/sessions/55dce499-3afd-4c84-a913-19f7412efe1b
This commit is contained in:
parent
8d03008e2e
commit
d8b46b5610
|
|
@ -1,61 +1,42 @@
|
||||||
#!/usr/bin/env -S dotnet run --
|
#!/usr/bin/env -S dotnet run --
|
||||||
#:package CliFx
|
|
||||||
|
|
||||||
using CliFx;
|
// Set up arguments
|
||||||
using CliFx.Attributes;
|
string GetArg(string name)
|
||||||
using CliFx.Infrastructure;
|
|
||||||
|
|
||||||
return await new CliApplicationBuilder()
|
|
||||||
.AddCommand<PublishMacOSBundleCommand>()
|
|
||||||
.Build()
|
|
||||||
.RunAsync(args);
|
|
||||||
|
|
||||||
[Command(Description = "Publishes the GUI app as a macOS .app bundle.")]
|
|
||||||
public class PublishMacOSBundleCommand : ICommand
|
|
||||||
{
|
{
|
||||||
private const string BundleName = "DiscordChatExporter.app";
|
var idx = Array.IndexOf(args, name);
|
||||||
private const string AppName = "DiscordChatExporter";
|
if (idx < 0 || idx + 1 >= args.Length)
|
||||||
private const string AppCopyright = "© Oleksii Holub";
|
throw new InvalidOperationException($"Missing required option: {name}");
|
||||||
private const string AppIdentifier = "me.Tyrrrz.DiscordChatExporter";
|
return args[idx + 1];
|
||||||
private const string AppSpokenName = "Discord Chat Exporter";
|
}
|
||||||
private const string AppIconName = "AppIcon";
|
|
||||||
|
|
||||||
[CommandOption("publish-dir", Description = "Path to the publish output directory.")]
|
var publishDirPathArg = GetArg("--publish-dir");
|
||||||
public required string PublishDirPath { get; init; }
|
var iconsFilePathArg = GetArg("--icons-file");
|
||||||
|
var fullVersionArg = GetArg("--full-version");
|
||||||
|
var shortVersionArg = GetArg("--short-version");
|
||||||
|
|
||||||
[CommandOption("icons-file", Description = "Path to the .icns icons file.")]
|
const string BundleName = "DiscordChatExporter.app";
|
||||||
public required string IconsFilePath { get; init; }
|
const string AppName = "DiscordChatExporter";
|
||||||
|
const string AppCopyright = "© Oleksii Holub";
|
||||||
|
const string AppIdentifier = "me.Tyrrrz.DiscordChatExporter";
|
||||||
|
const string AppSpokenName = "Discord Chat Exporter";
|
||||||
|
const string AppIconName = "AppIcon";
|
||||||
|
|
||||||
[CommandOption("full-version", Description = "Full version string (e.g. '1.2.3.4').")]
|
// Set up paths
|
||||||
public required string FullVersion { get; init; }
|
var publishDirPath = Path.GetFullPath(publishDirPathArg);
|
||||||
|
var tempDirPath = Path.GetFullPath(Path.Combine(publishDirPath, "../publish-macos-app-temp"));
|
||||||
|
|
||||||
[CommandOption("short-version", Description = "Short version string (e.g. '1.2.3').")]
|
// Ensure the temporary directory is clean before use in case a previous run crashed
|
||||||
public required string ShortVersion { get; init; }
|
if (Directory.Exists(tempDirPath))
|
||||||
|
|
||||||
public async ValueTask ExecuteAsync(IConsole console)
|
|
||||||
{
|
|
||||||
// Set up paths
|
|
||||||
var publishDirPath = Path.GetFullPath(PublishDirPath);
|
|
||||||
var tempDirPath = Path.GetFullPath(
|
|
||||||
Path.Combine(publishDirPath, "../publish-macos-app-temp")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Ensure the temporary directory is clean before use in case a previous run crashed
|
|
||||||
if (Directory.Exists(tempDirPath))
|
|
||||||
Directory.Delete(tempDirPath, true);
|
Directory.Delete(tempDirPath, true);
|
||||||
|
|
||||||
var bundleDirPath = Path.Combine(tempDirPath, BundleName);
|
var bundleDirPath = Path.Combine(tempDirPath, BundleName);
|
||||||
var contentsDirPath = Path.Combine(bundleDirPath, "Contents");
|
var contentsDirPath = Path.Combine(bundleDirPath, "Contents");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Copy icons into the .app's Resources folder
|
// Copy icons into the .app's Resources folder
|
||||||
Directory.CreateDirectory(Path.Combine(contentsDirPath, "Resources"));
|
Directory.CreateDirectory(Path.Combine(contentsDirPath, "Resources"));
|
||||||
File.Copy(
|
File.Copy(iconsFilePathArg, Path.Combine(contentsDirPath, "Resources", "AppIcon.icns"), true);
|
||||||
IconsFilePath,
|
|
||||||
Path.Combine(contentsDirPath, "Resources", "AppIcon.icns"),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Generate the Info.plist metadata file with the app information
|
// Generate the Info.plist metadata file with the app information
|
||||||
// lang=xml
|
// lang=xml
|
||||||
|
|
@ -81,9 +62,9 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
<key>CFBundleIconName</key>
|
<key>CFBundleIconName</key>
|
||||||
<string>{AppIconName}</string>
|
<string>{AppIconName}</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>{FullVersion}</string>
|
<string>{fullVersionArg}</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>{ShortVersion}</string>
|
<string>{shortVersionArg}</string>
|
||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true />
|
<true />
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
|
|
@ -103,11 +84,7 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS"));
|
Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS"));
|
||||||
foreach (var entryPath in Directory.GetFileSystemEntries(publishDirPath))
|
foreach (var entryPath in Directory.GetFileSystemEntries(publishDirPath))
|
||||||
{
|
{
|
||||||
var destinationPath = Path.Combine(
|
var destinationPath = Path.Combine(contentsDirPath, "MacOS", Path.GetFileName(entryPath));
|
||||||
contentsDirPath,
|
|
||||||
"MacOS",
|
|
||||||
Path.GetFileName(entryPath)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Directory.Exists(entryPath))
|
if (Directory.Exists(entryPath))
|
||||||
Directory.Move(entryPath, destinationPath);
|
Directory.Move(entryPath, destinationPath);
|
||||||
|
|
@ -117,12 +94,10 @@ public class PublishMacOSBundleCommand : ICommand
|
||||||
|
|
||||||
// Move the final bundle into the publish directory for upload
|
// Move the final bundle into the publish directory for upload
|
||||||
Directory.Move(bundleDirPath, Path.Combine(publishDirPath, BundleName));
|
Directory.Move(bundleDirPath, Path.Combine(publishDirPath, BundleName));
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
// Clean up the temporary directory
|
// Clean up the temporary directory
|
||||||
if (Directory.Exists(tempDirPath))
|
if (Directory.Exists(tempDirPath))
|
||||||
Directory.Delete(tempDirPath, true);
|
Directory.Delete(tempDirPath, true);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue