From defdedc9b15120205b89ed4f8c1a9a0d25eb70da Mon Sep 17 00:00:00 2001 From: Mohamed <110548351+oop7@users.noreply.github.com> Date: Wed, 27 Aug 2025 02:52:50 +0300 Subject: [PATCH] update build-windows.yml --- .github/workflows/build-windows.yml | 464 +++++++++++++++------------- 1 file changed, 251 insertions(+), 213 deletions(-) diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index b07500c..366b4a7 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -1,214 +1,252 @@ -name: Build Windows Release - -on: - push: - tags: - - 'v*' - -env: - PYTHON_VERSION: '3.12.10' - -jobs: - build-windows: - runs-on: windows-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Extract version from tag - id: get_version - shell: powershell - run: | - $tag = "${{ github.ref_name }}" - $version = $tag -replace '^v', '' - Write-Host "Extracted version: $version" - echo "VERSION=$version" >> $env:GITHUB_OUTPUT - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Cache Python dependencies - uses: actions/cache@v3 - with: - path: | - venv - ~\AppData\Local\pip\Cache - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Create virtual environment and install dependencies - shell: powershell - run: | - python -m venv venv - .\venv\Scripts\Activate.ps1 - python -m pip install --upgrade pip - pip install --no-cache-dir -r requirements.txt - pip install --no-cache-dir cx_Freeze - pip install --no-cache-dir yt-dlp - - - name: Update version in setup files - shell: powershell - run: | - $version = "${{ steps.get_version.outputs.VERSION }}" - Write-Host "Updating version to: $version" - - # Update setup.py - $setupContent = Get-Content "build/windows/setup.py" -Raw - $setupContent = $setupContent -replace 'version="[^"]*"', "version=`"$version`"" - Set-Content "build/windows/setup.py" -Value $setupContent - - # Update setup-ffmpeg.py - $setupFFmpegContent = Get-Content "build/windows/setup-ffmpeg.py" -Raw - $setupFFmpegContent = $setupFFmpegContent -replace 'version="[^"]*"', "version=`"$version`"" - Set-Content "build/windows/setup-ffmpeg.py" -Value $setupFFmpegContent - - Write-Host "Version updated in setup files (build script auto-detects version)" - - - name: Build Standard Version (MSI + ZIP) - shell: powershell - run: | - .\venv\Scripts\Activate.ps1 - Write-Host "Building Standard Version..." - - # Clean previous build artifacts - if (Test-Path "build\exe.*") { Remove-Item "build\exe.*" -Recurse -Force } - if (Test-Path "dist") { Remove-Item "dist" -Recurse -Force } - - # Build executable - python build\windows\setup.py build - - # Build MSI installer - python build\windows\setup.py bdist_msi - - # Create ZIP distribution - $exeDir = Get-ChildItem -Path "build" -Directory -Filter "exe.*" | Select-Object -First 1 - if ($exeDir) { - $version = "${{ steps.get_version.outputs.VERSION }}" - Compress-Archive -Path "$($exeDir.FullName)\*" -DestinationPath "dist\YTSage-v$version.zip" -Force - Write-Host "Created ZIP: YTSage-v$version.zip" - } - - - name: Build FFmpeg Version (MSI + ZIP) - shell: powershell - run: | - .\venv\Scripts\Activate.ps1 - Write-Host "Building FFmpeg Version..." - - # Clean previous build artifacts - if (Test-Path "build\exe.*") { Remove-Item "build\exe.*" -Recurse -Force } - if (Test-Path "dist\*.msi") { Remove-Item "dist\*.msi" -Force } - - # Build executable with FFmpeg - python build\windows\setup-ffmpeg.py build - - # Build MSI installer with FFmpeg - python build\windows\setup-ffmpeg.py bdist_msi - - # Create ZIP distribution with FFmpeg - $exeDir = Get-ChildItem -Path "build" -Directory -Filter "exe.*" | Select-Object -First 1 - if ($exeDir) { - $version = "${{ steps.get_version.outputs.VERSION }}" - Compress-Archive -Path "$($exeDir.FullName)\*" -DestinationPath "dist\YTSage-v$version-ffmpeg.zip" -Force - Write-Host "Created ZIP: YTSage-v$version-ffmpeg.zip" - } - - - name: Prepare release artifacts - shell: powershell - run: | - $version = "${{ steps.get_version.outputs.VERSION }}" - - Write-Host "Preparing artifacts for version: $version" - New-Item -ItemType Directory -Path "artifacts" -Force - - # Find and copy standard build artifacts from dist directory - $standardMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -notlike "*ffmpeg*" } | Select-Object -First 1 - if ($standardMsi) { - Copy-Item $standardMsi.FullName "artifacts\YTSage-v$version.msi" - Write-Host "Copied: $($standardMsi.Name) -> YTSage-v$version.msi" - } - - $standardZip = Get-ChildItem -Path "dist" -Filter "YTSage-v$version.zip" | Select-Object -First 1 - if ($standardZip) { - Copy-Item $standardZip.FullName "artifacts\YTSage-v$version.zip" - Write-Host "Copied: $($standardZip.Name) -> YTSage-v$version.zip" - } - - # Find and copy FFmpeg build artifacts from dist directory - $ffmpegMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -like "*ffmpeg*" } | Select-Object -First 1 - if ($ffmpegMsi) { - Copy-Item $ffmpegMsi.FullName "artifacts\YTSage-v$version-ffmpeg.msi" - Write-Host "Copied: $($ffmpegMsi.Name) -> YTSage-v$version-ffmpeg.msi" - } - - $ffmpegZip = Get-ChildItem -Path "dist" -Filter "YTSage-v$version-ffmpeg.zip" | Select-Object -First 1 - if ($ffmpegZip) { - Copy-Item $ffmpegZip.FullName "artifacts\YTSage-v$version-ffmpeg.zip" - Write-Host "Copied: $($ffmpegZip.Name) -> YTSage-v$version-ffmpeg.zip" - } - - # List all artifacts - Write-Host "Final artifacts:" - Get-ChildItem artifacts | ForEach-Object { Write-Host " $($_.Name)" } - - - name: Create draft release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ github.ref_name }} - name: YTSage ${{ github.ref_name }} - draft: true - prerelease: false - body: | - # YTSage ${{ github.ref_name }} - - **Release Date**: ${{ github.event.head_commit.timestamp }} - - ## Downloads - - ### Standard Version - - **YTSage-v${{ steps.get_version.outputs.VERSION }}.msi** - Windows Installer (Recommended) - - **YTSage-v${{ steps.get_version.outputs.VERSION }}.zip** - Portable ZIP (No installation required) - - ### FFmpeg Bundle Version - - **YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi** - Windows Installer with FFmpeg included - - **YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip** - Portable ZIP with FFmpeg included - - ## Installation Instructions - - ### MSI Installer - 1. Download the `.msi` file - 2. Double-click to run the installer - 3. Follow the installation wizard - 4. YTSage will be available in your Start Menu - - ### Portable ZIP - 1. Download the `.zip` file - 2. Extract to your preferred location - 3. Run `YTSage.exe` - - ## System Requirements - - - Windows 10/11 (64-bit) - - .NET Framework (usually pre-installed) - - Internet connection for yt-dlp updates - - ## Notes - - - Standard version: Downloads FFmpeg automatically when needed - - FFmpeg bundle: Includes FFmpeg binaries for offline use - - --- - - **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }} - files: | - artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}.msi - artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}.zip - artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi - artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip - env: +name: Build Windows Release + +on: + push: + tags: + - 'v*' + +env: + PYTHON_VERSION: '3.12.10' + +jobs: + build-windows: + runs-on: windows-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from tag + id: get_version + shell: powershell + run: | + $tag = "${{ github.ref_name }}" + $version = $tag -replace '^v', '' + Write-Host "Extracted version: $version" + echo "VERSION=$version" >> $env:GITHUB_OUTPUT + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Cache Python dependencies + uses: actions/cache@v3 + with: + path: | + venv + ~\AppData\Local\pip\Cache + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Create virtual environment and install dependencies + shell: powershell + run: | + python -m venv venv + .\venv\Scripts\Activate.ps1 + python -m pip install --upgrade pip + pip install --no-cache-dir -r requirements.txt + pip install --no-cache-dir cx_Freeze + pip install --no-cache-dir yt-dlp + + - name: Update version in setup files + shell: powershell + run: | + $version = "${{ steps.get_version.outputs.VERSION }}" + Write-Host "Updating version to: $version" + + # Update setup.py + $setupContent = Get-Content "build/windows/setup.py" -Raw + $setupContent = $setupContent -replace 'version="[^"]*"', "version=`"$version`"" + Set-Content "build/windows/setup.py" -Value $setupContent + + # Update setup-ffmpeg.py + $setupFFmpegContent = Get-Content "build/windows/setup-ffmpeg.py" -Raw + $setupFFmpegContent = $setupFFmpegContent -replace 'version="[^"]*"', "version=`"$version`"" + Set-Content "build/windows/setup-ffmpeg.py" -Value $setupFFmpegContent + + Write-Host "Version updated in setup files (build script auto-detects version)" + + - name: Build Standard Version (MSI + ZIP) + shell: powershell + run: | + .\venv\Scripts\Activate.ps1 + Write-Host "Building Standard Version..." + + # Clean previous build artifacts + if (Test-Path "build\exe.*") { Remove-Item "build\exe.*" -Recurse -Force } + if (Test-Path "dist") { Remove-Item "dist" -Recurse -Force } + + # Build executable + python build\windows\setup.py build + + # Build MSI installer + python build\windows\setup.py bdist_msi + + # Create ZIP distribution + $exeDir = Get-ChildItem -Path "build" -Directory -Filter "exe.*" | Select-Object -First 1 + if ($exeDir) { + $version = "${{ steps.get_version.outputs.VERSION }}" + Compress-Archive -Path "$($exeDir.FullName)\*" -DestinationPath "dist\YTSage-v$version.zip" -Force + Write-Host "Created ZIP: YTSage-v$version.zip" + } + + - name: Setup FFmpeg for bundle + shell: powershell + run: | + Write-Host "Setting up FFmpeg for bundled version..." + + # Create ffmpeg directory + New-Item -ItemType Directory -Path "ffmpeg-temp" -Force + + # Download FFmpeg + $ffmpegUrl = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip" + Write-Host "Downloading FFmpeg from: $ffmpegUrl" + Invoke-WebRequest -Uri $ffmpegUrl -OutFile "ffmpeg-temp\ffmpeg.zip" + + # Extract FFmpeg + Expand-Archive -Path "ffmpeg-temp\ffmpeg.zip" -DestinationPath "ffmpeg-temp" -Force + + # Find the extracted directory (it has a timestamp in the name) + $ffmpegDir = Get-ChildItem -Path "ffmpeg-temp" -Directory | Where-Object { $_.Name -like "ffmpeg-*" } | Select-Object -First 1 + + if ($ffmpegDir) { + # Set environment variable for the build + $ffmpegBinPath = Join-Path $ffmpegDir.FullName "bin" + Write-Host "FFmpeg binaries found at: $ffmpegBinPath" + echo "FFMPEG_PATH=$ffmpegBinPath" >> $env:GITHUB_ENV + + # Verify files exist + $ffmpegExe = Join-Path $ffmpegBinPath "ffmpeg.exe" + $ffprobeExe = Join-Path $ffmpegBinPath "ffprobe.exe" + $ffplayExe = Join-Path $ffmpegBinPath "ffplay.exe" + + if (Test-Path $ffmpegExe) { Write-Host "✓ ffmpeg.exe found" } else { Write-Host "✗ ffmpeg.exe missing" } + if (Test-Path $ffprobeExe) { Write-Host "✓ ffprobe.exe found" } else { Write-Host "✗ ffprobe.exe missing" } + if (Test-Path $ffplayExe) { Write-Host "✓ ffplay.exe found" } else { Write-Host "✗ ffplay.exe missing" } + } else { + Write-Host "Error: Could not find FFmpeg directory after extraction" + exit 1 + } + + - name: Build FFmpeg Version (MSI + ZIP) + shell: powershell + run: | + .\venv\Scripts\Activate.ps1 + Write-Host "Building FFmpeg Version..." + + # Clean previous build artifacts + if (Test-Path "build\exe.*") { Remove-Item "build\exe.*" -Recurse -Force } + if (Test-Path "dist\*.msi") { Remove-Item "dist\*.msi" -Force } + + # Build executable with FFmpeg + python build\windows\setup-ffmpeg.py build + + # Build MSI installer with FFmpeg + python build\windows\setup-ffmpeg.py bdist_msi + + # Create ZIP distribution with FFmpeg + $exeDir = Get-ChildItem -Path "build" -Directory -Filter "exe.*" | Select-Object -First 1 + if ($exeDir) { + $version = "${{ steps.get_version.outputs.VERSION }}" + Compress-Archive -Path "$($exeDir.FullName)\*" -DestinationPath "dist\YTSage-v$version-ffmpeg.zip" -Force + Write-Host "Created ZIP: YTSage-v$version-ffmpeg.zip" + } + + - name: Prepare release artifacts + shell: powershell + run: | + $version = "${{ steps.get_version.outputs.VERSION }}" + + Write-Host "Preparing artifacts for version: $version" + New-Item -ItemType Directory -Path "artifacts" -Force + + # Find and copy standard build artifacts from dist directory + $standardMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -notlike "*ffmpeg*" } | Select-Object -First 1 + if ($standardMsi) { + Copy-Item $standardMsi.FullName "artifacts\YTSage-v$version.msi" + Write-Host "Copied: $($standardMsi.Name) -> YTSage-v$version.msi" + } + + $standardZip = Get-ChildItem -Path "dist" -Filter "YTSage-v$version.zip" | Select-Object -First 1 + if ($standardZip) { + Copy-Item $standardZip.FullName "artifacts\YTSage-v$version.zip" + Write-Host "Copied: $($standardZip.Name) -> YTSage-v$version.zip" + } + + # Find and copy FFmpeg build artifacts from dist directory + $ffmpegMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -like "*ffmpeg*" } | Select-Object -First 1 + if ($ffmpegMsi) { + Copy-Item $ffmpegMsi.FullName "artifacts\YTSage-v$version-ffmpeg.msi" + Write-Host "Copied: $($ffmpegMsi.Name) -> YTSage-v$version-ffmpeg.msi" + } + + $ffmpegZip = Get-ChildItem -Path "dist" -Filter "YTSage-v$version-ffmpeg.zip" | Select-Object -First 1 + if ($ffmpegZip) { + Copy-Item $ffmpegZip.FullName "artifacts\YTSage-v$version-ffmpeg.zip" + Write-Host "Copied: $($ffmpegZip.Name) -> YTSage-v$version-ffmpeg.zip" + } + + # List all artifacts + Write-Host "Final artifacts:" + Get-ChildItem artifacts | ForEach-Object { Write-Host " $($_.Name)" } + + - name: Create draft release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.ref_name }} + name: YTSage ${{ github.ref_name }} + draft: true + prerelease: false + body: | + # YTSage ${{ github.ref_name }} + + **Release Date**: ${{ github.event.head_commit.timestamp }} + + ## Downloads + + ### Standard Version + - **YTSage-v${{ steps.get_version.outputs.VERSION }}.msi** - Windows Installer (Recommended) + - **YTSage-v${{ steps.get_version.outputs.VERSION }}.zip** - Portable ZIP (No installation required) + + ### FFmpeg Bundle Version + - **YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi** - Windows Installer with FFmpeg included + - **YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip** - Portable ZIP with FFmpeg included + + ## Installation Instructions + + ### MSI Installer + 1. Download the `.msi` file + 2. Double-click to run the installer + 3. Follow the installation wizard + 4. YTSage will be available in your Start Menu + + ### Portable ZIP + 1. Download the `.zip` file + 2. Extract to your preferred location + 3. Run `YTSage.exe` + + ## System Requirements + + - Windows 10/11 (64-bit) + - .NET Framework (usually pre-installed) + - Internet connection for yt-dlp updates + + ## Notes + + - Standard version: Downloads FFmpeg automatically when needed + - FFmpeg bundle: Includes FFmpeg binaries for offline use + + --- + + **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.ref_name }} + files: | + artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}.msi + artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}.zip + artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi + artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file