diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fad35e8..1bc0dea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,6 +98,7 @@ jobs: -p:Version=${{ github.ref_type == 'tag' && github.ref_name || format('999.9.9-ci-{0}', github.sha) }} -p:CSharpier_Bypass=true -p:DownloadFFmpeg=${{ matrix.bundle-ffmpeg }} + -p:PublishMacOSBundle=${{ startsWith(matrix.rid, 'osx-') }} --output YoutubeDownloader/bin/publish --configuration Release --runtime ${{ matrix.rid }} @@ -174,13 +175,24 @@ jobs: name: ${{ matrix.artifact-name-base }}.${{ matrix.rid }} path: YoutubeDownloader/ - - name: Set permissions (app) + - name: Set permissions if: ${{ !startsWith(matrix.rid, 'win-') }} - run: chmod +x YoutubeDownloader/YoutubeDownloader - - - name: Set permissions (FFmpeg) - if: ${{ !startsWith(matrix.rid, 'win-') && matrix.bundle-ffmpeg }} - run: chmod +x YoutubeDownloader/ffmpeg + run: | + if [ -f YoutubeDownloader/YoutubeDownloader ]; then + chmod +x YoutubeDownloader/YoutubeDownloader + fi + + 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 # Change into the artifacts directory to avoid including the directory itself in the zip archive diff --git a/YoutubeDownloader/Publish-MacOSBundle.ps1 b/YoutubeDownloader/Publish-MacOSBundle.ps1 new file mode 100644 index 0000000..9152055 --- /dev/null +++ b/YoutubeDownloader/Publish-MacOSBundle.ps1 @@ -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 = @" + + + + + CFBundleDisplayName + YoutubeDownloader + CFBundleName + YoutubeDownloader + CFBundleExecutable + YoutubeDownloader + NSHumanReadableCopyright + © Oleksii Holub + CFBundleIdentifier + me.Tyrrrz.YoutubeDownloader + CFBundleSpokenName + YoutubeDownloader + CFBundleIconFile + AppIcon + CFBundleIconName + AppIcon + CFBundleVersion + $FullVersion + CFBundleShortVersionString + $ShortVersion + NSHighResolutionCapable + + CFBundlePackageType + APPL + + +"@ + + 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 +} \ No newline at end of file diff --git a/YoutubeDownloader/YoutubeDownloader.csproj b/YoutubeDownloader/YoutubeDownloader.csproj index d59de84..d7c7444 100644 --- a/YoutubeDownloader/YoutubeDownloader.csproj +++ b/YoutubeDownloader/YoutubeDownloader.csproj @@ -69,4 +69,8 @@ + + + + \ No newline at end of file diff --git a/favicon.icns b/favicon.icns new file mode 100644 index 0000000..9677b22 Binary files /dev/null and b/favicon.icns differ