mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-08-08 21:37:53 +02:00
Bundle for macOS via MacBundle
This commit is contained in:
@@ -128,12 +128,16 @@ jobs:
|
|||||||
-p:Version=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
-p:Version=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }}
|
||||||
-p:CSharpier_Bypass=true
|
-p:CSharpier_Bypass=true
|
||||||
-p:EncryptionSalt=${{ secrets.ENCRYPTION_SALT || 'HimalayanPinkSalt' }}
|
-p:EncryptionSalt=${{ secrets.ENCRYPTION_SALT || 'HimalayanPinkSalt' }}
|
||||||
-p:PublishMacOSBundle=${{ startsWith(matrix.rid, 'osx-') }}
|
|
||||||
--output ${{ matrix.app }}/bin/publish/
|
--output ${{ matrix.app }}/bin/publish/
|
||||||
--configuration Release
|
--configuration Release
|
||||||
--runtime ${{ matrix.rid }}
|
--runtime ${{ matrix.rid }}
|
||||||
--self-contained
|
--self-contained
|
||||||
|
|
||||||
|
- name: Rename macOS bundle
|
||||||
|
if: ${{ startsWith(matrix.rid, 'osx-') && matrix.app == 'DiscordChatExporter.Gui' }}
|
||||||
|
run: >
|
||||||
|
mv ${{ matrix.app }}/bin/publish/DCE.app ${{ matrix.app }}/bin/publish/${{ matrix.asset }}.app
|
||||||
|
|
||||||
- name: Upload app binaries
|
- name: Upload app binaries
|
||||||
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.5" />
|
<PackageVersion Include="GitHubActionsTestLogger" Version="3.0.5" />
|
||||||
<PackageVersion Include="Gress" Version="2.2.0" />
|
<PackageVersion Include="Gress" Version="2.2.0" />
|
||||||
<PackageVersion Include="JsonExtensions" Version="1.2.3" />
|
<PackageVersion Include="JsonExtensions" Version="1.2.3" />
|
||||||
|
<PackageVersion Include="MacBundle" Version="1.0.0" />
|
||||||
<PackageVersion Include="Markdig" Version="1.3.2" />
|
<PackageVersion Include="Markdig" Version="1.3.2" />
|
||||||
<PackageVersion Include="Material.Avalonia" Version="3.16.1" />
|
<PackageVersion Include="Material.Avalonia" Version="3.16.1" />
|
||||||
<PackageVersion Include="Material.Icons.Avalonia" Version="3.0.2" />
|
<PackageVersion Include="Material.Icons.Avalonia" Version="3.0.2" />
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
|
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<MacOSBundleIdentifier>me.tyrrrz.discordchatexporter</MacOSBundleIdentifier>
|
||||||
|
<MacOSBundleName>DCE</MacOSBundleName>
|
||||||
|
<MacOSBundleDisplayName>DiscordChatExporter</MacOSBundleDisplayName>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<EncryptionSalt>HimalayanPinkSalt</EncryptionSalt>
|
<EncryptionSalt>HimalayanPinkSalt</EncryptionSalt>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -16,10 +22,6 @@
|
|||||||
<ProjectProperty Include="EncryptionSalt" />
|
<ProjectProperty Include="EncryptionSalt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<PublishMacOSBundle>false</PublishMacOSBundle>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="../favicon.ico" Link="favicon.ico" />
|
<AvaloniaResource Include="../favicon.ico" Link="favicon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -34,6 +36,7 @@
|
|||||||
<PackageReference Include="Deorcify" />
|
<PackageReference Include="Deorcify" />
|
||||||
<PackageReference Include="DialogHost.Avalonia" />
|
<PackageReference Include="DialogHost.Avalonia" />
|
||||||
<PackageReference Include="Gress" />
|
<PackageReference Include="Gress" />
|
||||||
|
<PackageReference Include="MacBundle" />
|
||||||
<PackageReference Include="Markdig" />
|
<PackageReference Include="Markdig" />
|
||||||
<PackageReference Include="Material.Avalonia" />
|
<PackageReference Include="Material.Avalonia" />
|
||||||
<PackageReference Include="Material.Icons.Avalonia" />
|
<PackageReference Include="Material.Icons.Avalonia" />
|
||||||
@@ -46,11 +49,4 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../DiscordChatExporter.Core/DiscordChatExporter.Core.csproj" />
|
<ProjectReference Include="../DiscordChatExporter.Core/DiscordChatExporter.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="PublishMacOSBundle" AfterTargets="Publish" Condition="$(PublishMacOSBundle)">
|
|
||||||
<Exec
|
|
||||||
Command="dotnet run --file "$(ProjectDir)PublishMacOSBundle.csx" -- --publish-dir "$(PublishDir)" --icons-file "$(ProjectDir)../favicon.icns" --full-version $(Version) --short-version $(AssemblyVersion)"
|
|
||||||
LogStandardErrorAsError="true"
|
|
||||||
/>
|
|
||||||
</Target>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,123 +0,0 @@
|
|||||||
#!/usr/bin/dotnet --
|
|
||||||
#:package CliFx
|
|
||||||
|
|
||||||
using CliFx;
|
|
||||||
using CliFx.Binding;
|
|
||||||
using CliFx.Infrastructure;
|
|
||||||
|
|
||||||
[Command(Description = "Publishes the GUI app as a macOS .app bundle.")]
|
|
||||||
public partial class PublishMacOSBundleCommand : ICommand
|
|
||||||
{
|
|
||||||
private const string BundleName = "DiscordChatExporter.app";
|
|
||||||
private const string AppName = "DiscordChatExporter";
|
|
||||||
private const string AppCopyright = "© Oleksii Holub";
|
|
||||||
private const string AppIdentifier = "me.Tyrrrz.DiscordChatExporter";
|
|
||||||
private const string AppSpokenName = "Discord Chat Exporter";
|
|
||||||
private const string AppIconName = "AppIcon";
|
|
||||||
|
|
||||||
[CommandOption("publish-dir", Description = "Path to the publish output directory.")]
|
|
||||||
public required string PublishDirPath { get; set; }
|
|
||||||
|
|
||||||
[CommandOption("icons-file", Description = "Path to the .icns icons file.")]
|
|
||||||
public required string IconsFilePath { get; set; }
|
|
||||||
|
|
||||||
[CommandOption("full-version", Description = "Full version string (e.g., '1.2.3.4').")]
|
|
||||||
public required string FullVersion { get; set; }
|
|
||||||
|
|
||||||
[CommandOption("short-version", Description = "Short version string (e.g., '1.2.3').")]
|
|
||||||
public required string ShortVersion { get; set; }
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
var bundleDirPath = Path.Combine(tempDirPath, BundleName);
|
|
||||||
var contentsDirPath = Path.Combine(bundleDirPath, "Contents");
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Copy icons into the .app's Resources folder
|
|
||||||
Directory.CreateDirectory(Path.Combine(contentsDirPath, "Resources"));
|
|
||||||
File.Copy(
|
|
||||||
IconsFilePath,
|
|
||||||
Path.Combine(contentsDirPath, "Resources", "AppIcon.icns"),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Generate the Info.plist metadata file with the app information
|
|
||||||
// lang=xml
|
|
||||||
var plistContent = $"""
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDisplayName</key>
|
|
||||||
<string>{AppName}</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>{AppName}</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>{AppName}</string>
|
|
||||||
<key>NSHumanReadableCopyright</key>
|
|
||||||
<string>{AppCopyright}</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>{AppIdentifier}</string>
|
|
||||||
<key>CFBundleSpokenName</key>
|
|
||||||
<string>{AppSpokenName}</string>
|
|
||||||
<key>CFBundleIconFile</key>
|
|
||||||
<string>{AppIconName}</string>
|
|
||||||
<key>CFBundleIconName</key>
|
|
||||||
<string>{AppIconName}</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>{FullVersion}</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>{ShortVersion}</string>
|
|
||||||
<key>NSHighResolutionCapable</key>
|
|
||||||
<true />
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>APPL</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
""";
|
|
||||||
|
|
||||||
await File.WriteAllTextAsync(Path.Combine(contentsDirPath, "Info.plist"), plistContent);
|
|
||||||
|
|
||||||
// Delete the previous bundle if it exists
|
|
||||||
var existingBundlePath = Path.Combine(publishDirPath, BundleName);
|
|
||||||
if (Directory.Exists(existingBundlePath))
|
|
||||||
Directory.Delete(existingBundlePath, true);
|
|
||||||
|
|
||||||
// Move all files from the publish directory into the MacOS directory
|
|
||||||
Directory.CreateDirectory(Path.Combine(contentsDirPath, "MacOS"));
|
|
||||||
foreach (var entryPath in Directory.GetFileSystemEntries(publishDirPath))
|
|
||||||
{
|
|
||||||
var destinationPath = Path.Combine(
|
|
||||||
contentsDirPath,
|
|
||||||
"MacOS",
|
|
||||||
Path.GetFileName(entryPath)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (Directory.Exists(entryPath))
|
|
||||||
Directory.Move(entryPath, destinationPath);
|
|
||||||
else
|
|
||||||
File.Move(entryPath, destinationPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move the final bundle into the publish directory for upload
|
|
||||||
Directory.Move(bundleDirPath, Path.Combine(publishDirPath, BundleName));
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// Clean up the temporary directory
|
|
||||||
if (Directory.Exists(tempDirPath))
|
|
||||||
Directory.Delete(tempDirPath, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
Reference in New Issue
Block a user