ci: flatten bin files to artifact root #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Dev Build (Windows + Vosk) | |
| on: | |
| push: | |
| branches: [ "**" ] | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| windows-dev-build: | |
| runs-on: windows-latest | |
| timeout-minutes: 30 | |
| defaults: | |
| run: | |
| shell: pwsh | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26.3' | |
| - name: Setup MSYS2 (UCRT64) | |
| id: msys2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: true | |
| install: >- | |
| mingw-w64-ucrt-x86_64-gcc | |
| mingw-w64-ucrt-x86_64-tools | |
| - name: Check MSYS2 availability | |
| shell: pwsh | |
| run: | | |
| Get-Command bash -ErrorAction SilentlyContinue | |
| Get-Command gcc -ErrorAction SilentlyContinue | |
| - name: Resolve MSYS2 UCRT bin | |
| run: | | |
| $msysRoot = "${{ steps.msys2.outputs.msys2-location }}" | |
| $ucrtBin = Join-Path $msysRoot "ucrt64\bin" | |
| "MSYS2_ROOT=$msysRoot" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| "MSYS2_UCRT_BIN=$ucrtBin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
| Write-Host "MSYS2 root: $msysRoot" | |
| Write-Host "UCRT bin : $ucrtBin" | |
| - name: Show tool versions | |
| run: | | |
| & (Join-Path $env:MSYS2_UCRT_BIN "gcc.exe") --version | |
| & (Join-Path $env:MSYS2_UCRT_BIN "g++.exe") --version | |
| & (Join-Path $env:MSYS2_UCRT_BIN "dlltool.exe") --version | |
| & (Join-Path $env:MSYS2_UCRT_BIN "objdump.exe") --version | |
| go version | |
| - name: Build with Vosk script | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| ./scripts/build-with-vosk.ps1 -Msys2UcrtBin $env:MSYS2_UCRT_BIN | |
| - name: Dump build stderr on failure | |
| if: failure() | |
| run: | | |
| $p = "bin/build.stderr.log" | |
| if (Test-Path $p) { | |
| Write-Host "===== BEGIN build.stderr.log (tail 400) =====" | |
| Get-Content $p -Tail 4000 | |
| Write-Host "===== END build.stderr.log =====" | |
| } else { | |
| Write-Host "No $p found" | |
| } | |
| - name: Dump build stdout on failure | |
| if: failure() | |
| run: | | |
| $p = "bin/build.stdout.log" | |
| if (Test-Path $p) { | |
| Write-Host "===== BEGIN build.stdout.log (tail 200) =====" | |
| Get-Content $p -Tail 2000 | |
| Write-Host "===== END build.stdout.log =====" | |
| } else { | |
| Write-Host "No $p found" | |
| } | |
| - name: Extract likely linker errors on failure | |
| if: failure() | |
| run: | | |
| $patterns = 'undefined reference|cannot find|-lvosk|ld\.exe|collect2|fatal error|error:|cgo:|runtime/cgo:|gcc: error|clang: error|exit status [0-9]+' | |
| function Show-MatchesWithContext { | |
| param( | |
| [Parameter(Mandatory = $true)][string]$Path, | |
| [Parameter(Mandatory = $true)][string]$Label, | |
| [Parameter(Mandatory = $true)][string]$Pattern, | |
| [int]$Context = 40, | |
| [int]$MaxMatches = 5 | |
| ) | |
| if (-not (Test-Path $Path)) { | |
| Write-Host "No $Path found" | |
| return | |
| } | |
| Write-Host "===== $Label matches =====" | |
| $hits = Select-String -Path $Path -Pattern $Pattern -CaseSensitive:$false | |
| if (-not $hits) { | |
| Write-Host "(no matches)" | |
| return | |
| } | |
| $hits | Select-Object -Last 200 | ForEach-Object { $_.Line } | |
| $lines = Get-Content $Path | |
| $firstHits = $hits | Select-Object -First $MaxMatches | |
| foreach ($h in $firstHits) { | |
| $start = [Math]::Max(1, $h.LineNumber - $Context) | |
| $end = [Math]::Min($lines.Count, $h.LineNumber + $Context) | |
| Write-Host "===== $Label context around line $($h.LineNumber) =====" | |
| for ($i = $start; $i -le $end; $i++) { | |
| Write-Host ("{0,6}: {1}" -f $i, $lines[$i - 1]) | |
| } | |
| } | |
| } | |
| Show-MatchesWithContext -Path "bin/build.stderr.log" -Label "stderr" -Pattern $patterns | |
| Show-MatchesWithContext -Path "bin/build.stdout.log" -Label "stdout" -Pattern $patterns | |
| - name: Prepare dev artifact bundle | |
| run: | | |
| $bundle = ".artifact-bundle" | |
| if (Test-Path $bundle) { Remove-Item -Recurse -Force $bundle } | |
| New-Item -ItemType Directory -Path $bundle | Out-Null | |
| # All files from bin go to artifact root. | |
| Copy-Item -Path "bin/*" -Destination $bundle -Recurse -Force | |
| Copy-Item -Path "config.json" -Destination $bundle -Force | |
| Copy-Item -Path "user" -Destination $bundle -Recurse -Force | |
| Copy-Item -Path "static" -Destination $bundle -Recurse -Force | |
| Copy-Item -Path "README.md" -Destination $bundle -Force | |
| Copy-Item -Path "LICENSE" -Destination $bundle -Force | |
| - name: Upload dev artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: OmniPanel-go-windows-dev | |
| path: | | |
| .artifact-bundle/** | |
| if-no-files-found: warn |