ci: centralize Bun version to package.json to ensure consistent builds across CI and local development

This commit is contained in:
Dax Raad
2025-11-02 15:41:32 -05:00
parent 06ac1be226
commit d1cd7d0344
2 changed files with 15 additions and 2 deletions

View File

@@ -5,6 +5,8 @@ runs:
steps: steps:
- name: Setup Bun - name: Setup Bun
uses: oven-sh/setup-bun@v2 uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Cache ~/.bun - name: Cache ~/.bun
id: cache-bun id: cache-bun

View File

@@ -1,7 +1,18 @@
import { $ } from "bun" import { $ } from "bun"
import path from "path"
if (process.versions.bun !== "1.3.1") { const rootPkgPath = path.resolve(import.meta.dir, "../../../package.json")
throw new Error("This script requires bun@1.3.1") const rootPkg = await Bun.file(rootPkgPath).json()
const expectedBunVersion = rootPkg.packageManager?.split("@")[1]
if (!expectedBunVersion) {
throw new Error("packageManager field not found in root package.json")
}
if (process.versions.bun !== expectedBunVersion) {
throw new Error(
`This script requires bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`,
)
} }
const CHANNEL = const CHANNEL =