cask "google-cloud-sdk" do arch arm: "arm", intel: "x86_64" version "492.0.0" sha256 arm: "e8aefb9398fe6458cec017fd2d83c8c2a1e6c66fcc8799b0009a4bcee652910d", intel: "f57e353aa5e286aad49ccb63e29efb119b2925dbea8cd6a84a10de208e554f54" url "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-#{version}-darwin-#{arch}.tar.gz" name "Google Cloud SDK" desc "Set of tools to manage resources and applications hosted on Google Cloud" homepage "https://cloud.google.com/sdk/" livecheck do url "https://cloud.google.com/sdk/docs/install-sdk" regex(/latest\s*gcloud\s*CLI\s*version\s*\(v?(\d+(?:\.\d+)+)\)/i) end auto_updates true depends_on formula: "python@3.12" google_cloud_sdk_root = "#{HOMEBREW_PREFIX}/share/google-cloud-sdk" installer script: { executable: "google-cloud-sdk/install.sh", args: [ "--quiet", "--usage-reporting", "false", "--bash-completion", "false", "--path-update", "false", "--rc-path", "false", "--install-python", "false" ], } binary "google-cloud-sdk/bin/bq" binary "google-cloud-sdk/bin/docker-credential-gcloud" binary "google-cloud-sdk/bin/gcloud" binary "google-cloud-sdk/bin/git-credential-gcloud.sh", target: "git-credential-gcloud" binary "google-cloud-sdk/bin/gsutil" binary "google-cloud-sdk/completion.bash.inc", target: "#{HOMEBREW_PREFIX}/etc/bash_completion.d/google-cloud-sdk" binary "google-cloud-sdk/completion.zsh.inc", target: "#{HOMEBREW_PREFIX}/share/zsh/site-functions/_google_cloud_sdk" preflight do FileUtils.cp_r staged_path/"google-cloud-sdk/.", google_cloud_sdk_root, remove_destination: true FileUtils.rm_r(staged_path/"google-cloud-sdk") FileUtils.ln_s google_cloud_sdk_root, (staged_path/"google-cloud-sdk") end postflight do # HACK: Allow existing shell profiles to work by linking the current version to the `latest` directory. unless (latest_path = staged_path.dirname/"latest").directory? FileUtils.ln_s staged_path, latest_path, force: true end end uninstall delete: staged_path.dirname/"latest" zap trash: [ "#{google_cloud_sdk_root}.staging", google_cloud_sdk_root, ] end