Fix install scripts breaking desktop-wide icons via stub hicolor inde… #17
Workflow file for this run
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: Windows | |
| # Experimental Windows build. Kept in its own workflow so a failure here never | |
| # affects the Linux release pipeline. Produces goto.exe (CGO + whisper.cpp, | |
| # built with the MSYS2/UCRT64 gcc so the static lib links with Go's cgo) and | |
| # attaches it to the release on tags. | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write # needed for `gh release upload` to attach goto.exe | |
| jobs: | |
| windows: | |
| runs-on: windows-latest | |
| defaults: | |
| run: | |
| shell: msys2 {0} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up MSYS2 (UCRT64 toolchain) | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| path-type: inherit # so the msys2 shell also sees the Go from setup-go | |
| update: false # skip the full pacman -Syu: faster, and a stable toolchain keeps the lib cache valid | |
| install: >- | |
| mingw-w64-ucrt-x86_64-gcc | |
| mingw-w64-ucrt-x86_64-cmake | |
| mingw-w64-ucrt-x86_64-ninja | |
| make | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Cache the compiled whisper lib | |
| id: whisper-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: third_party/whisper.cpp/build_go | |
| # rebuilds only when the vendored whisper source / build config changes. | |
| # bump the v1 prefix if a toolchain change ever makes the cached .a stale. | |
| key: win-whisperlib-v1-${{ hashFiles('third_party/whisper.cpp/bindings/go/Makefile', 'third_party/whisper.cpp/CMakeLists.txt', 'third_party/whisper.cpp/src/**', 'third_party/whisper.cpp/ggml/**') }} | |
| - name: Build whisper static lib (MinGW) | |
| if: steps.whisper-cache.outputs.cache-hit != 'true' | |
| run: | | |
| export CMAKE_GENERATOR=Ninja | |
| export CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)" | |
| make lib | |
| - name: Normalize static lib names for MinGW | |
| # On Windows, cmake names the static libs without the "lib" prefix | |
| # (ggml.a, ggml-base.a, ...), but cgo links with -lggml, which needs | |
| # libggml.a. Copy each to a lib-prefixed name. Windows-only; the Linux | |
| # build already produces libggml.a etc. | |
| run: | | |
| for d in third_party/whisper.cpp/build_go/src third_party/whisper.cpp/build_go/ggml/src; do | |
| for f in "$d"/*.a; do | |
| [ -e "$f" ] || continue | |
| base=$(basename "$f") | |
| case "$base" in | |
| lib*) ;; | |
| *) cp -f "$f" "$d/lib$base" ;; | |
| esac | |
| done | |
| done | |
| - name: Embed the app icon (windres -> .syso) | |
| # windres (MinGW binutils) compiles goto.rc into a COFF resource object. | |
| # Named *_windows_amd64.syso, the Go linker auto-includes it only for | |
| # windows/amd64, embedding the icon into goto.exe. | |
| run: windres -O coff -i goto.rc -o rsrc_windows_amd64.syso | |
| - name: Build goto.exe | |
| run: | | |
| export CGO_ENABLED=1 | |
| export C_INCLUDE_PATH="$PWD/third_party/whisper.cpp/include:$PWD/third_party/whisper.cpp/ggml/include" | |
| export LIBRARY_PATH="$PWD/third_party/whisper.cpp/build_go/src:$PWD/third_party/whisper.cpp/build_go/ggml/src" | |
| # ggml is compiled with OpenMP, so the final link needs the OpenMP | |
| # runtime (-fopenmp pulls in libgomp); without it the link fails with | |
| # undefined reference to GOMP_*/omp_*. | |
| export CGO_LDFLAGS="-fopenmp" | |
| # -H windowsgui: no console window for the tray app. | |
| # -extldflags -static: link libgcc/libstdc++/libwinpthread/libgomp | |
| # statically, so the .exe is self-contained and doesn't need MSYS2 | |
| # DLLs (libwinpthread-1.dll, libstdc++-6.dll, ...) on the user's PC. | |
| go build -tags whisper -ldflags '-s -w -H windowsgui -extldflags "-static"' -o goto.exe . | |
| ls -la goto.exe | |
| # sanity: list any remaining non-system DLL deps (best effort) | |
| ldd goto.exe 2>/dev/null | grep -iE 'libwinpthread|libstdc|libgcc|libgomp' && echo "WARNING: still depends on MinGW DLLs" || echo "no MinGW DLL deps (self-contained)" | |
| - name: Build Inno Setup Installer | |
| shell: pwsh | |
| run: | | |
| $ver = if ($env:GITHUB_REF_NAME) { $env:GITHUB_REF_NAME.TrimStart('v') } else { "0.3.16" } | |
| $env:GOTO_VERSION = $ver | |
| & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" packaging/windows/installer.iss | |
| # Rename to include version | |
| $installer = "packaging/windows/Output/goto_installer_windows.exe" | |
| if (Test-Path $installer) { | |
| $versioned = "goto_${ver}_installer_windows.exe" | |
| Copy-Item $installer $versioned | |
| Write-Host "Created: $versioned" | |
| Get-Item $versioned | Format-List Name, Length | |
| } | |
| - name: Attach goto.exe and Installer to the release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| ver="${GITHUB_REF_NAME#v}" | |
| # Upload standalone exe | |
| cp goto.exe "goto_${ver}_windows_amd64.exe" | |
| gh release upload "${GITHUB_REF_NAME}" "goto_${ver}_windows_amd64.exe" --clobber | |
| # Upload the installer | |
| installer="goto_${ver}_installer_windows.exe" | |
| if [ -f "$installer" ]; then | |
| gh release upload "${GITHUB_REF_NAME}" "$installer" --clobber | |
| else | |
| echo "Warning: Installer not found at $installer" | |
| fi | |
| - name: Publish to Chocolatey | |
| if: startsWith(github.ref, 'refs/tags/') | |
| shell: pwsh | |
| env: | |
| CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }} | |
| run: | | |
| $ver = "${env:GITHUB_REF_NAME}".TrimStart('v') | |
| $exe = "goto_${ver}_windows_amd64.exe" | |
| $sha = (Get-FileHash -Algorithm SHA256 $exe).Hash.ToLower() | |
| $choco = "packaging/chocolatey" | |
| $script = "$choco/tools/chocolateyinstall.ps1" | |
| # literal (not regex) replace of the version/checksum placeholders | |
| (Get-Content $script -Raw).Replace('{{VERSION}}', $ver).Replace('{{SHA256}}', $sha) | Set-Content $script | |
| choco pack "$choco/goto-window.nuspec" --version $ver --outputdirectory $choco | |
| if ([string]::IsNullOrEmpty($env:CHOCO_API_KEY)) { | |
| Write-Host "CHOCO_API_KEY not set; packed the .nupkg but not pushing." | |
| exit 0 | |
| } | |
| # The community repo returns 403 for NEW versions while the package's | |
| # first version is still pending human moderation. That's expected and | |
| # NOT a build failure, only fail on unexpected push errors. | |
| $out = (choco push "$choco/goto-window.$ver.nupkg" --source https://push.chocolatey.org/ --api-key $env:CHOCO_API_KEY 2>&1 | Out-String) | |
| Write-Host $out | |
| if ($LASTEXITCODE -ne 0) { | |
| if ($out -match '40[39]|Forbidden|already exists|conflict') { | |
| Write-Host "::warning::Chocolatey push rejected (likely the moderation gate: new versions are blocked until the first version is approved, or this version is already submitted). Not failing the build." | |
| exit 0 | |
| } | |
| Write-Error "Chocolatey push failed for an unexpected reason (see output above)." | |
| exit 1 | |
| } |