Skip to content

Commit d1cd7d0

Browse files
committed
ci: centralize Bun version to package.json to ensure consistent builds across CI and local development
1 parent 06ac1be commit d1cd7d0

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.github/actions/setup-bun/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ runs:
55
steps:
66
- name: Setup Bun
77
uses: oven-sh/setup-bun@v2
8+
with:
9+
bun-version-file: package.json
810

911
- name: Cache ~/.bun
1012
id: cache-bun

packages/script/src/index.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import { $ } from "bun"
2+
import path from "path"
23

3-
if (process.versions.bun !== "1.3.1") {
4-
throw new Error("This script requires bun@1.3.1")
4+
const rootPkgPath = path.resolve(import.meta.dir, "../../../package.json")
5+
const rootPkg = await Bun.file(rootPkgPath).json()
6+
const expectedBunVersion = rootPkg.packageManager?.split("@")[1]
7+
8+
if (!expectedBunVersion) {
9+
throw new Error("packageManager field not found in root package.json")
10+
}
11+
12+
if (process.versions.bun !== expectedBunVersion) {
13+
throw new Error(
14+
`This script requires bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`,
15+
)
516
}
617

718
const CHANNEL =

0 commit comments

Comments
 (0)