Skip to content
Closed
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@ The official [Agent Skills evaluation guide](https://agentskills.io/skill-creati

Install with the script:

**macOS / Linux**:

```bash
curl -fsSL https://raw.githubusercontent.com/alibaba/skill-up/main/install.sh | bash
```

The installer downloads the matching binary from [GitHub Releases](https://github.com/alibaba/skill-up/releases).
**Windows (PowerShell)**:

```powershell
irm https://raw.githubusercontent.com/alibaba/skill-up/main/install.ps1 | iex
```

The installer downloads the matching binary from [GitHub Releases](https://github.com/alibaba/skill-up/releases). Set `SKILL_UP_VERSION` to pin a release and `INSTALL_DIR` to override the install location.

To build locally from a checkout, install [Go](https://go.dev/dl/) 1.25 or later:

Expand Down
10 changes: 9 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,19 @@

使用安装脚本:

**macOS / Linux**:

```bash
curl -fsSL https://raw.githubusercontent.com/alibaba/skill-up/main/install.sh | bash
```

安装脚本会从 [GitHub Releases](https://github.com/alibaba/skill-up/releases) 下载当前平台对应的二进制文件。
**Windows(PowerShell)**:

```powershell
irm https://raw.githubusercontent.com/alibaba/skill-up/main/install.ps1 | iex
```

安装脚本会从 [GitHub Releases](https://github.com/alibaba/skill-up/releases) 下载当前平台对应的二进制文件。可通过 `SKILL_UP_VERSION` 指定版本,通过 `INSTALL_DIR` 覆盖安装目录。

如需从仓库 checkout 后本地构建,需要安装 [Go](https://go.dev/dl/) 1.25 或更高版本:

Expand Down
126 changes: 126 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#Requires -Version 5.1
[CmdletBinding()]
param()

$ErrorActionPreference = 'Stop'
[Net.ServicePointManager]::SecurityProtocol = `
[Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

$Repo = 'alibaba/skill-up'
$Project = 'skill-up'
$RequestedVersion = if ($env:SKILL_UP_VERSION) { $env:SKILL_UP_VERSION } else { 'latest' }
$InstallDir = if ($env:INSTALL_DIR) {
$env:INSTALL_DIR
} else {
Join-Path $env:LOCALAPPDATA 'Programs\skill-up'
}

function Get-Arch {
$a = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE }
switch -Regex ($a) {
'^(AMD64|x86_64)$' { return 'amd64' }
'^(ARM64|aarch64)$' { return 'arm64' }
}
throw "unsupported architecture: $a"
}

function Get-LatestTag {
$url = "https://github.com/$Repo/releases/latest"
$req = [System.Net.HttpWebRequest]::Create($url)
$req.AllowAutoRedirect = $false
$req.Method = 'HEAD'
try {
$resp = $req.GetResponse()
} catch [System.Net.WebException] {
$resp = $_.Exception.Response
if (-not $resp) { throw }
}
try {
$location = $resp.Headers['Location']
} finally {
$resp.Close()
}
if (-not $location) { throw "unable to resolve latest tag from $url" }
return ($location -split '/tag/')[-1]
}

function Test-Checksum {
param(
[Parameter(Mandatory)] [string] $File,
[Parameter(Mandatory)] [string] $ChecksumsFile
)
$name = [System.IO.Path]::GetFileName($File)
$expected = $null
foreach ($line in Get-Content -LiteralPath $ChecksumsFile) {
$parts = $line -split '\s+', 2
if ($parts.Count -eq 2 -and $parts[1].Trim() -eq $name) {
$expected = $parts[0].ToLowerInvariant()
break
}
}
if (-not $expected) {
throw "no checksum entry for $name in $ChecksumsFile"
}
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $File).Hash.ToLowerInvariant()
if ($actual -ne $expected) {
throw "checksum mismatch for ${name} (expected $expected, got $actual)"
}
}

$arch = Get-Arch
$os = 'windows'

$tag = $RequestedVersion
if ($tag -eq 'latest') {
$tag = Get-LatestTag
} elseif (-not $tag.StartsWith('v')) {
$tag = "v$tag"
}
$version = $tag.TrimStart('v')

$archive = "${Project}_${version}_${os}_${arch}.zip"
$baseUrl = "https://github.com/$Repo/releases/download/$tag"
$archiveUrl = "$baseUrl/$archive"
$checksumsUrl = "$baseUrl/${Project}_${version}_checksums.txt"

$tmpDir = New-Item -ItemType Directory -Force -Path `
(Join-Path $env:TEMP "skill-up-install-$([guid]::NewGuid().ToString('N'))")

try {
$archivePath = Join-Path $tmpDir $archive
$checksumsPath = Join-Path $tmpDir 'checksums.txt'

Write-Host "Downloading $archiveUrl"
Invoke-WebRequest -Uri $archiveUrl -OutFile $archivePath -UseBasicParsing

Write-Host 'Downloading checksums'
Invoke-WebRequest -Uri $checksumsUrl -OutFile $checksumsPath -UseBasicParsing
Test-Checksum -File $archivePath -ChecksumsFile $checksumsPath

Expand-Archive -LiteralPath $archivePath -DestinationPath $tmpDir -Force

if (-not (Test-Path -LiteralPath $InstallDir)) {
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
}

$binaryName = "$Project.exe"
$src = Join-Path $tmpDir $binaryName
$dest = Join-Path $InstallDir $binaryName
Copy-Item -LiteralPath $src -Destination $dest -Force

Write-Host "Installed $binaryName to $InstallDir"
} finally {
Remove-Item -LiteralPath $tmpDir -Recurse -Force -ErrorAction SilentlyContinue
}

$pathEntries = ($env:Path -split ';') | Where-Object { $_ }
if ($pathEntries -notcontains $InstallDir) {
Write-Host ''
Write-Host "$InstallDir is not in PATH. Add it for the current session with:"
Write-Host ''
Write-Host " `$env:Path = `"$InstallDir;`$env:Path`""
Write-Host ''
Write-Host 'Or persist it for your user account with:'
Write-Host ''
Write-Host " [Environment]::SetEnvironmentVariable('Path', `"$InstallDir;`" + [Environment]::GetEnvironmentVariable('Path', 'User'), 'User')"
}
Loading