66# Platform Build Strategy:
77# - Linux: Uses Ubuntu runner with cross-compilation
88# - macOS: Uses macOS runner with cross-compilation
9- # - Windows: Uses Ubuntu runner with Docker cross-compilation (same as desktop build)
9+ # - Windows: Uses Windows runner with native MSVC build
1010on :
1111 workflow_call :
1212 inputs :
@@ -56,20 +56,19 @@ jobs:
5656 # Windows builds (only x86_64 supported)
5757 - os : windows
5858 architecture : x86_64
59- target-suffix : pc-windows-gnu
60- build-on : ubuntu -latest
59+ target-suffix : pc-windows-msvc
60+ build-on : windows -latest
6161 use-cross : false
62- use-docker : true
6362
6463 steps :
6564 - name : Checkout code
6665 uses : actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
6766 with :
6867 ref : ${{ inputs.ref }}
69- fetch-depth : 0
7068
7169 - name : Update version in Cargo.toml
7270 if : ${{ inputs.version != '' }}
71+ shell : bash
7372 run : |
7473 sed -i.bak 's/^version = ".*"/version = "'${{ inputs.version }}'"/' Cargo.toml
7574 rm -f Cargo.toml.bak
@@ -85,10 +84,10 @@ jobs:
8584 key : ${{ matrix.architecture }}-${{ matrix.target-suffix }}
8685
8786 - name : Cache Cargo artifacts (Windows)
88- if : matrix.use-docker
87+ if : matrix.os == 'windows'
8988 uses : Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
9089 with :
91- key : ${{ matrix.architecture }}-${{ matrix.target-suffix }}
90+ key : windows-msvc-cli
9291
9392 - name : Build CLI (Linux/macOS)
9493 if : matrix.use-cross
@@ -110,110 +109,28 @@ jobs:
110109 export CC="${{ matrix.cc || ''}}"
111110 cross build --release --target ${TARGET} -p goose-cli
112111
113- - name : Build CLI (Windows)
114- if : matrix.use-docker
112+ - name : Setup Rust (Windows)
113+ if : matrix.os == 'windows'
114+ shell : bash
115115 run : |
116- echo "🚀 Building Windows CLI executable with enhanced GitHub Actions caching..."
117-
118- # Create cache directories
119- mkdir -p ~/.cargo/registry ~/.cargo/git
120-
121- # Use enhanced caching with GitHub Actions cache mounts
122- docker run --rm \
123- -v "$(pwd)":/usr/src/myapp \
124- -v "$HOME/.cargo/registry":/usr/local/cargo/registry \
125- -v "$HOME/.cargo/git":/usr/local/cargo/git \
126- -w /usr/src/myapp \
127- rust:latest \
128- bash -c "
129- set -e
130- echo '=== Setting up Rust environment with caching ==='
131- export CARGO_HOME=/usr/local/cargo
132- export PATH=/usr/local/cargo/bin:\$PATH
133-
134- # Check if Windows target is already installed in cache
135- if rustup target list --installed | grep -q x86_64-pc-windows-gnu; then
136- echo '✅ Windows cross-compilation target already installed'
137- else
138- echo '📦 Installing Windows cross-compilation target...'
139- rustup target add x86_64-pc-windows-gnu
140- fi
141-
142- echo '=== Setting up build dependencies ==='
143- apt-get update
144- apt-get install -y mingw-w64 protobuf-compiler cmake time
145-
146- echo '=== Setting up cross-compilation environment ==='
147- export CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc
148- export CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++
149- export AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar
150- export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc
151- export PKG_CONFIG_ALLOW_CROSS=1
152- export PROTOC=/usr/bin/protoc
153-
154- echo '=== Optimized Cargo configuration ==='
155- mkdir -p .cargo
156- echo '[build]' > .cargo/config.toml
157- echo 'jobs = 4' >> .cargo/config.toml
158- echo '' >> .cargo/config.toml
159- echo '[target.x86_64-pc-windows-gnu]' >> .cargo/config.toml
160- echo 'linker = \"x86_64-w64-mingw32-gcc\"' >> .cargo/config.toml
161- echo '' >> .cargo/config.toml
162- echo '[net]' >> .cargo/config.toml
163- echo 'git-fetch-with-cli = true' >> .cargo/config.toml
164- echo 'retry = 3' >> .cargo/config.toml
165- echo '' >> .cargo/config.toml
166- echo '[profile.release]' >> .cargo/config.toml
167- echo 'codegen-units = 1' >> .cargo/config.toml
168- echo 'lto = false' >> .cargo/config.toml
169- echo 'panic = \"abort\"' >> .cargo/config.toml
170- echo 'debug = false' >> .cargo/config.toml
171- echo 'opt-level = 2' >> .cargo/config.toml
172- echo '' >> .cargo/config.toml
173- echo '[registries.crates-io]' >> .cargo/config.toml
174- echo 'protocol = \"sparse\"' >> .cargo/config.toml
175-
176- echo '=== Building with cached dependencies ==='
177- # Check if we have cached build artifacts
178- if [ -d target/x86_64-pc-windows-gnu/release/deps ] && [ \"\$(ls -A target/x86_64-pc-windows-gnu/release/deps)\" ]; then
179- echo '✅ Found cached build artifacts, performing incremental build...'
180- CARGO_INCREMENTAL=1
181- else
182- echo '🔨 No cached artifacts found, performing full build...'
183- CARGO_INCREMENTAL=0
184- fi
185-
186- echo '🔨 Building Windows CLI executable...'
187- CARGO_INCREMENTAL=\$CARGO_INCREMENTAL \
188- CARGO_NET_RETRY=3 \
189- CARGO_HTTP_TIMEOUT=60 \
190- RUST_BACKTRACE=1 \
191- cargo build --release --target x86_64-pc-windows-gnu -p goose-cli --jobs 4
192-
193- echo '=== Copying Windows runtime DLLs ==='
194- GCC_DIR=\$(ls -d /usr/lib/gcc/x86_64-w64-mingw32/*/ | head -n 1)
195- cp \"\$GCC_DIR/libstdc++-6.dll\" target/x86_64-pc-windows-gnu/release/
196- cp \"\$GCC_DIR/libgcc_s_seh-1.dll\" target/x86_64-pc-windows-gnu/release/
197- cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll target/x86_64-pc-windows-gnu/release/
198-
199- echo '✅ Build completed successfully!'
200- ls -la target/x86_64-pc-windows-gnu/release/
201- "
116+ rustup show
117+ rustup target add x86_64-pc-windows-msvc
202118
203- sudo chown -R $USER:$USER target/
119+ - name : Build CLI (Windows)
120+ if : matrix.os == 'windows'
121+ shell : bash
122+ run : |
123+ echo "🚀 Building Windows CLI executable..."
124+ cargo build --release --target x86_64-pc-windows-msvc -p goose-cli
204125
205- # Verify build succeeded
206- if [ ! -f "./target/x86_64-pc-windows-gnu/release/goose.exe" ]; then
126+ if [ ! -f "./target/x86_64-pc-windows-msvc/release/goose.exe" ]; then
207127 echo "❌ Windows CLI binary not found."
208- ls -la ./target/x86_64-pc-windows-gnu /release/ || echo "Release directory doesn't exist"
128+ ls -la ./target/x86_64-pc-windows-msvc /release/ || echo "Release directory doesn't exist"
209129 exit 1
210130 fi
211131
212132 echo "✅ Windows CLI binary found!"
213- ls -la ./target/x86_64-pc-windows-gnu/release/goose.exe
214-
215- echo "✅ Windows runtime DLLs:"
216- ls -la ./target/x86_64-pc-windows-gnu/release/*.dll
133+ ls -la ./target/x86_64-pc-windows-msvc/release/goose.exe
217134
218135 - name : Package CLI (Linux/macOS)
219136 if : matrix.use-cross
@@ -233,22 +150,17 @@ jobs:
233150 echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.tar.bz2" >> $GITHUB_ENV
234151
235152 - name : Package CLI (Windows)
236- if : matrix.use-docker
153+ if : matrix.os == 'windows'
154+ shell : bash
237155 run : |
238156 export TARGET="${{ matrix.architecture }}-${{ matrix.target-suffix }}"
239157
240- # Create a directory for the package contents
241158 mkdir -p "target/${TARGET}/release/goose-package"
242159
243- # Copy the goose binary
244160 cp "target/${TARGET}/release/goose.exe" "target/${TARGET}/release/goose-package/"
245161
246- # Copy Windows runtime DLLs
247- cp "target/${TARGET}/release/"*.dll "target/${TARGET}/release/goose-package/"
248-
249- # Create the zip archive with binary and DLLs
250162 cd "target/${TARGET}/release"
251- zip -r "goose-${TARGET}.zip" goose-package/
163+ 7z a -tzip "goose-${TARGET}.zip" goose-package/
252164 echo "ARTIFACT=target/${TARGET}/release/goose-${TARGET}.zip" >> $GITHUB_ENV
253165
254166 - name : Upload CLI artifact
0 commit comments