Skip to content
Merged
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
62 changes: 21 additions & 41 deletions actions/setup-cli/install.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions docs/src/content/docs/troubleshooting/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh |

After installation, the binary is installed to `~/.local/share/gh/extensions/gh-aw/gh-aw` and can be used with `gh aw` commands just like the extension installation.

> [!NOTE]
> The install script works in restricted network environments (like GitHub Copilot agent runtime or corporate networks with MITM proxies) by using GitHub's "latest" release redirect, which doesn't require API access. Simply run the script without specifying a version to install the latest release.

### Install Specific Version

To install a specific version, pass the version tag as an argument:

```bash wrap
curl -sL https://raw.githubusercontent.com/github/gh-aw/main/install-gh-aw.sh | \
bash -s -- v0.40.0
```

Find available versions at the [releases page](https://github.com/github/gh-aw/releases).

### Extension Not Found After Installation

If you installed the extension but `gh aw` command is not found:
Expand Down
62 changes: 21 additions & 41 deletions install-gh-aw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

# Script to download and install gh-aw binary for the current OS and architecture
# Supports: Linux, macOS (Darwin), FreeBSD, Windows (Git Bash/MSYS/Cygwin)
# Usage: ./install-gh-aw.sh [version]
# If no version is specified, it will fetch and use the latest release
# Usage: ./install-gh-aw.sh [version] [options]
# If no version is specified, it will use "latest" (GitHub automatically resolves to the latest release)
# Note: Checksum validation is currently skipped by default (will be enabled in future releases)
# Example: ./install-gh-aw.sh v1.0.0
#
# Examples:
# ./install-gh-aw.sh # Install latest version
# ./install-gh-aw.sh v1.0.0 # Install specific version
# ./install-gh-aw.sh --skip-checksum # Skip checksum validation
#
# Options:
# --skip-checksum Skip checksum verification
# --gh-install Try gh extension install first

set -e # Exit on any error

Expand All @@ -25,11 +33,9 @@ for arg in "$@"; do
case $arg in
--skip-checksum)
SKIP_CHECKSUM=true
shift
;;
--gh-install)
TRY_GH_INSTALL=true
shift
;;
*)
if [ -z "$VERSION" ]; then
Expand Down Expand Up @@ -214,48 +220,17 @@ fetch_release_data() {
return 1
}

# Get version (use provided version or fetch latest)
# Get version (use provided version or default to "latest")
# VERSION is already set from argument parsing
REPO="github/gh-aw"

if [ -z "$VERSION" ]; then
print_info "No version specified, fetching latest release information from GitHub..."

if ! LATEST_RELEASE=$(fetch_release_data "https://api.github.com/repos/$REPO/releases/latest"); then
print_error "Failed to fetch latest release information from GitHub API"
print_info "You can specify a version directly: ./install-gh-aw.sh v1.0.0"
exit 1
fi

if [ "$HAS_JQ" = true ]; then
# Use jq for JSON parsing
VERSION=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
RELEASE_NAME=$(echo "$LATEST_RELEASE" | jq -r '.name')
else
# Fallback to grep/sed
VERSION=$(echo "$LATEST_RELEASE" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
RELEASE_NAME=$(echo "$LATEST_RELEASE" | grep '"name"' | sed -E 's/.*"name": *"([^"]+)".*/\1/')
fi

if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
print_error "Failed to parse latest release information"
exit 1
fi

print_info "Latest release: $RELEASE_NAME ($VERSION)"
print_info "No version specified, using 'latest'..."
VERSION="latest"
else
print_info "Using specified version: $VERSION"
fi

# Validate that the release exists
print_info "Validating release $VERSION exists..."
if ! RELEASE_CHECK=$(fetch_release_data "https://api.github.com/repos/$REPO/releases/tags/$VERSION"); then
print_error "Release $VERSION does not exist in $REPO"
print_info "Please check the releases at: https://github.com/$REPO/releases"
exit 1
fi
print_success "Release $VERSION validated"

# Try gh extension install if requested (and gh is available)
if [ "$TRY_GH_INSTALL" = true ] && command -v gh &> /dev/null; then
print_info "Attempting to install gh-aw using 'gh extension install'..."
Expand Down Expand Up @@ -289,8 +264,13 @@ elif [ "$TRY_GH_INSTALL" = true ]; then
fi

# Construct download URL and paths
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$PLATFORM"
CHECKSUMS_URL="https://github.com/$REPO/releases/download/$VERSION/checksums.txt"
if [ "$VERSION" = "latest" ]; then
DOWNLOAD_URL="https://github.com/$REPO/releases/latest/download/$PLATFORM"
CHECKSUMS_URL="https://github.com/$REPO/releases/latest/download/checksums.txt"
else
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$PLATFORM"
CHECKSUMS_URL="https://github.com/$REPO/releases/download/$VERSION/checksums.txt"
fi
if [ "$OS_NAME" = "windows" ]; then
DOWNLOAD_URL="${DOWNLOAD_URL}.exe"
fi
Expand Down
36 changes: 36 additions & 0 deletions scripts/test-install-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,41 @@ else
exit 1
fi

# Test 11: Verify "latest" version functionality
echo ""
echo "Test 11: Verify 'latest' version functionality"

# Check for "latest" as default version
if grep -q "using 'latest'" "$PROJECT_ROOT/install-gh-aw.sh"; then
echo " ✓ PASS: Script uses 'latest' as default version"
else
echo " ✗ FAIL: Script does not use 'latest' as default version"
exit 1
fi

# Check for latest URL construction
if grep -q 'releases/latest/download' "$PROJECT_ROOT/install-gh-aw.sh"; then
echo " ✓ PASS: Latest release URL pattern is correct"
else
echo " ✗ FAIL: Latest release URL pattern not found"
exit 1
fi

# Check that API validation is removed
if grep -q "fetch_release_data.*releases/latest" "$PROJECT_ROOT/install-gh-aw.sh"; then
echo " ✗ FAIL: API validation for latest release still exists"
exit 1
else
echo " ✓ PASS: API validation for latest release removed"
fi

# Check that validation logic is removed
if grep -q "Validating release.*exists" "$PROJECT_ROOT/install-gh-aw.sh"; then
echo " ✗ FAIL: Version validation logic still exists"
exit 1
else
echo " ✓ PASS: Version validation logic removed"
fi

echo ""
echo "=== All tests passed ==="
Loading