Files
SageTube/.github/workflows/build-windows.yml
T
Your Name 29e995eee0 Simplify MSI build options and update version to 4.7.4
Removed problematic summary_data and install_icon from MSI build options in setup.py and setup-ffmpeg.py to address cx_Freeze build issues. Updated target_name and version fields to 4.7.4. Enhanced build-windows.yml with improved artifact cleanup and error handling for MSI creation.
2025-08-27 15:39:00 +03:00

308 lines
12 KiB
YAML

name: Build Windows Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
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`""
$setupContent = $setupContent -replace 'target_name="[^"]*"', "target_name=`"YTSage-v$version.exe`""
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`""
$setupFFmpegContent = $setupFFmpegContent -replace 'target_name="[^"]*"', "target_name=`"YTSage-v$version-ffmpeg.exe`""
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 only)
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 "build\bdist.*") { Remove-Item "build\bdist.*" -Recurse -Force }
if (Test-Path "dist") { Remove-Item "dist" -Recurse -Force }
# Build executable
python build\windows\setup.py build
# Build MSI installer with error handling
Write-Host "Building standard MSI installer..."
Write-Host "Current working directory: $(Get-Location)"
Write-Host "Setup.py path: $(Resolve-Path 'build\windows\setup.py')"
# Run with maximum verbosity to capture any hidden errors
python build\windows\setup.py bdist_msi --verbose
if ($LASTEXITCODE -eq 0) {
Write-Host "Standard MSI build completed successfully"
# List MSI files created
Write-Host "MSI files in dist directory after standard build:"
if (Test-Path "dist") {
$msiFiles = Get-ChildItem -Path "dist" -Filter "*.msi"
if ($msiFiles) {
$msiFiles | ForEach-Object { Write-Host " $($_.Name)" }
} else {
Write-Host " No MSI files found! Attempting alternative build method..."
# Alternative approach: try building without excludes that might cause issues
Write-Host "Retrying MSI build with simplified configuration..."
python build\windows\setup.py bdist_msi --skip-build
if (Test-Path "dist/*.msi") {
Write-Host "Alternative MSI build succeeded!"
Get-ChildItem -Path "dist" -Filter "*.msi" | ForEach-Object { Write-Host " $($_.Name)" }
} else {
Write-Host "ERROR: MSI creation failed completely. Build directory contents:"
if (Test-Path "build") {
Get-ChildItem -Path "build" -Recurse | ForEach-Object { Write-Host " $($_.FullName)" }
}
exit 1
}
}
} else {
Write-Host " No dist directory found!"
exit 1
}
} else {
Write-Host "Error building standard MSI - exit code: $LASTEXITCODE"
exit 1
}
- 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/GyanD/codexffmpeg/releases/download/7.1.1/ffmpeg-7.1.1-full_build.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 (GyanD ffmpeg has specific naming)
$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 "[OK] ffmpeg.exe found"
} else {
Write-Host "[ERROR] ffmpeg.exe missing"
}
if (Test-Path $ffprobeExe) {
Write-Host "[OK] ffprobe.exe found"
} else {
Write-Host "[ERROR] ffprobe.exe missing"
}
if (Test-Path $ffplayExe) {
Write-Host "[OK] ffplay.exe found"
} else {
Write-Host "[ERROR] ffplay.exe missing"
}
} else {
Write-Host "Error: Could not find FFmpeg directory after extraction"
exit 1
}
- name: Build FFmpeg Version (MSI only)
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 "build\bdist.*") { Remove-Item "build\bdist.*" -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 and error handling
Write-Host "Building FFmpeg MSI installer..."
python build\windows\setup-ffmpeg.py bdist_msi
if ($LASTEXITCODE -eq 0) {
Write-Host "FFmpeg MSI build completed successfully"
# List MSI files created
Write-Host "MSI files in dist directory after FFmpeg build:"
if (Test-Path "dist") {
Get-ChildItem -Path "dist" -Filter "*.msi" | ForEach-Object { Write-Host " $($_.Name)" }
}
} else {
Write-Host "Error building FFmpeg MSI - exit code: $LASTEXITCODE"
exit 1
}
- 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
# List all files in dist directory first
Write-Host "Files in dist directory:"
if (Test-Path "dist") {
Get-ChildItem -Path "dist" -Recurse | ForEach-Object { Write-Host " $($_.FullName)" }
} else {
Write-Host " No dist directory found!"
}
# Find and copy standard build artifacts from dist directory
# Look for any MSI file that doesn't contain "ffmpeg" in the name
$standardMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -notlike "*ffmpeg*" -and $_.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"
} else {
Write-Host "Warning: Standard MSI not found"
# List all MSI files for debugging
Write-Host "Available MSI files:"
Get-ChildItem -Path "dist" -Filter "*.msi" | ForEach-Object { Write-Host " $($_.Name)" }
}
# Find and copy FFmpeg build artifacts from dist directory
# Look for any MSI file that contains "ffmpeg" or "FFmpeg" in the name
$ffmpegMsi = Get-ChildItem -Path "dist" -Filter "*.msi" | Where-Object { $_.Name -like "*ffmpeg*" -or $_.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"
} else {
Write-Host "Warning: FFmpeg MSI not found"
}
# List all artifacts
Write-Host "Final artifacts:"
if (Test-Path "artifacts") {
$artifactFiles = Get-ChildItem artifacts
if ($artifactFiles) {
$artifactFiles | ForEach-Object { Write-Host " $($_.Name)" }
} else {
Write-Host " No artifacts created!"
}
} else {
Write-Host " Artifacts directory not found!"
}
- 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 (Downloads FFmpeg when needed)
### FFmpeg Bundle Version
- **YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi** - Windows Installer 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
## 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/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}