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
42 changes: 42 additions & 0 deletions .github/workflows/homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ permissions:
contents: write
packages: write
actions: read
pages: write
id-token: write

# Global environment variables
env:
Expand Down Expand Up @@ -535,6 +537,46 @@ jobs:
echo ""
echo "🔗 Homebrew Guidelines: https://docs.brew.sh/Adding-Software-to-Homebrew"

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Prepare deployment files
run: |
echo "📁 Preparing GitHub Pages deployment from scripts directory..."

# Ensure scripts directory exists
if [ ! -d "scripts" ]; then
echo "❌ scripts directory not found!"
exit 1
fi

# Display files to be deployed
echo "Files to be deployed:"
ls -la scripts/

# Verify critical files exist
if [ ! -f "scripts/windows" ]; then
echo "❌ scripts/windows file not found!"
exit 1
fi

echo "✅ All required files found"

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./scripts

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

- name: Deployment summary
run: |
echo "🎉 GitHub Pages deployment completed!"
echo "📄 Site URL: ${{ steps.deployment.outputs.page_url }}"
echo "🔗 Install command: powershell -Command \"irm https://agbcloud.github.io/agbcloud-cli/windows | iex\""

- name: Validate Official Formula
run: |
echo "🧪 Validating Official Homebrew Formula (Source Build Mode)..."
Expand Down
257 changes: 211 additions & 46 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,240 @@
# AgbCloud CLI Scripts
# AgbCloud CLI Windows Installation Guide

This directory contains scripts for the AgbCloud CLI project.
This guide provides instructions for installing AgbCloud CLI on Windows using PowerShell.

## Test Scripts
## Table of Contents

