Skip to content

{Packaging} Fix cask template and az upgrade for preview and homebrew-cask migration#33168

Open
naga-nandyala wants to merge 3 commits intoAzure:devfrom
naga-nandyala:naga/cask_upgrade_fix
Open

{Packaging} Fix cask template and az upgrade for preview and homebrew-cask migration#33168
naga-nandyala wants to merge 3 commits intoAzure:devfrom
naga-nandyala:naga/cask_upgrade_fix

Conversation

@naga-nandyala
Copy link
Copy Markdown
Contributor

@naga-nandyala naga-nandyala commented Apr 10, 2026

Summary

Two packaging fixes for the upcoming homebrew-cask migration (Plan B):

1. az upgrade: Detect correct cask token for preview vs production

The current az upgrade hardcodes brew upgrade --cask azure-cli. Under Plan B, preview users install via the azure-cli-preview cask token (from custom tap Azure/homebrew-azure-cli). This fix adds runtime detection so az upgrade uses the correct token.

Change: src/azure-cli/azure/cli/command_modules/util/custom.py

  • Check if azure-cli-preview cask is installed via brew list --cask azure-cli-preview
  • If found, use azure-cli-preview as the cask token; otherwise default to azure-cli

2. Fix cask definition template (azure-cli.rb.in)

Fixes discovered during Homebrew PR #257931:

Change: scripts/release/macos/templates/azure-cli.rb.in

  1. Removed os macos: "macos" stanza — caused Homebrew CI to simulate Linux tags, resulting in sha256: nil audit failure
  2. Hardcoded macos in URL — replaced #{os} interpolation since os stanza is removed
  3. Added verified: parameter to URL — required by Homebrew when URL domain differs from homepage domain
  4. Fixed completion stanza ordering — bash → fish → zsh (alphabetical, per Homebrew style guide)

The updated template now matches the working cask in the custom tap Azure/homebrew-azure-cli.

Testing

  • Verified generated cask output matches the working azure-cli-preview cask in Azure/homebrew-azure-cli
  • az upgrade logic tested with both azure-cli and azure-cli-preview cask tokens

…oduction

During the preview phase (Plan B), the cask is distributed as
`azure-cli-preview` via a custom tap, while post-migration it
becomes `azure-cli` in homebrew-cask. The `az upgrade` command
now checks which cask token is installed and upgrades accordingly.
Copilot AI review requested due to automatic review settings April 10, 2026 04:13
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 10, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Apr 10, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 10, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates az upgrade (util command module) to correctly upgrade Azure CLI when installed via Homebrew cask during the preview-to-production transition, by selecting the installed cask token before running brew upgrade.

Changes:

  • Detect whether azure-cli-preview is installed via Homebrew cask and select the appropriate cask token.
  • Use the detected cask token when invoking brew upgrade --cask ... for HOMEBREW_CASK installs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@naga-nandyala naga-nandyala changed the title [Packaging] az upgrade: Detect correct cask token for preview vs production [Packaging] Fix cask template and az upgrade for homebrew-cask migration (Plan B) Apr 10, 2026
…d narrower exception handling

Address Copilot review feedback:
- Check both azure-cli-preview and azure-cli cask tokens explicitly
- Fail early with UPGRADE_MSG if neither cask is installed
- Catch OSError instead of broad Exception, with debug logging
@naga-nandyala naga-nandyala changed the title [Packaging] Fix cask template and az upgrade for homebrew-cask migration (Plan B) {Packaging} Fix cask template and az upgrade for preview and homebrew-cask migration Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants