Detach FFmpeg downloading script from the build process
This commit is contained in:
parent
593673cd4b
commit
5f5686e6a0
31
.github/workflows/main.yml
vendored
31
.github/workflows/main.yml
vendored
@ -53,6 +53,11 @@ jobs:
|
||||
bundle-ffmpeg:
|
||||
- true
|
||||
- false
|
||||
include:
|
||||
- bundle-ffmpeg: true
|
||||
artifact-name-base: YoutubeDownloader
|
||||
- bundle-ffmpeg: false
|
||||
artifact-name-base: YoutubeDownloader.Bare
|
||||
exclude:
|
||||
# FFmpeg builds for these platforms are not easily available
|
||||
- bundle-ffmpeg: true
|
||||
@ -76,7 +81,8 @@ jobs:
|
||||
|
||||
- name: Download FFmpeg
|
||||
if: ${{ matrix.bundle-ffmpeg }}
|
||||
run: dotnet build YoutubeDownloader -t:DownloadFFmpeg
|
||||
shell: pwsh
|
||||
run: YoutubeDownloader/DownloadFFmpeg.ps1 -platform ${{ matrix.rid }}
|
||||
|
||||
- name: Publish app
|
||||
run: >
|
||||
@ -91,7 +97,7 @@ jobs:
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
|
||||
with:
|
||||
name: ${{ matrix.bundle-ffmpeg && 'YoutubeDownloader' || 'YoutubeDownloader.Bare' }}.${{ matrix.rid }}
|
||||
name: ${{ matrix.artifact-name-base }}.${{ matrix.rid }}
|
||||
path: YoutubeDownloader/bin/publish
|
||||
if-no-files-found: error
|
||||
|
||||
@ -135,6 +141,11 @@ jobs:
|
||||
bundle-ffmpeg:
|
||||
- true
|
||||
- false
|
||||
include:
|
||||
- bundle-ffmpeg: true
|
||||
artifact-name-base: YoutubeDownloader
|
||||
- bundle-ffmpeg: false
|
||||
artifact-name-base: YoutubeDownloader.Bare
|
||||
exclude:
|
||||
# FFmpeg builds for these platforms are not easily available
|
||||
- bundle-ffmpeg: true
|
||||
@ -151,26 +162,28 @@ jobs:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
|
||||
with:
|
||||
name: ${{ matrix.bundle-ffmpeg && 'YoutubeDownloader' || 'YoutubeDownloader.Bare' }}.${{ matrix.rid }}
|
||||
name: ${{ matrix.artifact-name-base }}.${{ matrix.rid }}
|
||||
path: YoutubeDownloader/
|
||||
|
||||
- name: Set permissions
|
||||
- name: Set permissions (app)
|
||||
if: ${{ !startsWith(matrix.rid, 'win-') }}
|
||||
run: |
|
||||
chmod +x YoutubeDownloader/YoutubeDownloader
|
||||
${{ matrix.bundle-ffmpeg && 'chmod +x YoutubeDownloader/ffmpeg' || '' }}
|
||||
run: chmod +x YoutubeDownloader/YoutubeDownloader
|
||||
|
||||
- name: Set permissions (FFmpeg)
|
||||
if: ${{ !startsWith(matrix.rid, 'win-') && matrix.bundle-ffmpeg }}
|
||||
run: chmod +x YoutubeDownloader/ffmpeg
|
||||
|
||||
- name: Create package
|
||||
# Change into the artifacts directory to avoid including the directory itself in the zip archive
|
||||
working-directory: YoutubeDownloader/
|
||||
run: zip -r ../${{ matrix.bundle-ffmpeg && 'YoutubeDownloader' || 'YoutubeDownloader.Bare' }}.${{ matrix.rid }}.zip .
|
||||
run: zip -r ../${{ matrix.artifact-name-base }}.${{ matrix.rid }}.zip .
|
||||
|
||||
- name: Upload release asset
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: >
|
||||
gh release upload ${{ github.ref_name }}
|
||||
${{ matrix.bundle-ffmpeg && 'YoutubeDownloader' || 'YoutubeDownloader.Bare' }}.${{ matrix.rid }}.zip
|
||||
${{ matrix.artifact-name-base }}.${{ matrix.rid }}.zip
|
||||
--repo ${{ github.event.repository.full_name }}
|
||||
|
||||
notify:
|
||||
|
@ -1,6 +1,3 @@
|
||||
# This script is called from inside an MSBuild task to download FFmpeg binaries:
|
||||
# dotnet build -t:DownloadFFmpeg
|
||||
|
||||
param (
|
||||
[string]$platform,
|
||||
[string]$outputPath
|
||||
@ -8,11 +5,37 @@ param (
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# If the platform is not specified, use the current OS/arch
|
||||
if (-not $platform) {
|
||||
$arch = [Runtime.InteropServices.RuntimeInformation]::OSArchitecture
|
||||
|
||||
if ($isWindows) {
|
||||
$platform = "windows-$arch"
|
||||
} elseif ($isLinux) {
|
||||
$platform = "linux-$arch"
|
||||
} elseif ($isMacOS) {
|
||||
$platform = "osx-$arch"
|
||||
} else {
|
||||
throw "Unsupported platform"
|
||||
}
|
||||
}
|
||||
|
||||
# Normalize platform identifier
|
||||
$platform = $platform.ToLower().Replace("win-", "windows-")
|
||||
|
||||
# If the output path is not specified, use the current directory
|
||||
if (-not $outputPath) {
|
||||
$fileName = if ($platform.Contains("windows-")) { "ffmpeg.exe" } else { "ffmpeg" }
|
||||
$outputPath = "$PSScriptRoot/$fileName"
|
||||
}
|
||||
|
||||
# Delete the existing file if it exists
|
||||
if (Test-Path $outputPath) {
|
||||
Remove-Item $outputPath
|
||||
}
|
||||
|
||||
# Download the archive
|
||||
Write-Host "Downloading FFmpeg..."
|
||||
Write-Host "Downloading FFmpeg for $platform..."
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
$http = New-Object System.Net.WebClient
|
||||
try {
|
||||
|
@ -14,6 +14,11 @@
|
||||
<AvaloniaResource Include="..\favicon.ico" Link="favicon.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="ffmpeg.exe" CopyToOutputDirectory="PreserveNewest" Condition="Exists('ffmpeg.exe')" />
|
||||
<None Include="ffmpeg" CopyToOutputDirectory="PreserveNewest" Condition="Exists('ffmpeg')" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncImageLoader.Avalonia" Version="3.2.1" />
|
||||
<PackageReference Include="Avalonia" Version="11.1.3" />
|
||||
@ -53,28 +58,4 @@
|
||||
<TrimmerRootAssembly Include="WebView.Core" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Task to download FFmpeg -->
|
||||
<PropertyGroup>
|
||||
<FFmpegPlatform>$(RuntimeIdentifier)</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86'">win-x86</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86'">linux-x86</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</FFmpegPlatform>
|
||||
<FFmpegPlatform Condition="'$(FFmpegPlatform)' == '' AND $([MSBuild]::IsOsPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</FFmpegPlatform>
|
||||
<FFmpegFileName Condition="$(FFmpegPlatform.StartsWith('win-'))">ffmpeg.exe</FFmpegFileName>
|
||||
<FFmpegFileName Condition="'$(FFmpegFileName)' == ''">ffmpeg</FFmpegFileName>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="DownloadFFmpeg">
|
||||
<Exec Command="pwsh -ExecutionPolicy Bypass -File "$(ProjectDir)/DownloadFFmpeg.ps1" -Platform $(FFmpegPlatform) -OutputPath "$(ProjectDir)/$(FFmpegFileName)"" LogStandardErrorAsError="true" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="ffmpeg.exe" CopyToOutputDirectory="PreserveNewest" Condition="Exists('ffmpeg.exe')" />
|
||||
<None Include="ffmpeg" CopyToOutputDirectory="PreserveNewest" Condition="Exists('ffmpeg')" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user