Refactor Windows build workflow for releases
Simplifies and improves the Windows release workflow by cleaning up version extraction, artifact handling, and release note generation. Artifact naming is now version-specific, redundant steps are removed, and the release draft creation is streamlined with direct body content. Also updates dependency caching and installation commands for better reliability.
This commit is contained in:
@@ -3,24 +3,11 @@ name: Build Windows Release
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- 'v* # Update setup.py
|
- 'v*'
|
||||||
$setupContent = Get-Content "build/windows/setup.py" -Raw
|
|
||||||
$setupContent = $setupContent -replace 'version\s*=\s*["\'][^"\']*["\']', "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\s*=\s*["\'][^"\']*["\']', "version='$version'"
|
|
||||||
Set-Content "build/windows/setup-ffmpeg.py" -Value $setupFFmpegContent
|
|
||||||
|
|
||||||
# Update build script
|
|
||||||
$buildScript = Get-Content "build/windows/windows-build-universal.ps1" -Raw
|
|
||||||
$buildScript = $buildScript -replace '\$SCRIPT_VERSION\s*=\s*["\'][^"\']*["\']', "`$SCRIPT_VERSION = '$version'"
|
|
||||||
Set-Content "build/windows/windows-build-universal.ps1" -Value $buildScripton version tags like v4.8.0, v4.8.1, etc.
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHON_VERSION: '3.12.10'
|
PYTHON_VERSION: '3.12.10'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-windows:
|
build-windows:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -37,61 +24,54 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
$tag = "${{ github.ref_name }}"
|
$tag = "${{ github.ref_name }}"
|
||||||
$version = $tag -replace '^v', ''
|
$version = $tag -replace '^v', ''
|
||||||
|
Write-Host "Extracted version: $version"
|
||||||
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
|
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
|
||||||
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
|
|
||||||
Write-Host "Extracted version: $version from tag: $tag"
|
- name: Setup Python
|
||||||
|
|
||||||
- name: Set up Python ${{ env.PYTHON_VERSION }}
|
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ env.PYTHON_VERSION }}
|
python-version: ${{ env.PYTHON_VERSION }}
|
||||||
|
|
||||||
- name: Cache Python dependencies
|
- name: Cache Python dependencies
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~\AppData\Local\pip\Cache
|
|
||||||
venv
|
venv
|
||||||
key: ${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt') }}
|
~\AppData\Local\pip\Cache
|
||||||
|
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-python-${{ env.PYTHON_VERSION }}-
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Create virtual environment and install dependencies
|
- name: Create virtual environment and install dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
Write-Host "Creating virtual environment..."
|
|
||||||
python -m venv venv
|
python -m venv venv
|
||||||
.\venv\Scripts\Activate.ps1
|
.\venv\Scripts\Activate.ps1
|
||||||
|
|
||||||
Write-Host "Installing dependencies..."
|
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install --no-cache-dir -r requirements.txt
|
||||||
pip install cx_Freeze
|
pip install --no-cache-dir cx_Freeze
|
||||||
|
pip install --no-cache-dir yt-dlp
|
||||||
Write-Host "Verifying installation..."
|
|
||||||
python --version
|
- name: Update version in setup files
|
||||||
pip list
|
|
||||||
|
|
||||||
- name: Update version in source files
|
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
$version = "${{ steps.get_version.outputs.VERSION }}"
|
$version = "${{ steps.get_version.outputs.VERSION }}"
|
||||||
Write-Host "Updating version to: $version"
|
Write-Host "Updating version to: $version"
|
||||||
|
|
||||||
# Update setup.py
|
# Update setup.py
|
||||||
$setupContent = Get-Content "setup.py" -Raw
|
$setupContent = Get-Content "build/windows/setup.py" -Raw
|
||||||
$setupContent = $setupContent -replace 'version\s*=\s*["\'][^"\']*["\']', "version='$version'"
|
$setupContent = $setupContent -replace 'version\s*=\s*["\'][^"\']*["\']', "version='$version'"
|
||||||
Set-Content "setup.py" -Value $setupContent
|
Set-Content "build/windows/setup.py" -Value $setupContent
|
||||||
|
|
||||||
# Update setup-ffmpeg.py
|
# Update setup-ffmpeg.py
|
||||||
$setupFFmpegContent = Get-Content "setup-ffmpeg.py" -Raw
|
$setupFFmpegContent = Get-Content "build/windows/setup-ffmpeg.py" -Raw
|
||||||
$setupFFmpegContent = $setupFFmpegContent -replace 'version\s*=\s*["\'][^"\']*["\']', "version='$version'"
|
$setupFFmpegContent = $setupFFmpegContent -replace 'version\s*=\s*["\'][^"\']*["\']', "version='$version'"
|
||||||
Set-Content "setup-ffmpeg.py" -Value $setupFFmpegContent
|
Set-Content "build/windows/setup-ffmpeg.py" -Value $setupFFmpegContent
|
||||||
|
|
||||||
# Update build scripts version
|
# Update build script
|
||||||
$buildScript = Get-Content "windows-build-universal.ps1" -Raw
|
$buildScript = Get-Content "build/windows/windows-build-universal.ps1" -Raw
|
||||||
$buildScript = $buildScript -replace '\$SCRIPT_VERSION\s*=\s*["\'][^"\']*["\']', "`$SCRIPT_VERSION = '$version'"
|
$buildScript = $buildScript -replace '\$SCRIPT_VERSION\s*=\s*["\'][^"\']*["\']', "`$SCRIPT_VERSION = '$version'"
|
||||||
Set-Content "windows-build-universal.ps1" -Value $buildScript
|
Set-Content "build/windows/windows-build-universal.ps1" -Value $buildScript
|
||||||
|
|
||||||
Write-Host "Version updated in all files"
|
Write-Host "Version updated in all files"
|
||||||
|
|
||||||
@@ -113,119 +93,93 @@ jobs:
|
|||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
$version = "${{ steps.get_version.outputs.VERSION }}"
|
$version = "${{ steps.get_version.outputs.VERSION }}"
|
||||||
|
|
||||||
Write-Host "Preparing artifacts for version: $version"
|
Write-Host "Preparing artifacts for version: $version"
|
||||||
|
New-Item -ItemType Directory -Path "artifacts" -Force
|
||||||
|
|
||||||
# Create artifacts directory
|
# Find and copy standard build artifacts
|
||||||
New-Item -ItemType Directory -Force -Path "artifacts"
|
$standardMsi = Get-ChildItem -Path "releases" -Filter "YTSage-v$version.msi" -Recurse | Select-Object -First 1
|
||||||
|
|
||||||
# List all files in releases directory
|
|
||||||
Write-Host "Files in releases directory:"
|
|
||||||
Get-ChildItem "releases" -Recurse | ForEach-Object { Write-Host $_.FullName }
|
|
||||||
|
|
||||||
# Copy and rename artifacts with proper versioning
|
|
||||||
$standardMsi = Get-ChildItem "releases" -Filter "*YTSage*.msi" | Where-Object { $_.Name -notlike "*ffmpeg*" } | Select-Object -First 1
|
|
||||||
$standardZip = Get-ChildItem "releases" -Filter "*YTSage*portable*.zip" | Where-Object { $_.Name -notlike "*ffmpeg*" } | Select-Object -First 1
|
|
||||||
$ffmpegMsi = Get-ChildItem "releases" -Filter "*ffmpeg*.msi" | Select-Object -First 1
|
|
||||||
$ffmpegZip = Get-ChildItem "releases" -Filter "*ffmpeg*portable*.zip" | Select-Object -First 1
|
|
||||||
|
|
||||||
if ($standardMsi) {
|
if ($standardMsi) {
|
||||||
Copy-Item $standardMsi.FullName "artifacts\YTSage-v$version.msi"
|
Copy-Item $standardMsi.FullName "artifacts\YTSage-v$version.msi"
|
||||||
Write-Host "Copied: $($standardMsi.Name) -> YTSage-v$version.msi"
|
Write-Host "Copied: $($standardMsi.Name) -> YTSage-v$version.msi"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$standardZip = Get-ChildItem -Path "releases" -Filter "YTSage-v$version.zip" -Recurse | Select-Object -First 1
|
||||||
if ($standardZip) {
|
if ($standardZip) {
|
||||||
Copy-Item $standardZip.FullName "artifacts\YTSage-v$version.zip"
|
Copy-Item $standardZip.FullName "artifacts\YTSage-v$version.zip"
|
||||||
Write-Host "Copied: $($standardZip.Name) -> YTSage-v$version.zip"
|
Write-Host "Copied: $($standardZip.Name) -> YTSage-v$version.zip"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Find and copy FFmpeg build artifacts
|
||||||
|
$ffmpegMsi = Get-ChildItem -Path "releases" -Filter "YTSage-v$version-ffmpeg.msi" -Recurse | Select-Object -First 1
|
||||||
if ($ffmpegMsi) {
|
if ($ffmpegMsi) {
|
||||||
Copy-Item $ffmpegMsi.FullName "artifacts\YTSage-v$version-ffmpeg.msi"
|
Copy-Item $ffmpegMsi.FullName "artifacts\YTSage-v$version-ffmpeg.msi"
|
||||||
Write-Host "Copied: $($ffmpegMsi.Name) -> YTSage-v$version-ffmpeg.msi"
|
Write-Host "Copied: $($ffmpegMsi.Name) -> YTSage-v$version-ffmpeg.msi"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ffmpegZip = Get-ChildItem -Path "releases" -Filter "YTSage-v$version-ffmpeg.zip" -Recurse | Select-Object -First 1
|
||||||
if ($ffmpegZip) {
|
if ($ffmpegZip) {
|
||||||
Copy-Item $ffmpegZip.FullName "artifacts\YTSage-v$version-ffmpeg.zip"
|
Copy-Item $ffmpegZip.FullName "artifacts\YTSage-v$version-ffmpeg.zip"
|
||||||
Write-Host "Copied: $($ffmpegZip.Name) -> YTSage-v$version-ffmpeg.zip"
|
Write-Host "Copied: $($ffmpegZip.Name) -> YTSage-v$version-ffmpeg.zip"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Verify artifacts
|
# List all artifacts
|
||||||
Write-Host "Final artifacts:"
|
Write-Host "Final artifacts:"
|
||||||
Get-ChildItem "artifacts" | ForEach-Object {
|
Get-ChildItem artifacts | ForEach-Object { Write-Host " $($_.Name)" }
|
||||||
Write-Host "$($_.Name) - $([math]::Round($_.Length / 1MB, 2)) MB"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Create Release Notes
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
$version = "${{ steps.get_version.outputs.VERSION }}"
|
|
||||||
$tag = "${{ steps.get_version.outputs.TAG }}"
|
|
||||||
$releaseDate = Get-Date -Format "yyyy-MM-dd"
|
|
||||||
|
|
||||||
$releaseNotes = @"
|
|
||||||
# YTSage $version
|
|
||||||
|
|
||||||
Released: $releaseDate
|
- name: Create draft release
|
||||||
|
|
||||||
## Downloads
|
|
||||||
|
|
||||||
### Standard Version
|
|
||||||
- **YTSage-v$version.msi** - Windows Installer (Recommended)
|
|
||||||
- **YTSage-v$version.zip** - Portable ZIP (No installation required)
|
|
||||||
|
|
||||||
### FFmpeg Bundle Version
|
|
||||||
- **YTSage-v$version-ffmpeg.msi** - Windows Installer with FFmpeg included
|
|
||||||
- **YTSage-v$version-ffmpeg.zip** - Portable ZIP with FFmpeg included
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
### MSI Installer (Recommended)
|
|
||||||
1. Download the `.msi` file
|
|
||||||
2. Double-click to install
|
|
||||||
3. Follow the installation wizard
|
|
||||||
|
|
||||||
### 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/v${{ steps.get_version.outputs.VERSION }}...HEAD
|
|
||||||
"@
|
|
||||||
|
|
||||||
Set-Content "artifacts\RELEASE_NOTES.md" -Value $releaseNotes
|
|
||||||
Write-Host "Release notes created"
|
|
||||||
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: windows-release-${{ steps.get_version.outputs.VERSION }}
|
|
||||||
path: artifacts/
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
- name: Create Draft Release
|
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_version.outputs.TAG }}
|
tag_name: ${{ github.ref_name }}
|
||||||
name: YTSage ${{ steps.get_version.outputs.VERSION }}
|
name: YTSage ${{ github.ref_name }}
|
||||||
body_path: artifacts/RELEASE_NOTES.md
|
|
||||||
draft: true
|
draft: true
|
||||||
prerelease: false
|
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: |
|
files: |
|
||||||
artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}.msi
|
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 }}.zip
|
||||||
artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi
|
artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.msi
|
||||||
artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip
|
artifacts/YTSage-v${{ steps.get_version.outputs.VERSION }}-ffmpeg.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
Reference in New Issue
Block a user