oven-sh/setup-bun
Download, install, and add Bun to the PATH so later steps can run bun commands.
What it does
oven-sh/setup-bun downloads and installs Bun so later steps can run bun install, bun test, or bunx.
The version can come from the bun-version input, a version file like .bun-version or package.json, or default to the latest release. The Bun executable is cached between runs unless disabled.
Usage
workflow (.yml)
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: bun testInputs
| Input | Description | Default | Required |
|---|---|---|---|
bun-version | Version of Bun to install, e.g. "latest", "canary", "1.0.0", "1.0.x", or a commit SHA. | - | No |
bun-version-file | File to read the Bun version from, e.g. package.json, .bun-version, .tool-versions. | - | No |
bun-download-url | Override the download URL. Skips version resolution and the AVX2 support check. | - | No |
registries | Package registries with authentication support, including scoped registries with tokens. | - | No |
no-cache | Disable caching of the Bun executable. | false | No |
Outputs
| Output | Description |
|---|---|
bun-version | The version of Bun that was installed. |
bun-path | The path to the Bun executable. |
cache-hit | Whether the Bun executable came from the cache. |
Notes
Resolving wildcard or range versions queries the GitHub API for tags; the default token input covers this on github.com, and a PAT helps on GHES if you hit rate limits.
Common errors
- Version resolution can fail with a GitHub API rate-limit error when resolving wildcard or range versions on busy runners; pass a token or pin an exact
bun-version. - Bun crashing immediately after install on old or exotic CPUs is usually missing AVX2 support;
bun-download-urlskips the AVX2 check, so only override it if you know the target supports the build.
Security and pinning
- Pin the action to a commit SHA and pin
bun-versionto an exact version for reproducible builds. - Pass registry tokens in the
registriesinput from secrets, never inline in the workflow file.
Alternatives and related
actions/setup-nodeInstall a specific Node.js version and cache your npm, yarn, or pnpm dependencies.
pnpm/action-setupInstall the pnpm package manager, so setup-node can cache the pnpm store.
actions/cacheCache any files between workflow runs, keyed on a hash of your lockfiles.
Frequently asked questions
How do I keep CI on the same Bun version as my repo?
Commit a
.bun-version file (or set the version in package.json) and point bun-version-file at it, so CI and local dev resolve the same version.