diff --git a/.github/workflows/bundle-desktop-windows.yml b/.github/workflows/bundle-desktop-windows.yml new file mode 100644 index 0000000000..28ffcc1699 --- /dev/null +++ b/.github/workflows/bundle-desktop-windows.yml @@ -0,0 +1,140 @@ +name: "Bundle Desktop (Windows)" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + workflow_call: + inputs: + signing: + description: 'Whether to sign the Windows executable' + required: false + type: boolean + default: false + secrets: + WINDOWS_CERTIFICATE: + required: false + WINDOWS_CERTIFICATE_PASSWORD: + required: false + +jobs: + build-desktop-windows: + name: Build Desktop (Windows) + runs-on: windows-latest + + steps: + # 1) Check out source + - name: Checkout repository + uses: actions/checkout@v3 + + # 2) Set up Rust + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + # 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 + uses: actions/setup-node@v3 + with: + node-version: 16 + + # 4) Cache dependencies (optional, can add more paths if needed) + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: | + node_modules + ui/desktop/node_modules + key: ${{ runner.os }}-build-desktop-windows-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-desktop-windows- + + # 5) Install top-level dependencies if a package.json is in root + - name: Install top-level deps + run: | + if (Test-Path package.json) { + npm install + } + + # 6) Build rust for x86_64-pc-windows-gnu + - name: Install MinGW dependencies + run: | + choco install mingw + # Add MinGW to PATH + echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - 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 + run: | + if (!(Test-Path .\target\x86_64-pc-windows-gnu\release\goosed.exe)) { + Write-Error "Windows binary not found."; exit 1; + } + Write-Host "Copying Windows binary and DLLs to ui/desktop/src/bin..." + 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 + Copy-Item "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\libstdc++-6.dll" ui\desktop\src\bin\ + Copy-Item "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\libgcc_s_seh-1.dll" ui\desktop\src\bin\ + Copy-Item "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin\libwinpthread-1.dll" ui\desktop\src\bin\ + + # Copy any other DLLs from the release directory + ls .\target\x86_64-pc-windows-gnu\release\*.dll | ForEach-Object { + Copy-Item $_ ui\desktop\src\bin\ + } + + # 8) Install & build UI desktop + - name: Build desktop UI with npm + run: | + cd ui\desktop + npm install + npm run bundle:windows + + # 9) Copy exe/dll to final out/Goose-win32-x64/resources/bin + - name: Copy exe/dll to out folder + run: | + cd ui\desktop + if (!(Test-Path .\out\Goose-win32-x64\resources\bin)) { + New-Item -ItemType Directory -Path .\out\Goose-win32-x64\resources\bin | Out-Null + } + 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) + - name: Sign Windows executable + # Skip this step by default - enable when we have a certificate + if: inputs.signing && inputs.signing == true + env: + WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }} + WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }} + run: | + # Create a temporary certificate file + $certBytes = [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE) + $certPath = Join-Path -Path $env:RUNNER_TEMP -ChildPath "certificate.pfx" + [IO.File]::WriteAllBytes($certPath, $certBytes) + + # 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 + - name: Upload Windows build artifacts + uses: actions/upload-artifact@v4 + with: + name: desktop-windows-dist + path: ui/desktop/out/Goose-win32-x64/ diff --git a/.github/workflows/bundle-desktop.yml b/.github/workflows/bundle-desktop.yml index 18b23401d3..235da57164 100644 --- a/.github/workflows/bundle-desktop.yml +++ b/.github/workflows/bundle-desktop.yml @@ -201,21 +201,5 @@ jobs: echo "App did not stay open. Possible crash or startup error." exit 1 fi - LOGFILE="$HOME/Library/Application Support/Goose/logs/main.log" - # Print the log and verify "ChatWindow loaded" is in the logs - if [ -f "$LOGFILE" ]; then - echo "===== Log file contents =====" - cat "$LOGFILE" - echo "=============================" - if grep -F "ChatWindow loaded" "$LOGFILE"; then - echo "Confirmed: 'ChatWindow loaded' found in logs!" - else - echo "Did not find 'ChatWindow loaded' in logs. Failing..." - exit 1 - fi - else - echo "No log file found at $LOGFILE. Exiting with failure." - exit 1 - fi # Kill the app to clean up - pkill -f "Goose.app/Contents/MacOS/Goose" \ No newline at end of file + pkill -f "Goose.app/Contents/MacOS/Goose" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d97c7a36c..8b462f051e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,7 +33,7 @@ jobs: path: download_cli.sh # ------------------------------------------------------------ - # 3) Bundle Desktop App (macOS only) + # 3) Bundle Desktop App (macOS) # ------------------------------------------------------------ bundle-desktop: uses: ./.github/workflows/bundle-desktop.yml @@ -46,13 +46,26 @@ jobs: APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} + # ------------------------------------------------------------ + # 4) Bundle Desktop App (Windows) + # ------------------------------------------------------------ + bundle-desktop-windows: + uses: ./.github/workflows/bundle-desktop-windows.yml + # Signing is disabled by default until we have a certificate + with: + signing: false + # Uncomment and configure these when we have a certificate: + # secrets: + # WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }} + # WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }} + # ------------------------------------ # 4) Create/Update GitHub Release # ------------------------------------ release: name: Release runs-on: ubuntu-latest - needs: [build-cli, install-script, bundle-desktop] + needs: [build-cli, install-script, bundle-desktop, bundle-desktop-windows] permissions: contents: write steps: