-
-
Notifications
You must be signed in to change notification settings - Fork 140
226 lines (203 loc) · 8.96 KB
/
Copy pathbuild-windows.yml
File metadata and controls
226 lines (203 loc) · 8.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Builds the standalone Windows zip for x86_64 and attaches it to the
# GitHub release that triggered the run.
#
# Mirrors build-linux.yml and build-macos.yml. The package bundles EVERYTHING
# (Python runtime, onnxruntime, PyAV/ffmpeg, the ONNX models, embedded
# PostgreSQL via pgserver and embedded Redis), so an installed package needs no
# Docker and no separately-installed database/broker.
#
# The small native build inputs (redis-server.exe, the unaccent/pg_trgm contrib
# modules) are built or downloaded in this workflow, then baked into the bundle
# by windows/AudioMuse-AI.spec.
#
# The ~5 GB of models are NOT in git. This workflow assembles ./model from the
# same GitHub releases the Dockerfile/macOS/Linux builds use, INCLUDING the
# HuggingFace cache (trimmed to just the roberta-base tokenizer the app actually
# loads) so the release assets stay under GitHub's 2 GB per-file limit.
name: Build standalone Windows zip
on:
push:
tags:
- 'v*.*.*' # Build on every version tag
pull_request: # Build on PRs too, to catch bundle breakage early.
types:
- opened
- reopened
- synchronize
workflow_dispatch: # Allow manual runs for testing without a release
concurrency:
group: build-windows-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# Releases the models live on. Bump these in lockstep with the Dockerfile.
MODEL_RELEASE: v5.0.0-model
DCLAP_RELEASE: v1
jobs:
build:
# Skip draft PRs and fork PRs -- the same guard the other build workflows use.
if: >-
github.event_name != 'pull_request' ||
(github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: windows-2022
permissions:
contents: read
env:
ARCH: amd64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Sanity-check runner architecture
shell: powershell
run: |
$got = (Get-WmiObject Win32_Processor).Architecture
Write-Host "CPU Architecture: $got (9=amd64, 12=arm64)"
if ($got -ne 9) {
Write-Error "Expected amd64 runner but got architecture $got"
exit 1
}
- name: Install Python dependencies
shell: powershell
run: |
python -m venv .venv-windows
.venv-windows\Scripts\activate
pip install --upgrade pip
pip install -r requirements/windows.txt
- name: Build vendored redis-server.exe
shell: cmd
run: windows\vendor\build-redis.bat
- name: Verify vendored PostgreSQL contrib is present
shell: powershell
run: |
$dest = "windows\vendor\pg-contrib\$env:ARCH"
$required = @("lib\unaccent.dll", "lib\pg_trgm.dll", "extension\unaccent.control", "extension\pg_trgm.control", "extension\unaccent--1.1.sql", "extension\pg_trgm--1.3.sql", "tsearch_data\unaccent.rules")
$bad = @()
foreach ($f in $required) {
$p = Join-Path $dest $f
if (-not (Test-Path $p) -or (Get-Item $p).Length -eq 0) { $bad += $f }
}
if ($bad.Count -ne 0) {
Write-Error "Missing or empty vendored pg-contrib files: $($bad -join ', '). Regenerate with windows/vendor/pg-contrib/build-pg-contrib-cross.sh -- never ship empty placeholders (they silently disable unaccent/pg_trgm search)."
exit 1
}
Write-Host "Vendored pg-contrib present and non-empty."
- name: Assemble ./model (mirrors the Dockerfile/macOS/Linux models stage)
shell: powershell
env:
GH_TOKEN: ${{ github.token }}
run: |
New-Item -ItemType Directory -Force -Path model | Out-Null
$modelRelease = "$env:MODEL_RELEASE"
$dclapRelease = "$env:DCLAP_RELEASE"
Write-Host "==> musicnn + CLAP text models (from $modelRelease)"
gh release download $modelRelease -R $env:GITHUB_REPOSITORY -D model --clobber `
-p musicnn_embedding.onnx `
-p musicnn_prediction.onnx `
-p clap_text_model.onnx
Write-Host "==> DCLAP audio model (from $dclapRelease in the -DCLAP repo)"
gh release download $dclapRelease -R NeptuneHub/AudioMuse-AI-DCLAP -D model --clobber `
-p model_epoch_36.onnx `
-p model_epoch_36.onnx.data
Write-Host "==> HuggingFace cache (roberta/bert/bart)"
$tmp_hf = Join-Path $env:RUNNER_TEMP "hf_models"
New-Item -ItemType Directory -Force -Path $tmp_hf | Out-Null
gh release download $modelRelease -R $env:GITHUB_REPOSITORY -D $tmp_hf --clobber `
-p huggingface_models.tar.gz
New-Item -ItemType Directory -Force -Path model\huggingface | Out-Null
tar -xzf "$tmp_hf\huggingface_models.tar.gz" -C model\huggingface
if ($LASTEXITCODE -ne 0) { Write-Error "tar failed extracting huggingface models"; exit 1 }
Remove-Item -Recurse -Force $tmp_hf
Write-Host "==> Trim HF cache to just the roberta-base tokenizer (~1.4 GB saved)"
$hf = "model\huggingface\hub"
if (Test-Path "$hf\models--bert-base-uncased") { Remove-Item -Recurse -Force "$hf\models--bert-base-uncased" }
if (Test-Path "$hf\models--facebook--bart-base") { Remove-Item -Recurse -Force "$hf\models--facebook--bart-base" }
$rb = "$hf\models--roberta-base"
if (Test-Path $rb) {
Get-ChildItem -Recurse -File "$rb\blobs" | Where-Object { $_.Length -gt 10MB } | Remove-Item -Force
Get-ChildItem -Recurse "$rb\snapshots" -Include "model.safetensors","pytorch_model.bin" | Remove-Item -Force
}
Write-Host "==> lyrics bundles (whisper / silero / gte)"
$tmp = Join-Path $env:RUNNER_TEMP "lyrics_models"
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
gh release download $modelRelease -R $env:GITHUB_REPOSITORY -D $tmp --clobber `
-p lyrics_model_whisper.tar.gz `
-p lyrics_model_silero_vad.tar.gz `
-p lyrics_model_gte_vnni.tar.gz
foreach ($t in @("lyrics_model_whisper", "lyrics_model_silero_vad", "lyrics_model_gte_vnni")) {
tar -xzf "$tmp\$t.tar.gz" -C model
if ($LASTEXITCODE -ne 0) { Write-Error "tar failed extracting $t"; exit 1 }
}
Remove-Item -Recurse -Force $tmp
- name: Verify the assembled model/ is complete
shell: powershell
run: |
$required = @(
"model\musicnn_embedding.onnx",
"model\musicnn_prediction.onnx",
"model\clap_text_model.onnx",
"model\model_epoch_36.onnx",
"model\model_epoch_36.onnx.data",
"model\huggingface\hub\models--roberta-base\snapshots",
"model\silero_vad.onnx",
"model\gte-multilingual-base-int8.onnx",
"model\whisper-small-onnx\encoder_model.onnx",
"model\whisper-small-onnx\decoder_model_merged.onnx",
"model\gte-multilingual-base\tokenizer.json"
)
$missing = 0
foreach ($f in $required) {
if (-not (Test-Path $f)) {
Write-Error "Missing or empty: $f"
$missing = 1
}
}
if ($missing -ne 0) { Write-Error "Refusing to build an incomplete bundle."; exit 1 }
Write-Host "Model assembly verified."
- name: Build the bundle
shell: powershell
run: |
.venv-windows\Scripts\activate
if ($env:GITHUB_REF_TYPE -eq "tag") {
$ver = $env:GITHUB_REF_NAME -replace '^v', ''
} else {
$ver = "0.0.0"
}
$env:PKG_VERSION = $ver
cmd /c windows\build.bat
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
GITHUB_REF_TYPE: ${{ github.ref_type }}
- name: Upload zip as a workflow artifact
uses: actions/upload-artifact@v4
with:
name: AudioMuse-AI-${{ env.ARCH }}-windows-zip
path: dist/AudioMuse-AI-${{ env.ARCH }}-windows.zip
if-no-files-found: error
# NB: the PR-description "test build links" block is written by the
# dedicated `pr-test-link.yml` workflow (which runs after this build,
# verifies the artifacts exist, and posts the consolidated link block).
# Attach the zip to the release. Runs only for tag pushes.
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download built packages
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Attach packages to the release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/AudioMuse-AI-*-windows.zip
fail_on_unmatched_files: true