-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: switch to windows msvc #7080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
54ce2ef
a830536
6701de9
4cc73d9
a035415
dd9c935
ed77926
924fa5b
364ae9d
961491e
289c06e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| # Platform Build Strategy: | ||
| # - Linux: Uses Ubuntu runner with cross-compilation | ||
| # - macOS: Uses macOS runner with cross-compilation | ||
| # - Windows: Uses Ubuntu runner with Docker cross-compilation (same as desktop build) | ||
| # - Windows: Uses Windows runner with native MSVC build | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
|
|
@@ -56,10 +56,9 @@ jobs: | |
| # Windows builds (only x86_64 supported) | ||
| - os: windows | ||
| architecture: x86_64 | ||
| target-suffix: pc-windows-gnu | ||
| build-on: ubuntu-latest | ||
| target-suffix: pc-windows-msvc | ||
| build-on: windows-latest | ||
|
Comment on lines
56
to
+60
|
||
| use-cross: false | ||
| use-docker: true | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
|
|
@@ -70,6 +69,7 @@ jobs: | |
|
|
||
| - name: Update version in Cargo.toml | ||
| if: ${{ inputs.version != '' }} | ||
| shell: bash | ||
| run: | | ||
| sed -i.bak 's/^version = ".*"/version = "'${{ inputs.version }}'"/' Cargo.toml | ||
| rm -f Cargo.toml.bak | ||
|
|
@@ -85,10 +85,10 @@ jobs: | |
| key: ${{ matrix.architecture }}-${{ matrix.target-suffix }} | ||
|
|
||
| - name: Cache Cargo artifacts (Windows) | ||
| if: matrix.use-docker | ||
| if: matrix.os == 'windows' | ||
| uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2 | ||
| with: | ||
| key: ${{ matrix.architecture }}-${{ matrix.target-suffix }} | ||
| key: windows-msvc-cli | ||
|
|
||
| - name: Build CLI (Linux/macOS) | ||
| if: matrix.use-cross | ||
|
|
@@ -110,110 +110,28 @@ jobs: | |
| export CC="${{ matrix.cc || ''}}" | ||
| cross build --release --target ${TARGET} -p goose-cli | ||
|
|
||
| - name: Build CLI (Windows) | ||
| if: matrix.use-docker | ||
| - name: Setup Rust (Windows) | ||
| if: matrix.os == 'windows' | ||
| shell: bash | ||
| run: | | ||
| echo "🚀 Building Windows CLI executable with enhanced GitHub Actions caching..." | ||
|
|
||
| # Create cache directories | ||
| mkdir -p ~/.cargo/registry ~/.cargo/git | ||
|
|
||
| # Use enhanced caching with GitHub Actions cache mounts | ||
| docker run --rm \ | ||
| -v "$(pwd)":/usr/src/myapp \ | ||
| -v "$HOME/.cargo/registry":/usr/local/cargo/registry \ | ||
| -v "$HOME/.cargo/git":/usr/local/cargo/git \ | ||
| -w /usr/src/myapp \ | ||
| rust:latest \ | ||
| bash -c " | ||
| set -e | ||
| echo '=== Setting up Rust environment with caching ===' | ||
| export CARGO_HOME=/usr/local/cargo | ||
| export PATH=/usr/local/cargo/bin:\$PATH | ||
|
|
||
| # Check if Windows target is already installed in cache | ||
| if rustup target list --installed | grep -q x86_64-pc-windows-gnu; then | ||
| echo '✅ Windows cross-compilation target already installed' | ||
| else | ||
| echo '📦 Installing Windows cross-compilation target...' | ||
| rustup target add x86_64-pc-windows-gnu | ||
| fi | ||
|
|
||
| echo '=== Setting up build dependencies ===' | ||
| apt-get update | ||
| apt-get install -y mingw-w64 protobuf-compiler cmake time | ||
|
|
||
| echo '=== Setting up cross-compilation environment ===' | ||
| 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 | ||
|
|
||
| echo '=== Optimized Cargo configuration ===' | ||
| mkdir -p .cargo | ||
| echo '[build]' > .cargo/config.toml | ||
| echo 'jobs = 4' >> .cargo/config.toml | ||
| echo '' >> .cargo/config.toml | ||
| echo '[target.x86_64-pc-windows-gnu]' >> .cargo/config.toml | ||
| echo 'linker = \"x86_64-w64-mingw32-gcc\"' >> .cargo/config.toml | ||
| echo '' >> .cargo/config.toml | ||
| echo '[net]' >> .cargo/config.toml | ||
| echo 'git-fetch-with-cli = true' >> .cargo/config.toml | ||
| echo 'retry = 3' >> .cargo/config.toml | ||
| echo '' >> .cargo/config.toml | ||
| echo '[profile.release]' >> .cargo/config.toml | ||
| echo 'codegen-units = 1' >> .cargo/config.toml | ||
| echo 'lto = false' >> .cargo/config.toml | ||
| echo 'panic = \"abort\"' >> .cargo/config.toml | ||
| echo 'debug = false' >> .cargo/config.toml | ||
| echo 'opt-level = 2' >> .cargo/config.toml | ||
| echo '' >> .cargo/config.toml | ||
| echo '[registries.crates-io]' >> .cargo/config.toml | ||
| echo 'protocol = \"sparse\"' >> .cargo/config.toml | ||
|
|
||
| echo '=== Building with cached dependencies ===' | ||
| # Check if we have cached build artifacts | ||
| if [ -d target/x86_64-pc-windows-gnu/release/deps ] && [ \"\$(ls -A target/x86_64-pc-windows-gnu/release/deps)\" ]; then | ||
| echo '✅ Found cached build artifacts, performing incremental build...' | ||
| CARGO_INCREMENTAL=1 | ||
| else | ||
| echo '🔨 No cached artifacts found, performing full build...' | ||
| CARGO_INCREMENTAL=0 | ||
| fi | ||
|
|
||
| echo '🔨 Building Windows CLI executable...' | ||
| CARGO_INCREMENTAL=\$CARGO_INCREMENTAL \ | ||
| CARGO_NET_RETRY=3 \ | ||
| CARGO_HTTP_TIMEOUT=60 \ | ||
| RUST_BACKTRACE=1 \ | ||
| cargo build --release --target x86_64-pc-windows-gnu -p goose-cli --jobs 4 | ||
|
|
||
| echo '=== Copying Windows runtime DLLs ===' | ||
| GCC_DIR=\$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*/ | head -n 1) | ||
| cp \"\$GCC_DIR/libstdc++-6.dll\" target/x86_64-pc-windows-gnu/release/ | ||
| cp \"\$GCC_DIR/libgcc_s_seh-1.dll\" target/x86_64-pc-windows-gnu/release/ | ||
| cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll target/x86_64-pc-windows-gnu/release/ | ||
|
|
||
| echo '✅ Build completed successfully!' | ||
| ls -la target/x86_64-pc-windows-gnu/release/ | ||
| " | ||
| rustup show | ||
| rustup target add x86_64-pc-windows-msvc | ||
|
|
||
| sudo chown -R $USER:$USER target/ | ||
| - name: Build CLI (Windows) | ||
| if: matrix.os == 'windows' | ||
| shell: bash | ||
| run: | | ||
| echo "🚀 Building Windows CLI executable..." | ||
| cargo build --release --target x86_64-pc-windows-msvc -p goose-cli | ||
|
Comment on lines
+113
to
+125
|
||
|
|
||
| # Verify build succeeded | ||
| if [ ! -f "./target/x86_64-pc-windows-gnu/release/goose.exe" ]; then | ||
| if [ ! -f "./target/x86_64-pc-windows-msvc/release/goose.exe" ]; then | ||
| echo "❌ Windows CLI binary not found." | ||
| ls -la ./target/x86_64-pc-windows-gnu/release/ || echo "Release directory doesn't exist" | ||
| ls -la ./target/x86_64-pc-windows-msvc/release/ || echo "Release directory doesn't exist" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Windows CLI binary found!" | ||
| ls -la ./target/x86_64-pc-windows-gnu/release/goose.exe | ||
|
|
||
| echo "✅ Windows runtime DLLs:" | ||
| ls -la ./target/x86_64-pc-windows-gnu/release/*.dll | ||
| ls -la ./target/x86_64-pc-windows-msvc/release/goose.exe | ||
|
|
||
| - name: Package CLI (Linux/macOS) | ||
| if: matrix.use-cross | ||
|
|
@@ -233,22 +151,17 @@ jobs: | |
| echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.tar.bz2" >> $GITHUB_ENV | ||
|
|
||
| - name: Package CLI (Windows) | ||
| if: matrix.use-docker | ||
| if: matrix.os == 'windows' | ||
| shell: bash | ||
| run: | | ||
| export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}" | ||
|
|
||
| # Create a directory for the package contents | ||
| mkdir -p "target/${TARGET}/release/goose-package" | ||
|
|
||
| # Copy the goose binary | ||
| cp "target/${TARGET}/release/goose.exe" "target/${TARGET}/release/goose-package/" | ||
|
|
||
| # Copy Windows runtime DLLs | ||
| cp "target/${TARGET}/release/"*.dll "target/${TARGET}/release/goose-package/" | ||
|
|
||
| # Create the zip archive with binary and DLLs | ||
| cd "target/${TARGET}/release" | ||
| zip -r "goose-${TARGET}.zip" goose-package/ | ||
| 7z a -tzip "goose-${TARGET}.zip" goose-package/ | ||
| echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.zip" >> $GITHUB_ENV | ||
|
|
||
| - name: Upload CLI artifact | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflow_dispatchis enabled, so this workflow can now be run directly; please update the header comment that says it “doesn't get triggered on its own” to avoid misleading future maintainers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflow_dispatch:this was for testing. i have removed it after the test