Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scripts/release/macos/templates/azure-cli.rb.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cask "azure-cli" do
arch arm: "arm64", intel: "x86_64"
os macos: "macos"

version "{{ version }}"
sha256 arm: "{{ arm64_sha }}",
intel: "{{ x86_64_sha }}"

url "https://github.com/{{ github_repo }}/releases/download/azure-cli-#{version}/azure-cli-#{version}-#{os}-#{arch}.tar.gz"
url "https://github.com/{{ github_repo }}/releases/download/azure-cli-#{version}/azure-cli-#{version}-macos-#{arch}.tar.gz",
verified: "github.com/{{ github_repo }}/"
name "Azure CLI"
desc "Microsoft Azure CLI 2.0"
homepage "https://docs.microsoft.com/cli/azure/overview"
Expand All @@ -19,9 +19,9 @@ cask "azure-cli" do
depends_on formula: "python@{{ python_version }}"

binary "bin/az"
zsh_completion "completions/zsh/_az"
bash_completion "completions/bash/az"
fish_completion "completions/fish/az.fish"
zsh_completion "completions/zsh/_az"

zap trash: "~/.azure"
end
17 changes: 16 additions & 1 deletion src/azure-cli/azure/cli/command_modules/util/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,24 @@ def upgrade_version(cmd, update_all=None, yes=None, allow_preview=None): # pyli
exit_code = subprocess.call(update_cmd)
elif installer == 'HOMEBREW_CASK':
logger.debug("Update homebrew cask")
# Determine cask token: 'azure-cli-preview' (custom tap) or 'azure-cli' (homebrew-cask)
try:
preview_installed = subprocess.call(['brew', 'list', '--cask', 'azure-cli-preview'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0
cli_installed = subprocess.call(['brew', 'list', '--cask', 'azure-cli'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0
if preview_installed:
cask_token = 'azure-cli-preview'
elif cli_installed:
cask_token = 'azure-cli'
else:
raise CLIError(UPGRADE_MSG)
except OSError as ex:
logger.debug("Failed to detect Homebrew cask token: %s", ex)
cask_token = 'azure-cli'
exit_code = subprocess.call(['brew', 'update'])
if exit_code == 0:
update_cmd = ['brew', 'upgrade', '--cask', 'azure-cli']
update_cmd = ['brew', 'upgrade', '--cask', cask_token]
logger.debug("Update azure cli with '%s'", " ".join(update_cmd))
exit_code = subprocess.call(update_cmd)
Comment on lines +135 to 154
Copy link

Copilot AI Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new HOMEBREW_CASK token-detection logic (switching between azure-cli-preview and azure-cli) isn’t covered by tests. Since this path changes which package gets upgraded and can raise CLIError, it would be good to add unit coverage that mocks subprocess.call to validate selection and the failure case (neither cask installed).

Copilot uses AI. Check for mistakes.
elif installer == 'PIP':
Expand Down
Loading