### test.sh
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Verification](#verification)
- [Usage](#usage)
- [Troubleshooting](#troubleshooting)
- [Uninstallation](#uninstallation)

The main test runner script used by the Makefile for running unit and integration tests.
## Prerequisites

#### Usage
Before installing AgbCloud CLI, please ensure:
- Windows 10 or later (Windows Server 2016 or later)
- PowerShell 5.1 or later (PowerShell 7+ recommended)
- Internet connection
- Administrator privileges (recommended for PATH configuration)

```bash
# Run unit tests only
./scripts/test.sh --unit-only
## Installation

# Run integration tests only
./scripts/test.sh --integration-only
### Quick Installation

# Run all tests
./scripts/test.sh --all
Install AgbCloud CLI with a single PowerShell command:

# Run tests with verbose output
./scripts/test.sh --unit-only --verbose
```powershell
powershell -Command "irm https://litiantian123-code.github.io/agbcloud-cli/windows | iex"
```

## Build and Release Scripts
### Installation Process

### generate-server-files.sh
The installation script will:
1. **Detect system architecture** (amd64/arm64)
2. **Download the latest version** from GitHub Releases
3. **Create installation directory** (`%LOCALAPPDATA%\agbcloud` by default)
4. **Install the binary** as `agb.exe`
5. **Update PATH environment variable** (user-level)
6. **Verify installation** automatically

Generates server files and installation commands for distribution. This script is used in the CI/CD pipeline to create PowerShell installation scripts and version metadata.
## Verification

#### Usage
After installation, verify that AgbCloud CLI is installed correctly:

```bash
# Generate files for a specific version
VERSION="v1.2.3" ./scripts/generate-server-files.sh
### Step 1: Restart PowerShell
```powershell
# Close current PowerShell window and open a new one
Start-Process powershell -Verb RunAs; exit
# Or refresh the environment variables
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
```

### Step 2: Check Installation
```powershell
# Check if agb command is available
agb --version
```

**Expected Output:**
```
AgbCloud CLI version 1.0.0
Git commit: abc1234
Build date: 2025-01-15T10:30:00Z
```

### Step 3: Verify Command Help
```powershell
# Display help information
agb --help
```

**Expected Output:**
```
Command line interface for AgbCloud services

Usage:
agb [command]

Available Commands:
image Manage images
login Log in to AgbCloud
logout Log out from AgbCloud
version Show version information
help Help about any command

# Generate files with default dev version
./scripts/generate-server-files.sh
Flags:
-h, --help help for agb
-v, --verbose Enable verbose output

Use "agb [command] --help" for more information about a command.
```

### Step 4: Test Core Functionality
```powershell
# Test image command
agb image --help

# Test version command
agb version
```

#### Generated Files
## Usage

### Basic Commands

```powershell
# Show help
agb --help

- `server-files/install.ps1` - PowerShell installation script
- `server-files/latest.json` - Version metadata for API
# Show version
agb version

### upload-to-oss.sh
# Login to AgbCloud
agb login

Uploads build artifacts to Alibaba Cloud OSS. Can be used independently or as part of the CI/CD pipeline.
# List available images
agb image list

# Create a custom image
agb image create myImage --dockerfile ./Dockerfile --imageId agb-code-space-1

# Activate an image
agb image activate img-7a8b9c1d0e

# Deactivate an image
agb image deactivate img-7a8b9c1d0e
```

### Enable Verbose Output
```powershell
# Use -v flag for detailed output
agb -v image list
agb --verbose login
```

#### Usage
## Troubleshooting

```bash
# Set required environment variables
export OSS_ACCESS_KEY_ID="your-access-key"
export OSS_ACCESS_KEY_SECRET="your-secret-key"
export VERSION="v1.2.3"
### Common Issues

# Upload packages
./scripts/upload-to-oss.sh
#### Issue 1: Command Not Found
```powershell
# Error: 'agb' is not recognized as an internal or external command
```

## Features
**Solutions:**
1. **Restart PowerShell** or refresh environment variables:
```powershell
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
```

2. **Check installation directory:**
```powershell
Get-ChildItem "$env:LOCALAPPDATA\agbcloud"
```

#### Issue 2: Installation Failed
```powershell
# Error: Failed to download AgbCloud CLI
```

**Solutions:**
1. **Check internet connection**
2. **Try running the installation command again**
3. **Use manual download from GitHub Releases if needed**

#### Issue 3: Permission Denied
```powershell
# Error: Access denied or execution policy restriction
```

**Solutions:**
1. **Run as Administrator:**
```powershell
# Right-click PowerShell and select "Run as Administrator"
```

2. **Check execution policy:**
```powershell
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
```


### Getting Help

If you encounter issues:
1. **Check the installation log** for error messages
2. **Verify system requirements** (Windows version, PowerShell version)
3. **Try manual installation** from GitHub Releases
4. **Contact support** with error details and system information

## Uninstallation

To remove AgbCloud CLI:

### Step 1: Remove Binary
```powershell
# Remove installation directory
Remove-Item -Path "$env:LOCALAPPDATA\agbcloud" -Recurse -Force
```

### Step 2: Clean PATH
```powershell
# Remove from user PATH
$agbPath = "$env:LOCALAPPDATA\agbcloud"
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
$newPath = ($currentPath.Split(';') | Where-Object { $_ -ne $agbPath }) -join ';'
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
```

### Step 3: Verify Removal
```powershell
# This should return an error
agb --version
```

---

## Additional Information

### System Requirements
- **OS**: Windows 10/11, Windows Server 2016+
- **Architecture**: x64 (amd64) or ARM64
- **PowerShell**: 5.1+ (7+ recommended)
- **Disk Space**: ~50MB
- **Network**: Internet connection for download

### Installation Locations
- **Default**: `%LOCALAPPDATA%\agbcloud\agb.exe`

- **Test Automation**: Comprehensive test runner with multiple modes
- **Build Integration**: Automatic generation of installation files for CI/CD
- **Cloud Storage**: Upload artifacts to OSS with proper permissions
- **Version Management**: Support for version-specific builds and releases
### Links
- **GitHub Repository**: https://github.com/agbcloud/agbcloud-cli
- **Releases**: https://github.com/agbcloud/agbcloud-cli/releases
- **Documentation**: https://github.com/agbcloud/agbcloud-cli/blob/main/docs/USER_GUIDE.md
- **Issues**: https://github.com/agbcloud/agbcloud-cli/issues

## Compatibility
---

- Linux/macOS build environments
- Alibaba Cloud OSS integration
- Go 1.23+ test framework
**Note**: This installation method downloads the latest stable release. For development versions or specific releases, please visit the GitHub Releases page.
Loading
Loading