# gh release download: Fetch Release Assets in CI

> gh release download pulls assets or source tarballs from a GitHub release. Reference for --pattern, --dir, --archive, and the not-found and auth errors in CI.

Source: https://latchkey.dev/learn/command-reference/gh-release-download  
Updated: 2026-06-30

gh release download retrieves the assets attached to a release, filtered by glob pattern.

Pipelines that consume a prebuilt binary or fixture from a release use gh release download to grab exactly the assets they need.

## What it does

gh release download fetches assets from a named release tag, or the latest release if no tag is given. --pattern selects which assets by glob, and --archive downloads the source tarball or zipball instead of attached assets.

## Common usage

```Terminal
gh release download v1.2.0
gh release download v1.2.0 --pattern "*-linux-amd64.tar.gz"
gh release download --pattern "*.deb" --dir ./artifacts
gh release download v1.2.0 --archive tar.gz
```

## Flags

| Flag | What it does |
| --- | --- |
| -p, --pattern <glob> | Download only assets matching the glob |
| -D, --dir <dir> | Directory to download into |
| -A, --archive <format> | Download source archive: zip or tar.gz |
| -O, --output <file> | Write a single asset to a specific path |
| --clobber | Overwrite existing files |
| -R, --repo <owner/repo> | Target a specific repository |

## In CI

Set GH_TOKEN and permissions: { contents: read }. Without --pattern or --archive the command downloads every asset, which can be large; scope it. Use --clobber when a step may re-run and files already exist.

## Common errors in CI

"release not found" means the tag does not exist or is a draft the token cannot see. "no assets match the file pattern" means the --pattern glob matched nothing; check the exact asset names with gh release view. "gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable" means GH_TOKEN is unset.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### gh release download: Fetch Release Assets in CI?

Pipelines that consume a prebuilt binary or fixture from a release use gh release download to grab exactly the assets they need.

### What it does?

gh release download fetches assets from a named release tag, or the latest release if no tag is given. --pattern selects which assets by glob, and --archive downloads the source tarball or zipball instead of attached assets.

### In CI?

Set GH_TOKEN and permissions: { contents: read }. Without --pattern or --archive the command downloads every asset, which can be large; scope it. Use --clobber when a step may re-run and files already exist.

### Common errors in CI?

"release not found" means the tag does not exist or is a draft the token cannot see. "no assets match the file pattern" means the --pattern glob matched nothing; check the exact asset names with gh release view. "gh: To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable" means GH_TOKEN is unset.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
