@@ -2,125 +2,139 @@ name: Build (Windows/macOS/Linux)
22
33on :
44 push :
5- branches : [ main ]
5+ branches : [ main, master ]
6+ tags :
7+ - ' v*'
8+ paths :
9+ - ' **/*.py'
10+ - ' lang/**'
11+ - ' HELP.md'
12+ - ' yt_audio_workbench.spec'
13+ - ' .github/workflows/build.yml'
614 pull_request :
7- branches : [ main ]
8-
9- concurrency :
10- group : ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}
11- cancel-in-progress : true
15+ branches : [ main, master ]
16+ workflow_dispatch :
1217
1318jobs :
14- build :
15- name : Build on ${{ matrix.os }}
19+ test :
20+ name : Tests ( ${{ matrix.os }} | py${{ matrix.python }})
1621 runs-on : ${{ matrix.os }}
1722 strategy :
1823 fail-fast : false
1924 matrix :
20- os : [ubuntu-latest, macos-13, windows-latest ]
21-
25+ os : [ubuntu-latest, windows-latest, macos-13, macos-14 ]
26+ python : ['3.11']
2227 steps :
23- - name : Checkout
24- uses : actions/checkout@v4
25-
26- - name : Set up Python
27- uses : actions/setup-python@v5
28+ - uses : actions/checkout@v4
29+ - uses : actions/setup-python@v5
2830 with :
29- python-version : ' 3.11'
30-
31- - name : Upgrade pip
32- run : python -m pip install --upgrade pip
33-
34- - name : Install project deps (if any)
31+ python-version : ${{ matrix.python }}
32+ - name : Install OS dependencies (Linux only)
33+ if : startsWith(matrix.os, 'ubuntu')
3534 run : |
36- if [ -f requirements.txt ]; then
37- python -m pip install -r requirements.txt
38- else
39- echo "No requirements.txt found; installing tools only"
40- fi
41- shell : bash
42-
43- - name : Install dev tools
44- run : python -m pip install pyinstaller ruff mypy bandit pytest
45-
46- - name : Lint (ruff)
47- run : python -m ruff check .
48-
49- - name : Type-check (mypy, lenient)
50- run : python -m mypy --ignore-missing-imports . || true
51-
35+ sudo apt-get update
36+ sudo apt-get install -y python3-tk
37+ - name : Install Python dependencies
38+ run : |
39+ python -m pip install --upgrade pip
40+ python -m pip install pytest
41+ - name : Install project requirements (if requirements.txt exists)
42+ if : hashFiles('requirements.txt') != ''
43+ run : python -m pip install -r requirements.txt
5244 - name : Run tests
5345 env :
54- PYTHONPATH : .
55- run : pytest -q
46+ PYTHONPATH : ${{ github.workspace }}
47+ run : python -m pytest -q
5648
57- - name : Build (PyInstaller)
58- run : pyinstaller --noconfirm --name YT-Audio-Workbench --onefile yt_audio_backup_gui.py
59-
60- - name : List dist (if present)
61- run : |
62- if [ -d dist ]; then
63- ls -la dist
64- find dist -maxdepth 2 -type f -print || true
65- fi
66- shell : bash
67-
68- # ----- Set artifact name per-OS -----
69- - name : Set ZIP_NAME (Windows)
70- if : runner.os == 'Windows'
71- shell : pwsh
49+ build :
50+ name : Build (${{ matrix.os }})
51+ needs : test
52+ runs-on : ${{ matrix.os }}
53+ strategy :
54+ fail-fast : false
55+ matrix :
56+ os : [ubuntu-latest, windows-latest, macos-13, macos-14]
57+ steps :
58+ - uses : actions/checkout@v4
59+ - uses : actions/setup-python@v5
60+ with :
61+ python-version : ' 3.11 '
62+ - name : Install OS dependencies (Linux only)
63+ if : startsWith(matrix.os, 'ubuntu')
7264 run : |
73- "ZIP_NAME=YT-Audio-Workbench-Windows.zip" | Out-File -FilePath $env:GITHUB_ENV -Append
74-
75- - name : Set ZIP_NAME (*nix)
76- if : runner.os != 'Windows'
77- shell : bash
65+ sudo apt-get update
66+ sudo apt-get install -y python3-tk
67+ - name : Install Python dependencies
7868 run : |
79- if [ "${{ runner.os }}" = "macOS" ]; then
80- echo "ZIP_NAME=YT-Audio-Workbench-macOS.zip" >> "$GITHUB_ENV"
81- else
82- echo "ZIP_NAME=YT-Audio-Workbench-Linux.zip" >> "$GITHUB_ENV"
83- fi
84-
85- # ----- Package per-OS -----
86- - name : Zip dist (Windows)
87- if : runner.os == 'Windows'
69+ python -m pip install --upgrade pip
70+ python -m pip install pyinstaller
71+ - name : Install project requirements (if requirements.txt exists)
72+ if : hashFiles('requirements.txt') != ''
73+ run : python -m pip install -r requirements.txt
74+ - name : Build with PyInstaller
75+ run : pyinstaller -y yt_audio_workbench.spec
76+ - name : Pack artifact (Windows)
8877 shell : pwsh
8978 run : |
9079 $ErrorActionPreference = 'Stop'
91- if (-not (Test-Path -Path dist)) { throw "dist/ does not exist" }
92- if (Test-Path -Path "dist\\YT-Audio-Workbench.exe") {
93- $zip = "${{ env.ZIP_NAME }}"
94- Compress-Archive -Path "dist\\YT-Audio-Workbench.exe" -DestinationPath $zip -Force
95- } elseif (Test-Path -Path "dist\\YT-Audio-Workbench\\*") {
96- $zip = "${{ env.ZIP_NAME }}"
97- Compress-Archive -Path "dist\\YT-Audio-Workbench\\*" -DestinationPath $zip -Force
80+
81+ $dist = Join-Path $PWD 'dist'
82+ if (-not (Test-Path $dist)) {
83+ throw "dist/ not found. Did the build step run?"
84+ }
85+
86+ # Prefer a product directory (onedir). Fallback to files (onefile).
87+ $productDir = Get-ChildItem -Path $dist -Directory | Select-Object -First 1
88+ if ($productDir) {
89+ $zip = "$($productDir.Name)-Windows.zip"
90+ Push-Location $productDir.FullName
91+ Compress-Archive -Path * -DestinationPath (Join-Path $dist $zip) -Force
92+ Pop-Location
93+ $zipPath = Join-Path $dist $zip
9894 } else {
99- Get-ChildItem -Recurse dist
100- throw "Could not find PyInstaller output in dist/"
95+ $files = Get-ChildItem -Path $dist -File
96+ if (-not $files) {
97+ $found = (Get-ChildItem -Path $dist | Select-Object -ExpandProperty Name) -join ', '
98+ throw "Nothing to pack in dist/. Found entries: $found"
99+ }
100+ $zip = 'YT-Audio-Workbench-Windows.zip'
101+ Compress-Archive -Path ($files | ForEach-Object { $_.FullName }) -DestinationPath (Join-Path $dist $zip) -Force
102+ $zipPath = Join-Path $dist $zip
101103 }
102104
103- - name : Zip dist (*nix)
104- if : runner.os != 'Windows'
105- shell : bash
106- run : |
107- set -euo pipefail
108- : "${ZIP_NAME:?ZIP_NAME not set}"
109- if [ -f "dist/YT-Audio-Workbench" ]; then
110- zip -j -r "${ZIP_NAME}" "dist/YT-Audio-Workbench"
111- elif [ -d "dist/YT-Audio-Workbench" ]; then
112- zip -r "${ZIP_NAME}" "dist/YT-Audio-Workbench"
113- else
114- echo "dist/ contents:"
115- find dist -maxdepth 2 -print || true
116- echo "Could not find PyInstaller output in dist/"
117- exit 1
118- fi
105+ # Expose name/path for the upload step
106+ "ZIP_NAME=$(Split-Path -Leaf $zipPath)" | Out-File -FilePath $env:GITHUB_ENV -Append
107+ "ZIP_PATH=$zipPath" | Out-File -FilePath $env:GITHUB_ENV -Append
119108
109+ - name : Pack artifact (macOS/Linux)
110+ if : startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
111+ run : |
112+ cd dist
113+ zip -r ../YT-Audio-Workbench-${{ runner.os }}.zip YT-Audio-Workbench
114+ echo "ZIP_NAME=YT-Audio-Workbench-${{ runner.os }}.zip" >> $GITHUB_ENV
120115 - name : Upload artifact
121116 uses : actions/upload-artifact@v4
122117 with :
123- name : ${{ env.ZIP_NAME }}
118+ name : YT-Audio-Workbench- ${{ matrix.os }}
124119 path : ${{ env.ZIP_NAME }}
125- if-no-files-found : error
126- retention-days : 7
120+
121+ release :
122+ name : Release on tag
123+ if : startsWith(github.ref, 'refs/tags/v')
124+ needs : build
125+ runs-on : ubuntu-latest
126+ steps :
127+ - uses : actions/download-artifact@v4
128+ with :
129+ path : artifacts
130+ - name : List artifacts
131+ run : ls -R artifacts
132+ - name : Create GitHub Release
133+ uses : softprops/action-gh-release@v2
134+ with :
135+ draft : false
136+ prerelease : false
137+ files : |
138+ artifacts/**/YT-Audio-Workbench-*.zip
139+ env :
140+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments