Skip to content
Latchkey

oven-sh/setup-bun

Download, install, and add Bun to the PATH so later steps can run bun commands.

Official actionCategory: Language & Toolchain SetupLatest v2View on GitHub

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 test

Inputs

InputDescriptionDefaultRequired
bun-versionVersion of Bun to install, e.g. "latest", "canary", "1.0.0", "1.0.x", or a commit SHA.-No
bun-version-fileFile to read the Bun version from, e.g. package.json, .bun-version, .tool-versions.-No
bun-download-urlOverride the download URL. Skips version resolution and the AVX2 support check.-No
registriesPackage registries with authentication support, including scoped registries with tokens.-No
no-cacheDisable caching of the Bun executable.falseNo

Outputs

OutputDescription
bun-versionThe version of Bun that was installed.
bun-pathThe path to the Bun executable.
cache-hitWhether 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-url skips 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-version to an exact version for reproducible builds.
  • Pass registry tokens in the registries input from secrets, never inline in the workflow file.

Alternatives and related

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.
Running oven-sh/setup-bun? Run it on Latchkey managed runners - self-healing and caching included. Start free → 30-day trial · No credit card