Publish MacOS bundle (#659)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
c7cc8dc6ef
commit
a1c0d07a71
24
.github/workflows/main.yml
vendored
24
.github/workflows/main.yml
vendored
@ -98,6 +98,7 @@ 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:DownloadFFmpeg=${{ matrix.bundle-ffmpeg }}
|
-p:DownloadFFmpeg=${{ matrix.bundle-ffmpeg }}
|
||||||
|
-p:PublishMacOSBundle=${{ startsWith(matrix.rid, 'osx-') }}
|
||||||
--output YoutubeDownloader/bin/publish
|
--output YoutubeDownloader/bin/publish
|
||||||
--configuration Release
|
--configuration Release
|
||||||
--runtime ${{ matrix.rid }}
|
--runtime ${{ matrix.rid }}
|
||||||
@ -174,13 +175,24 @@ jobs:
|
|||||||
name: ${{ matrix.artifact-name-base }}.${{ matrix.rid }}
|
name: ${{ matrix.artifact-name-base }}.${{ matrix.rid }}
|
||||||
path: YoutubeDownloader/
|
path: YoutubeDownloader/
|
||||||
|
|
||||||
- name: Set permissions (app)
|
- name: Set permissions
|
||||||
if: ${{ !startsWith(matrix.rid, 'win-') }}
|
if: ${{ !startsWith(matrix.rid, 'win-') }}
|
||||||
run: chmod +x YoutubeDownloader/YoutubeDownloader
|
run: |
|
||||||
|
if [ -f YoutubeDownloader/YoutubeDownloader ]; then
|
||||||
- name: Set permissions (FFmpeg)
|
chmod +x YoutubeDownloader/YoutubeDownloader
|
||||||
if: ${{ !startsWith(matrix.rid, 'win-') && matrix.bundle-ffmpeg }}
|
fi
|
||||||
run: chmod +x YoutubeDownloader/ffmpeg
|
|
||||||
|
if [ -f YoutubeDownloader/YoutubeDownloader.app/Contents/MacOS/YoutubeDownloader ]; then
|
||||||
|
chmod +x YoutubeDownloader/YoutubeDownloader.app/Contents/MacOS/YoutubeDownloader
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f YoutubeDownloader/ffmpeg ]; then
|
||||||
|
chmod +x YoutubeDownloader/ffmpeg
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f YoutubeDownloader/YoutubeDownloader.app/Contents/MacOS/ffmpeg ]; then
|
||||||
|
chmod +x YoutubeDownloader/YoutubeDownloader.app/Contents/MacOS/ffmpeg
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Create package
|
- name: Create package
|
||||||
# Change into the artifacts directory to avoid including the directory itself in the zip archive
|
# Change into the artifacts directory to avoid including the directory itself in the zip archive
|
||||||
|
87
YoutubeDownloader/Publish-MacOSBundle.ps1
Normal file
87
YoutubeDownloader/Publish-MacOSBundle.ps1
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$PublishDirPath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$IconsFilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$FullVersion,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$ShortVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
# Setup paths
|
||||||
|
$tempDirPath = Join-Path $PublishDirPath "../publish-macos-app-temp"
|
||||||
|
$bundleName = "YoutubeDownloader.app"
|
||||||
|
$bundleDirPath = Join-Path $tempDirPath $bundleName
|
||||||
|
$contentsDirPath = Join-Path $bundleDirPath "Contents"
|
||||||
|
$macosDirPath = Join-Path $contentsDirPath "MacOS"
|
||||||
|
$resourcesDirPath = Join-Path $contentsDirPath "Resources"
|
||||||
|
|
||||||
|
try {
|
||||||
|
# Initialize the bundle's directory structure
|
||||||
|
New-Item -Path $bundleDirPath -ItemType Directory -Force
|
||||||
|
New-Item -Path $contentsDirPath -ItemType Directory -Force
|
||||||
|
New-Item -Path $macosDirPath -ItemType Directory -Force
|
||||||
|
New-Item -Path $resourcesDirPath -ItemType Directory -Force
|
||||||
|
|
||||||
|
# Copy icons into the .app's Resources folder
|
||||||
|
Copy-Item -Path $IconsFilePath -Destination (Join-Path $resourcesDirPath "AppIcon.icns") -Force
|
||||||
|
|
||||||
|
# Generate the Info.plist metadata file with the app information
|
||||||
|
$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>YoutubeDownloader</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>YoutubeDownloader</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>YoutubeDownloader</string>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>© Oleksii Holub</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>me.Tyrrrz.YoutubeDownloader</string>
|
||||||
|
<key>CFBundleSpokenName</key>
|
||||||
|
<string>YoutubeDownloader</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>AppIcon</string>
|
||||||
|
<key>CFBundleIconName</key>
|
||||||
|
<string>AppIcon</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>
|
||||||
|
"@
|
||||||
|
|
||||||
|
Set-Content -Path (Join-Path $contentsDirPath "Info.plist") -Value $plistContent
|
||||||
|
|
||||||
|
# Delete the previous bundle if it exists
|
||||||
|
if (Test-Path (Join-Path $PublishDirPath $bundleName)) {
|
||||||
|
Remove-Item -Path (Join-Path $PublishDirPath $bundleName) -Recurse -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Move all files from the publish directory into the MacOS directory
|
||||||
|
Get-ChildItem -Path $PublishDirPath | ForEach-Object {
|
||||||
|
Move-Item -Path $_.FullName -Destination $macosDirPath -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Move the final bundle into the publish directory for upload
|
||||||
|
Move-Item -Path $bundleDirPath -Destination $PublishDirPath -Force
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
# Clean up the temporary directory
|
||||||
|
Remove-Item -Path $tempDirPath -Recurse -Force
|
||||||
|
}
|
@ -69,4 +69,8 @@
|
|||||||
<Exec Command="pwsh -ExecutionPolicy Bypass -File $(ProjectDir)/Download-FFmpeg.ps1 -OutputPath $(ProjectDir)" LogStandardErrorAsError="true" Condition="'$(RuntimeIdentifier)' == ''" />
|
<Exec Command="pwsh -ExecutionPolicy Bypass -File $(ProjectDir)/Download-FFmpeg.ps1 -OutputPath $(ProjectDir)" LogStandardErrorAsError="true" Condition="'$(RuntimeIdentifier)' == ''" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="PublishMacOSBundle" AfterTargets="Publish" Condition="$(PublishMacOSBundle)">
|
||||||
|
<Exec Command="pwsh -ExecutionPolicy Bypass -File $(ProjectDir)/Publish-MacOSBundle.ps1 -PublishDirPath $(PublishDir) -IconsFilePath $(ProjectDir)/../favicon.icns -FullVersion $(Version) -ShortVersion $(AssemblyVersion)" LogStandardErrorAsError="true" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
BIN
favicon.icns
Normal file
BIN
favicon.icns
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user