Skip to content
Latchkey

gh release download: Fetch Release Assets in CI

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

FlagWhat 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
--clobberOverwrite 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →