Skip to content

feat: default to stable version and resolve aliases in install-gh-aw.sh#23628

Merged
pelikhan merged 2 commits intomainfrom
copilot/update-install-gh-aw-script
Mar 31, 2026
Merged

feat: default to stable version and resolve aliases in install-gh-aw.sh#23628
pelikhan merged 2 commits intomainfrom
copilot/update-install-gh-aw-script

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Summary

Updates install-gh-aw.sh to:

  1. Default to "stable" instead of "latest" when no version is specified
  2. Resolve version aliases from .github/aw/releases.json before constructing the download URL — so stablev0.64.5, latestlatest, and any future aliases are resolved transparently

Changes

  • install-gh-aw.sh:
    • Default version changed from "latest" to "stable"
    • Added alias resolution block: fetches https://raw.githubusercontent.com/github/gh-aw/main/.github/aw/releases.json and resolves the version through the aliases map
    • Supports both jq (preferred) and a grep/sed fallback for environments without jq
    • Regex-special characters in VERSION are escaped before using in the grep fallback
    • jq parse failures are surfaced with a print_info message rather than silently ignored
    • Self-referential aliases (e.g. "latest": "latest") emit a print_warning
    • Updated header comments and examples

Copilot AI and others added 2 commits March 31, 2026 03:42
…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>
Copilot AI requested a review from pelikhan March 31, 2026 03:43
@pelikhan pelikhan marked this pull request as ready for review March 31, 2026 03:49
Copilot AI review requested due to automatic review settings March 31, 2026 03:49
@pelikhan pelikhan merged commit 6bf3f5b into main Mar 31, 2026
9 checks passed
@pelikhan pelikhan deleted the copilot/update-install-gh-aw-script branch March 31, 2026 03:50
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 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 latest to stable.
  • Add alias-resolution logic by fetching .github/aw/releases.json, using jq when available and a grep/sed fallback 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) || {
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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) || {

Copilot uses AI. Check for mistakes.
Comment on lines +250 to +252
resolved_version=$(echo "$releases_json" | jq -r ".aliases[\"$VERSION\"] // empty" 2>/dev/null) || {
print_info "jq failed to parse releases.json; alias resolution skipped"
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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')
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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 \).

Suggested change
version_escaped=$(printf '%s' "$VERSION" | sed 's/[.[\*^$]/\\&/g')
version_escaped=$(printf '%s' "$VERSION" | sed 's/[][.[\*^$\\]/\\&/g')

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants