[minor-fixes] azd update: infer channel from binary version and block PR builds#7011
Conversation
Two fixes for azd update: 1. Channel auto-detection: LoadUpdateConfig() defaults to ChannelStable when no config exists, causing daily builds to check the wrong update source and display 'stable channel'. Add inferChannelFromVersion() that detects 'daily.' in the binary version string. Both azd update and the background auto-update check now use the correct channel by default. Explicit config still takes precedence. 2. Block PR builds: Replace IsDevVersion() with IsNonProdVersion() guard in update.go and main.go so both dev builds (0.0.0-dev.0) and PR builds (1.24.0-beta.1-pr.XXXXX) are blocked from self-updating. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR delivers two follow-up fixes to the azd update feature introduced in #6942:
- Channel auto-detection:
LoadUpdateConfig()previously hardcodedChannelStableas the default, causing daily builds to incorrectly check the stable update source. NowinferChannelFromVersion()is called to derive the default channel from the running binary's version string (detecting"daily."in the prerelease segment). - Block PR builds from self-updating: Guards in
main.goandcmd/update.goare switched fromIsDevVersion()toIsNonProdVersion()so that PR builds (with-pr.prerelease tags) are also excluded from auto-update and theazd updatecommand, in addition to local dev builds.
Changes:
inferChannelFromVersion()/inferChannelFromVersionString()helpers added toconfig.goto infer the default update channel from the binary version.- All
IsDevVersion()guards in update-related code paths replaced withIsNonProdVersion()to cover both dev and PR builds. - Tests added for the new
inferChannelFromVersionStringhelper.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cli/azd/pkg/update/config.go |
Adds inferChannelFromVersion()/inferChannelFromVersionString() and uses them as the default channel in LoadUpdateConfig() |
cli/azd/pkg/update/config_test.go |
Adds TestInferChannelFromVersion table-driven tests for the new helper |
cli/azd/main.go |
Switches auto-update banner/apply guards from IsDevVersion() to IsNonProdVersion(); updates log message |
cli/azd/cmd/update.go |
Switches azd update entrypoint guard from IsDevVersion() to IsNonProdVersion() and updates the error message |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Follow-up to #6942.
azd updateon a daily build says "stable channel" and checks for stable updates instead of daily ones. The channel was hardcoded to default tostablewhen no config was set. Now it looks at the binary version string — if it containsdaily., defaults to daily channel instead. Explicit config still wins.Also switched the dev-build guard from
IsDevVersion()toIsNonProdVersion()so PR builds are also blocked from self-updating (they were slipping through before).All update tests pass, no snapshot changes.
Related: #6721