Skip to content
Open
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
2 changes: 2 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P macos-latest=-self-hosted
87 changes: 83 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,101 @@
name: Test gh-install

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [main]
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
tool:
# Basic tarball
- repo: orf/gping
verify: gping --version
desc: "simple tarball"

# Test --pattern flag (force musl variant)
- repo: BurntSushi/ripgrep
pattern: "*musl*"
verify: rg --version
desc: "pattern filter"

# Test --name flag
- repo: sharkdp/fd
name: fdfind
verify: fdfind --version
desc: "custom name"

# Test --version flag
- repo: sharkdp/bat
version: v0.24.0
verify: bat --version | grep "0.24.0"
desc: "pinned version"

# Simple binary (no gnu/musl variants)
- repo: junegunn/fzf
verify: fzf --version
desc: "simple binary"

# Multiple file types (.tar.gz + .sha256)
- repo: astral-sh/uv
verify: uv --version
desc: "uv package manager"

# Go binary
- repo: jesseduffield/lazygit
verify: lazygit --version
desc: "go binary"

# Rust binary
- repo: sharkdp/hyperfine
verify: hyperfine --version
desc: "rust binary"

# Nested archive structure
- repo: dandavison/delta
verify: delta --version
desc: "nested archive"

runs-on: ${{ matrix.os }}
name: "${{ matrix.tool.desc }} (${{ matrix.os }})"

defaults:
run:
shell: bash

env:
GH_TOKEN: ${{ github.token }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install GitHub CLI (for act)
if: ${{ env.ACT }}
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update
sudo apt-get install -y gh

- name: Install extension locally
run: gh extension install .

- name: "Test: ${{ matrix.tool.desc }}"
run: |
args="--auto"
[ -n "${{ matrix.tool.pattern }}" ] && args="$args --pattern '${{ matrix.tool.pattern }}'"
[ -n "${{ matrix.tool.name }}" ] && args="$args --name ${{ matrix.tool.name }}"
[ -n "${{ matrix.tool.version }}" ] && args="$args --version ${{ matrix.tool.version }}"

echo "Running: gh install ${{ matrix.tool.repo }} $args"
eval "gh install ${{ matrix.tool.repo }} $args"

- name: Verify installation
run: |
export PATH="$HOME/.local/bin:$PATH"
${{ matrix.tool.verify }}
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,67 @@ gh extension install redraw/gh-install

## Usage

### Interactive mode (default)

```bash
gh install <user>/<repo>
```

The interactive mode will prompt you to select:

- Version to install
- Asset file to download
- Binary to extract (if archive)
- Name for the installed binary

Optional: For fuzzy search support, install [fzf](https://github.com/junegunn/fzf)

### Non-interactive mode: --auto (or -a)

For scripts, CI/CD pipelines, and non-interactive use.

```bash
gh install <user>/<repo> --auto
```

Auto mode automatically:

- Detects your platform (OS and architecture)
- Selects the latest version
- Prefers `gnu` over `musl` when both are available
- Excludes checksum files (.sha256, .sig, etc.)

> [!NOTE]
> To prefer `musl` instead, use the pattern flag:
>
> ```bash
> gh install <user>/<repo> --auto --pattern '*musl*'
> ```

**Examples:**

```bash
# Auto-detect everything (version, OS, architecture, binary name)
gh install cli/cli --auto

# Auto-detect with specific version
gh install cli/cli --auto --version v2.40.0

# Auto-detect with pattern to choose variant (musl vs gnu, etc)
gh install BurntSushi/ripgrep --auto --pattern '*.tar.gz$'

# Auto-detect with custom binary name
gh install sharkdp/fd --auto --name fdfind
```

**Options:**

- `-a, --auto` - Enable non-interactive mode with auto-detection
- `-v, --version <tag|latest>` - Version to install (default: latest in auto mode)
- `-p, --pattern <glob>` - Asset filename pattern to narrow down matches
- `-n, --name <name>` - Binary name (default: auto-detect from filename)
- `-h, --help` - Show help message

## Environment variables
- `$GH_BINPATH` path to install binaries, defaults to `$HOME/.local/bin`

- `$GH_BINPATH` - Path to install binaries, defaults to `$HOME/.local/bin`
Loading
Loading