Skip to content

Commit 3348b45

Browse files
authored
Update build.yml
1 parent 4458e2b commit 3348b45

File tree

1 file changed

+51
-19
lines changed

1 file changed

+51
-19
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ name: Build (Windows/macOS/Linux)
33
on:
44
push:
55
branches: [ main, master ]
6-
tags:
7-
- 'v*'
6+
tags: [ 'v*' ]
87
paths:
98
- '**/*.py'
109
- 'lang/**'
@@ -29,18 +28,22 @@ jobs:
2928
- uses: actions/setup-python@v5
3029
with:
3130
python-version: ${{ matrix.python }}
31+
3232
- name: Install OS dependencies (Linux only)
3333
if: startsWith(matrix.os, 'ubuntu')
3434
run: |
3535
sudo apt-get update
3636
sudo apt-get install -y python3-tk
37-
- name: Install Python dependencies
37+
38+
- name: Install Python deps for tests
3839
run: |
3940
python -m pip install --upgrade pip
4041
python -m pip install pytest
42+
4143
- name: Install project requirements (if requirements.txt exists)
4244
if: hashFiles('requirements.txt') != ''
4345
run: python -m pip install -r requirements.txt
46+
4447
- name: Run tests
4548
env:
4649
PYTHONPATH: ${{ github.workspace }}
@@ -59,32 +62,43 @@ jobs:
5962
- uses: actions/setup-python@v5
6063
with:
6164
python-version: '3.11'
65+
6266
- name: Install OS dependencies (Linux only)
6367
if: startsWith(matrix.os, 'ubuntu')
6468
run: |
6569
sudo apt-get update
66-
sudo apt-get install -y python3-tk
67-
- name: Install Python dependencies
70+
sudo apt-get install -y python3-tk zip
71+
72+
- name: Install Python deps for build
6873
run: |
6974
python -m pip install --upgrade pip
7075
python -m pip install pyinstaller
76+
7177
- name: Install project requirements (if requirements.txt exists)
7278
if: hashFiles('requirements.txt') != ''
7379
run: python -m pip install -r requirements.txt
80+
7481
- name: Build with PyInstaller
7582
run: pyinstaller -y yt_audio_workbench.spec
83+
84+
- name: Show dist tree (debug)
85+
shell: bash
86+
run: |
87+
echo "== dist/ contents =="
88+
ls -la dist || true
89+
echo "== one level deeper =="
90+
find dist -maxdepth 2 -mindepth 1 -print || true
91+
92+
# ---------- Windows pack ----------
7693
- name: Pack artifact (Windows)
77-
if: runner.os == 'Windows' # Or: if: startsWith(matrix.os, 'windows')
94+
if: runner.os == 'Windows'
7895
shell: pwsh
7996
run: |
8097
$ErrorActionPreference = 'Stop'
81-
8298
$dist = Join-Path $PWD 'dist'
83-
if (-not (Test-Path $dist)) {
84-
throw "dist/ not found. Did the build step run?"
85-
}
99+
if (-not (Test-Path $dist)) { throw "dist/ not found. Did the build step run?" }
86100
87-
# Prefer a product directory (onedir). Fallback to files (onefile).
101+
# Prefer onedir folder; fallback to onefile(s)
88102
$productDir = Get-ChildItem -Path $dist -Directory | Select-Object -First 1
89103
if ($productDir) {
90104
$zip = "$($productDir.Name)-Windows.zip"
@@ -103,22 +117,40 @@ jobs:
103117
$zipPath = Join-Path $dist $zip
104118
}
105119
106-
# Expose name/path for the upload step
107-
"ZIP_NAME=$(Split-Path -Leaf $zipPath)" | Out-File -FilePath $env:GITHUB_ENV -Append
108120
"ZIP_PATH=$zipPath" | Out-File -FilePath $env:GITHUB_ENV -Append
109121
122+
# ---------- macOS / Linux pack ----------
110123
- name: Pack artifact (macOS/Linux)
111-
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
124+
if: runner.os != 'Windows'
125+
shell: bash
112126
run: |
113-
ZIP_FILENAME="YT-Audio-Workbench-${{ matrix.os }}.zip"
114-
cd dist
115-
zip -r ../"$ZIP_FILENAME" YT-Audio-Workbench
116-
echo "ZIP_PATH=$ZIP_FILENAME" >> $GITHUB_ENV
127+
set -euo pipefail
128+
dist="dist"
129+
[[ -d "$dist" ]] || { echo "dist/ not found"; exit 1; }
130+
131+
# Prefer an app folder (onedir). If none, zip all files (onefile case).
132+
first_dir="$(find "$dist" -mindepth 1 -maxdepth 1 -type d | head -n1 || true)"
133+
if [[ -n "${first_dir:-}" ]]; then
134+
base="$(basename "$first_dir")"
135+
zip_path="$dist/${base}-${{ runner.os }}.zip"
136+
(cd "$first_dir" && zip -r "../$(basename "$zip_path")" .)
137+
else
138+
if ! find "$dist" -mindepth 1 -maxdepth 1 -type f | grep -q .; then
139+
echo "Nothing to pack in dist/"; exit 1
140+
fi
141+
zip_path="$dist/YT-Audio-Workbench-${{ runner.os }}.zip"
142+
(cd "$dist" && zip -r "$(basename "$zip_path")" .)
143+
fi
144+
echo "ZIP_PATH=$zip_path" >> "$GITHUB_ENV"
145+
117146
- name: Upload artifact
118147
uses: actions/upload-artifact@v4
119148
with:
120-
name: YT-Audio-Workbench-${{ matrix.os }}
149+
# unique name prevents 409 conflicts between matrix jobs
150+
name: YT-Audio-Workbench-${{ runner.os }}-${{ github.run_number }}
121151
path: ${{ env.ZIP_PATH }}
152+
if-no-files-found: error
153+
retention-days: 7
122154

123155
release:
124156
name: Release on tag

0 commit comments

Comments
 (0)