testing windows build (#2770)

This commit is contained in:
Max Novich
2025-06-04 15:12:44 -07:00
committed by GitHub
parent db975fe4bc
commit a24ee7e170
6 changed files with 90 additions and 96 deletions
+68 -87
View File
@@ -1,7 +1,7 @@
name: "Bundle Desktop (Windows)" name: "Bundle Desktop (Windows)"
on: on:
# push: # push:
# branches: [ "main" ] # branches: [ "main" ]
# pull_request: # pull_request:
# branches: [ "main" ] # branches: [ "main" ]
@@ -21,28 +21,20 @@ on:
jobs: jobs:
build-desktop-windows: build-desktop-windows:
name: Build Desktop (Windows) name: Build Desktop (Windows)
runs-on: windows-latest runs-on: ubuntu-latest # Use Ubuntu for cross-compilation
steps: steps:
# 1) Check out source # 1) Check out source
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
# 2) Set up Rust # 2) Set up Node.js
- name: Set up Rust
uses: dtolnay/rust-toolchain@38b70195107dddab2c7bbd522bcf763bac00963b
# If you need a specific version, you could do:
# or uses: actions/setup-rust@v1
# with:
# rust-version: 1.73.0
# 3) Set up Node.js
- name: Set up Node.js - name: Set up Node.js
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # pin@v3 uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # pin@v3
with: with:
node-version: 16 node-version: 18
# 4) Cache dependencies (optional, can add more paths if needed) # 3) Cache dependencies
- name: Cache node_modules - name: Cache node_modules
uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # pin@v3 uses: actions/cache@2f8e54208210a422b2efd51efaa6bd6d7ca8920f # pin@v3
with: with:
@@ -53,103 +45,92 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-build-desktop-windows- ${{ runner.os }}-build-desktop-windows-
# 5) Install top-level dependencies if a package.json is in root # 4) Build Rust for Windows using Docker (cross-compilation)
- name: Install top-level deps - name: Build Windows executable using Docker
run: | run: |
if (Test-Path package.json) { echo "Building Windows executable using Docker cross-compilation..."
npm install docker volume create goose-windows-cache || true
} docker run --rm \
-v "$(pwd)":/usr/src/myapp \
-v goose-windows-cache:/usr/local/cargo/registry \
-w /usr/src/myapp \
rust:latest \
sh -c "rustup target add x86_64-pc-windows-gnu && \
apt-get update && \
apt-get install -y mingw-w64 protobuf-compiler cmake && \
export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc && \
export CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++ && \
export AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc && \
export PKG_CONFIG_ALLOW_CROSS=1 && \
export PROTOC=/usr/bin/protoc && \
export PATH=/usr/bin:\$PATH && \
protoc --version && \
cargo build --release --target x86_64-pc-windows-gnu && \
GCC_DIR=\$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*/ | head -n 1) && \
cp \$GCC_DIR/libstdc++-6.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \
cp \$GCC_DIR/libgcc_s_seh-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/"
# 6) Build rust for x86_64-pc-windows-gnu # 5) Prepare Windows binary and DLLs
- name: Install MinGW dependencies
run: |
choco install mingw --version=8.1.0
# Debug - check installation paths
Write-Host "Checking MinGW installation..."
Get-ChildItem -Path "C:\ProgramData\chocolatey\lib\mingw" -Recurse -Filter "*.dll" | ForEach-Object {
Write-Host $_.FullName
}
Get-ChildItem -Path "C:\tools" -Recurse -Filter "*.dll" | ForEach-Object {
Write-Host $_.FullName
}
- name: Cargo build for Windows
run: |
cargo build --release --target x86_64-pc-windows-gnu
# 7) Check that the compiled goosed.exe exists and copy exe/dll to ui/desktop/src/bin
- name: Prepare Windows binary and DLLs - name: Prepare Windows binary and DLLs
run: | run: |
if (!(Test-Path .\target\x86_64-pc-windows-gnu\release\goosed.exe)) { if [ ! -f "./target/x86_64-pc-windows-gnu/release/goosed.exe" ]; then
Write-Error "Windows binary not found."; exit 1; echo "Windows binary not found."
} exit 1
Write-Host "Copying Windows binary and DLLs to ui/desktop/src/bin..." fi
if (!(Test-Path ui\desktop\src\bin)) {
New-Item -ItemType Directory -Path ui\desktop\src\bin | Out-Null
}
Copy-Item .\target\x86_64-pc-windows-gnu\release\goosed.exe ui\desktop\src\bin\
# Copy MinGW DLLs - try both possible locations echo "Cleaning destination directory..."
$mingwPaths = @( rm -rf ./ui/desktop/src/bin
"C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin", mkdir -p ./ui/desktop/src/bin
"C:\tools\mingw64\bin"
)
foreach ($path in $mingwPaths) { echo "Copying Windows binary and DLLs..."
if (Test-Path "$path\libstdc++-6.dll") { cp -f ./target/x86_64-pc-windows-gnu/release/goosed.exe ./ui/desktop/src/bin/
Write-Host "Found MinGW DLLs in $path" cp -f ./target/x86_64-pc-windows-gnu/release/*.dll ./ui/desktop/src/bin/
Copy-Item "$path\libstdc++-6.dll" ui\desktop\src\bin\
Copy-Item "$path\libgcc_s_seh-1.dll" ui\desktop\src\bin\
Copy-Item "$path\libwinpthread-1.dll" ui\desktop\src\bin\
break
}
}
# Copy any other DLLs from the release directory # Copy Windows platform files (tools, scripts, etc.)
ls .\target\x86_64-pc-windows-gnu\release\*.dll | ForEach-Object { if [ -d "./ui/desktop/src/platform/windows/bin" ]; then
Copy-Item $_ ui\desktop\src\bin\ echo "Copying Windows platform files..."
} for file in ./ui/desktop/src/platform/windows/bin/*.{exe,dll,cmd}; do
if [ -f "$file" ] && [ "$(basename "$file")" != "goosed.exe" ]; then
cp -f "$file" ./ui/desktop/src/bin/
fi
done
if [ -d "./ui/desktop/src/platform/windows/bin/goose-npm" ]; then
echo "Setting up npm environment..."
rsync -a --delete ./ui/desktop/src/platform/windows/bin/goose-npm/ ./ui/desktop/src/bin/goose-npm/
fi
echo "Windows-specific files copied successfully"
fi
# 8) Install & build UI desktop # 6) Install & build UI desktop
- name: Build desktop UI with npm - name: Build desktop UI with npm
run: | run: |
cd ui\desktop cd ui/desktop
npm install npm install
npm run bundle:windows npm run bundle:windows
# 9) Copy exe/dll to final out/Goose-win32-x64/resources/bin # 7) Copy exe/dll to final out/Goose-win32-x64/resources/bin
- name: Copy exe/dll to out folder - name: Copy exe/dll to out folder
run: | run: |
cd ui\desktop cd ui/desktop
if (!(Test-Path .\out\Goose-win32-x64\resources\bin)) { mkdir -p ./out/Goose-win32-x64/resources/bin
New-Item -ItemType Directory -Path .\out\Goose-win32-x64\resources\bin | Out-Null rsync -av src/bin/ out/Goose-win32-x64/resources/bin/
}
Copy-Item .\src\bin\goosed.exe .\out\Goose-win32-x64\resources\bin\
ls .\src\bin\*.dll | ForEach-Object {
Copy-Item $_ .\out\Goose-win32-x64\resources\bin\
}
# 10) Code signing (if enabled) # 8) Code signing (if enabled)
- name: Sign Windows executable - name: Sign Windows executable
# Skip this step by default - enable when we have a certificate
if: inputs.signing && inputs.signing == true if: inputs.signing && inputs.signing == true
env: env:
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }} WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }} WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
run: | run: |
# Create a temporary certificate file # Note: This would need to be adapted for Linux-based signing
$certBytes = [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE) # or moved to a Windows runner for the signing step only
$certPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "certificate.pfx" echo "Code signing would be implemented here"
[IO.File]::WriteAllBytes($certPath, $certBytes) echo "Currently skipped as we're running on Ubuntu"
# Sign the main executable
$signtool = "C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64\signtool.exe"
& $signtool sign /f $certPath /p $env:WINDOWS_CERTIFICATE_PASSWORD /tr http://timestamp.digicert.com /td sha256 /fd sha256 "ui\desktop\out\Goose-win32-x64\Goose.exe"
# Clean up the certificate
Remove-Item -Path $certPath
# 11) Upload the final Windows build # 9) Upload the final Windows build
- name: Upload Windows build artifacts - name: Upload Windows build artifacts
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # pin@v4 uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # pin@v4
with: with:
+5 -1
View File
@@ -23,6 +23,10 @@ target/
./ui/desktop/node_modules ./ui/desktop/node_modules
./ui/desktop/out ./ui/desktop/out
# Generated Goose DLLs (built at build time, not checked in)
ui/desktop/src/bin/goose_ffi.dll
ui/desktop/src/bin/goose_llm.dll
# Hermit # Hermit
.hermit/ .hermit/
@@ -43,4 +47,4 @@ debug_*.txt
benchmark-* benchmark-*
benchconf.json benchconf.json
scripts/fake.sh scripts/fake.sh
do_not_version/ do_not_version/
Generated
+1 -2
View File
@@ -2072,8 +2072,7 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]] [[package]]
name = "crunchy" name = "crunchy"
version = "0.2.3" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/nmathewson/crunchy?branch=cross-compilation-fix#260ec5f08969480c342bb3fe47f88870ed5c6cce"
checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929"
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
+5 -1
View File
@@ -8,4 +8,8 @@ version = "1.0.24"
authors = ["Block <ai-oss-tools@block.xyz>"] authors = ["Block <ai-oss-tools@block.xyz>"]
license = "Apache-2.0" license = "Apache-2.0"
repository = "https://github.com/block/goose" repository = "https://github.com/block/goose"
description = "An AI agent" description = "An AI agent"
# Patch for Windows cross-compilation issue with crunchy
[patch.crates-io]
crunchy = { git = "https://github.com/nmathewson/crunchy", branch = "cross-compilation-fix" }
+2 -4
View File
@@ -46,10 +46,8 @@ pre-build = [
] ]
[target.x86_64-pc-windows-gnu] [target.x86_64-pc-windows-gnu]
image = "dockcross/windows-static-x64:latest" image = "ghcr.io/cross-rs/x86_64-pc-windows-gnu:latest"
# Enable verbose output for Windows builds env = { "RUST_LOG" = "debug", "RUST_BACKTRACE" = "1", "CROSS_VERBOSE" = "1", "PKG_CONFIG_ALLOW_CROSS" = "1" }
build-std = true
env = { "RUST_LOG" = "debug", "RUST_BACKTRACE" = "1", "CROSS_VERBOSE" = "1" }
pre-build = [ pre-build = [
"""\ """\
apt-get update && apt-get install -y \ apt-get update && apt-get install -y \
+9 -1
View File
@@ -25,7 +25,15 @@ release-windows:
rust:latest \ rust:latest \
sh -c "rustup target add x86_64-pc-windows-gnu && \ sh -c "rustup target add x86_64-pc-windows-gnu && \
apt-get update && \ apt-get update && \
apt-get install -y mingw-w64 && \ apt-get install -y mingw-w64 protobuf-compiler cmake && \
export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc && \
export CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++ && \
export AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar && \
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc && \
export PKG_CONFIG_ALLOW_CROSS=1 && \
export PROTOC=/usr/bin/protoc && \
export PATH=/usr/bin:\$PATH && \
protoc --version && \
cargo build --release --target x86_64-pc-windows-gnu && \ cargo build --release --target x86_64-pc-windows-gnu && \
GCC_DIR=\$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*/ | head -n 1) && \ GCC_DIR=\$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*/ | head -n 1) && \
cp \$GCC_DIR/libstdc++-6.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \ cp \$GCC_DIR/libstdc++-6.dll /usr/src/myapp/target/x86_64-pc-windows-gnu/release/ && \