From c0822cfaf5d77288c2b1a224cede1bcfa471194e Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Sun, 11 Oct 2026 18:19:23 +0800 Subject: [PATCH] Free macOS Disk Space Only When the Build Might Not Fit --- .github/workflows/build_orca.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 5797681d99..9ebc319bf9 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -179,6 +179,13 @@ jobs: if: runner.os == 'macOS' && !inputs.macos-combine-only && !vars.SELF_HOSTED run: | df -hI / + # Deleting the unused Xcodes takes minutes, so only do it when the + # build might not fit. A cold build uses under 4 GiB after this step. + avail_gib=$(df -g / | awk 'NR == 2 { print $4 }') + if [ "$avail_gib" -ge 15 ]; then + echo "$avail_gib GiB free, enough for the build" + exit 0 + fi # Keep only the selected Xcode xcode=$(basename "$(cd "$(xcode-select -p)/../.." && pwd -P)") sudo find /Applications -maxdepth 1 -type d -name "Xcode_*.app" ! -name "$xcode" -exec rm -rf {} +