1
+ param (
2
+ [Parameter (Mandatory = $true )]
3
+ [string ]$PublishDirPath ,
4
+
5
+ [Parameter (Mandatory = $true )]
6
+ [string ]$IconsFilePath ,
7
+
8
+ [Parameter (Mandatory = $true )]
9
+ [string ]$FullVersion ,
10
+
11
+ [Parameter (Mandatory = $true )]
12
+ [string ]$ShortVersion
13
+ )
14
+
15
+ # Setup paths
16
+ $tempDirPath = Join-Path $PublishDirPath " ../publish-macos-app-temp"
17
+ $bundleName = " DiscordChatExporter.app"
18
+ $bundleDirPath = Join-Path $tempDirPath $bundleName
19
+ $contentsDirPath = Join-Path $bundleDirPath " Contents"
20
+ $macosDirPath = Join-Path $contentsDirPath " MacOS"
21
+ $resourcesDirPath = Join-Path $contentsDirPath " Resources"
22
+
23
+ try {
24
+ # Initialize the bundle's directory structure
25
+ New-Item - Path $bundleDirPath - ItemType Directory - Force
26
+ New-Item - Path $contentsDirPath - ItemType Directory - Force
27
+ New-Item - Path $macosDirPath - ItemType Directory - Force
28
+ New-Item - Path $resourcesDirPath - ItemType Directory - Force
29
+
30
+ # Copy icons into the .app's Resources folder
31
+ Copy-Item - Path $IconsFilePath - Destination (Join-Path $resourcesDirPath " AppIcon.icns" ) - Force
32
+
33
+ # Generate the Info.plist metadata file with the app information
34
+ $plistContent = @"
35
+ <?xml version="1.0" encoding="UTF-8"?>
36
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
37
+ <plist version="1.0">
38
+ <dict>
39
+ <key>CFBundleDisplayName</key>
40
+ <string>DiscordChatExporter</string>
41
+ <key>CFBundleName</key>
42
+ <string>DiscordChatExporter</string>
43
+ <key>CFBundleExecutable</key>
44
+ <string>DiscordChatExporter</string>
45
+ <key>NSHumanReadableCopyright</key>
46
+ <string>© Oleksii Holub</string>
47
+ <key>CFBundleIdentifier</key>
48
+ <string>me.Tyrrrz.DiscordChatExporter</string>
49
+ <key>CFBundleSpokenName</key>
50
+ <string>Discord Chat Exporter</string>
51
+ <key>CFBundleIconFile</key>
52
+ <string>AppIcon</string>
53
+ <key>CFBundleIconName</key>
54
+ <string>AppIcon</string>
55
+ <key>CFBundleVersion</key>
56
+ <string>$FullVersion </string>
57
+ <key>CFBundleShortVersionString</key>
58
+ <string>$ShortVersion </string>
59
+ <key>NSHighResolutionCapable</key>
60
+ <true />
61
+ <key>CFBundlePackageType</key>
62
+ <string>APPL</string>
63
+ </dict>
64
+ </plist>
65
+ "@
66
+
67
+ Set-Content - Path (Join-Path $contentsDirPath " Info.plist" ) - Value $plistContent
68
+
69
+ # Delete the previous bundle if it exists
70
+ if (Test-Path (Join-Path $PublishDirPath $bundleName )) {
71
+ Remove-Item - Path (Join-Path $PublishDirPath $bundleName ) - Recurse - Force
72
+ }
73
+
74
+ # Move all files from the publish directory into the MacOS directory
75
+ Get-ChildItem - Path $PublishDirPath | ForEach-Object {
76
+ Move-Item - Path $_.FullName - Destination $macosDirPath - Force
77
+ }
78
+
79
+ # Move the final bundle into the publish directory for upload
80
+ Move-Item - Path $bundleDirPath - Destination $PublishDirPath - Force
81
+ }
82
+ finally {
83
+ # Clean up the temporary directory
84
+ Remove-Item - Path $tempDirPath - Recurse - Force
85
+ }
0 commit comments