feat: default to stable version and resolve aliases in install-gh-aw.sh#23628
feat: default to stable version and resolve aliases in install-gh-aw.sh#23628
Conversation
…n in install-gh-aw.sh Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6a54af1b-4489-41f8-b650-cdc87dfdb9ed Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6a54af1b-4489-41f8-b650-cdc87dfdb9ed Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the install-gh-aw.sh installer to default to a “stable” release channel and to resolve version aliases from the repository’s .github/aw/releases.json before computing download URLs.
Changes:
- Change default install version from
latesttostable. - Add alias-resolution logic by fetching
.github/aw/releases.json, usingjqwhen available and agrep/sedfallback otherwise. - Add logging around alias resolution outcomes (resolved, self-referential, not found, fetch failure).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ -n "$releases_json" ]; then | ||
| resolved_version="" | ||
| if [ "$HAS_JQ" = true ]; then | ||
| resolved_version=$(echo "$releases_json" | jq -r ".aliases[\"$VERSION\"] // empty" 2>/dev/null) || { |
There was a problem hiding this comment.
jq filter is built by interpolating $VERSION directly into the jq program (".aliases["$VERSION"]"), which can break parsing for versions containing quotes/backslashes and allows user-controlled content to alter the jq query. Prefer passing VERSION via --arg and indexing .aliases[$arg] so alias lookup is safe and robust.
| resolved_version=$(echo "$releases_json" | jq -r ".aliases[\"$VERSION\"] // empty" 2>/dev/null) || { | |
| resolved_version=$(echo "$releases_json" | jq -r --arg ver "$VERSION" '.aliases[$ver] // empty' 2>/dev/null) || { |
| resolved_version=$(echo "$releases_json" | jq -r ".aliases[\"$VERSION\"] // empty" 2>/dev/null) || { | ||
| print_info "jq failed to parse releases.json; alias resolution skipped" | ||
| } |
There was a problem hiding this comment.
If jq parsing fails in this block, resolved_version stays empty and the script later reports "No alias found" (even though alias resolution was skipped due to a parse error). Consider tracking a jq-parse-failed flag (or falling back to the grep/sed path on jq failure) so the resulting log/message reflects the actual error condition.
| else | ||
| # Fallback: extract alias value using grep/sed | ||
| # Escape regex special characters in VERSION to avoid unintended matches | ||
| version_escaped=$(printf '%s' "$VERSION" | sed 's/[.[\*^$]/\\&/g') |
There was a problem hiding this comment.
The sed character class used to escape regex metacharacters (s/[.[\*^$]/.../) is not portable: including [ inside a bracket expression without placing it first (or escaping it) can be a syntax error on BSD/macOS sed. That would cause the script to exit under set -e on systems without jq. Use a portable character class (e.g., place ]/[ first and also consider escaping \).
| version_escaped=$(printf '%s' "$VERSION" | sed 's/[.[\*^$]/\\&/g') | |
| version_escaped=$(printf '%s' "$VERSION" | sed 's/[][.[\*^$\\]/\\&/g') |
| print_info "Resolved alias '$VERSION' -> '$resolved_version'" | ||
| VERSION="$resolved_version" | ||
| elif [ -n "$resolved_version" ]; then | ||
| print_warning "Version '$VERSION' is an alias for itself in releases.json (no change); this may indicate a misconfiguration" |
There was a problem hiding this comment.
Given the current .github/aw/releases.json includes a self-referential alias ("latest": "latest"), this branch will emit a WARNING for the common latest case and says it "may indicate a misconfiguration". If self-referential aliases are expected/intentional (at least for latest), consider downgrading this to an info message or special-casing known intentional self-aliases to avoid noisy/misleading warnings.
| print_warning "Version '$VERSION' is an alias for itself in releases.json (no change); this may indicate a misconfiguration" | |
| if [ "$VERSION" = "latest" ]; then | |
| print_info "Version 'latest' is a self-referential alias in releases.json; using 'latest' as-is" | |
| else | |
| print_warning "Version '$VERSION' is an alias for itself in releases.json (no change); this may indicate a misconfiguration" | |
| fi |
Summary
Updates
install-gh-aw.shto:"stable"instead of"latest"when no version is specified.github/aw/releases.jsonbefore constructing the download URL — sostable→v0.64.5,latest→latest, and any future aliases are resolved transparentlyChanges
install-gh-aw.sh:"latest"to"stable"https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/releases.jsonand resolves the version through thealiasesmapjq(preferred) and agrep/sedfallback for environments withoutjqVERSIONare escaped before using in the grep fallbackprint_infomessage rather than silently ignored"latest": "latest") emit aprint_warning