Skip to content

Update tray.py

Update tray.py #110

name: build uxplay-windows
on:
push:
branches:
- main
workflow_dispatch:
inputs:
tmate_debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
default: false
required: false
type: boolean
jobs:
build:
name: build uxplay
runs-on: windows-latest
permissions:
contents: write
steps:
- name: clone the repo
uses: actions/checkout@v4
- name: download & install Inno Setup
run: |
Invoke-WebRequest https://jrsoftware.org/download.php/is.exe -OutFile is.exe
start (Join-Path -Path $(Get-Location) -ChildPath "is.exe") /VERYSILENT
- name: download+install mDNSResponder libraries
run: |
git clone -b rel/mDNSResponder-214 https://github.com/apple-oss-distributions/mDNSResponder.git --depth 1 mdns214
cp dnssd.vcxproj mdns214\mDNSWindows\DLL\dnssd.vcxproj
& 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe' mdns214\mDNSWindows\DLL\dnssd.vcxproj /p:Configuration=Release /p:Platform=x64
mkdir "C:\Program Files\Bonjour SDK\Include"
mkdir "C:\Program Files\Bonjour SDK\Lib\x64"
cp mdns214\mDNSShared\dns_sd.h "C:\Program Files\Bonjour SDK\Include\dns_sd.h"
cp mdns214\mDNSWindows\DLL\x64\Release\dnssd.lib "C:\Program Files\Bonjour SDK\Lib\x64\dnssd.lib"
# this compiling has errors, but we don't care because all we need is dnssd.lib which gets compiled with no issues
continue-on-error: true
- name: download+install msys2 and related build dependencies
uses: msys2/setup-msys2@v2
with:
update: true
install: >-
git
zip
mingw-w64-x86_64-cmake
mingw-w64-x86_64-gcc
mingw-w64-x86_64-libplist
mingw-w64-x86_64-json-glib
mingw-w64-x86_64-gstreamer
mingw-w64-x86_64-gst-plugins-base
mingw-w64-x86_64-gst-libav
mingw-w64-x86_64-gst-plugins-good
mingw-w64-x86_64-gst-plugins-bad
- name: compiling uxplay (finally)
shell: msys2 {0}
run: |
git clone https://github.com/FDH2/UxPlay && cd UxPlay
mkdir build && cd build
cmake ..
ninja
mkdir artifact && cd artifact
mkdir lib
cp -r /mingw64/lib/gstreamer-1.0 lib/gstreamer-1.0
cp -r /mingw64/bin bin
cp ../uxplay.exe bin
# remove unnecessary DLLs so we get a smaller installer
- name: Prune compilation artifact directory
run: |
$artifactDir = "D:\a\uxplay-windows\uxplay-windows\UxPlay\build\artifact"
$keepListFile = "D:\a\uxplay-windows\uxplay-windows\dll-libs-list.txt"
# Read patterns from the keep list (can include wildcards)
$keepPatterns = @()
Get-Content $keepListFile | ForEach-Object {
$pattern = $_.Trim()
if ($pattern) {
$keepPatterns += $pattern
}
}
Write-Host "Total keep patterns: $($keepPatterns.Count)"
# Get all files currently existing in the target directory and its subdirectories
$allFilesInTarget = Get-ChildItem -Path $artifactDir -Recurse -File
Write-Host "Total files found in target directory before pruning: $($allFilesInTarget.Count)"
$deletedCount = 0
$keptCount = 0
# Iterate through all files and check if they match any keep pattern
foreach ($currentFile in $allFilesInTarget) {
$currentFilePath = $currentFile.FullName
$shouldKeep = $false
# Check if the current file matches any of the keep patterns
foreach ($pattern in $keepPatterns) {
if ($currentFilePath -like $pattern) {
$shouldKeep = $true
$keptCount++
break
}
}
if (-not $shouldKeep) {
Remove-Item $currentFilePath -Force
$deletedCount++
}
}
Write-Host "Cleanup complete! Kept $keptCount files, deleted $deletedCount files." -ForegroundColor Green
Write-Host "`nContents of $artifactDir after pruning:"
Get-ChildItem -Path $artifactDir -Recurse | Select-Object FullName
shell: powershell
# compiling the python tray icon into an .exe
- name: install pyinstaller and dependencies
run: |
python -m venv ./venv
.\venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install pyinstaller pystray
pyinstaller --noconsole --onedir --clean --name uxplay-windows --icon=icon.ico tray.py
cp -r D:\a\uxplay-windows\uxplay-windows\UxPlay\build\artifact\* D:\a\uxplay-windows\uxplay-windows\dist\uxplay-windows\_internal
cp D:\a\uxplay-windows\uxplay-windows\icon.ico D:\a\uxplay-windows\uxplay-windows\dist\uxplay-windows\_internal
- name: compile the installer with inno setup
run: .$(Join-Path -Path ${env:PROGRAMFILES(X86)} -ChildPath 'Inno Setup 6\\ISCC.exe') $(Join-Path -Path $(Get-Location) -ChildPath "script.iss")
- name: uploading artifact
uses: actions/upload-artifact@v4
with:
name: uxplay-windows
path: Output\uxplay-windows.exe
# move this between steps for debugging
- name: (optional) Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.tmate_debug_enabled }}