From 3c4f87cdc41a3d9be5c268eb83d67e26f8c8444c Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 4 Mar 2026 02:56:27 +0000 Subject: [PATCH] chore: centralize bun version and release URL constants --- bun/BUILD.bazel | 11 ++++++----- bun/repositories.bzl | 11 ++++++----- bun/version.bzl | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 bun/version.bzl diff --git a/bun/BUILD.bazel b/bun/BUILD.bazel index c84f88c..ff310a9 100644 --- a/bun/BUILD.bazel +++ b/bun/BUILD.bazel @@ -1,35 +1,36 @@ load(":toolchain.bzl", "bun_toolchain") +load(":version.bzl", "BUN_VERSION") toolchain_type(name = "toolchain_type") bun_toolchain( name = "linux_x64_toolchain_impl", bun = "@bun_linux_x64//:bun", - version = "1.1.38", + version = BUN_VERSION, ) bun_toolchain( name = "linux_aarch64_toolchain_impl", bun = "@bun_linux_aarch64//:bun", - version = "1.1.38", + version = BUN_VERSION, ) bun_toolchain( name = "darwin_x64_toolchain_impl", bun = "@bun_darwin_x64//:bun", - version = "1.1.38", + version = BUN_VERSION, ) bun_toolchain( name = "darwin_aarch64_toolchain_impl", bun = "@bun_darwin_aarch64//:bun", - version = "1.1.38", + version = BUN_VERSION, ) bun_toolchain( name = "windows_x64_toolchain_impl", bun = "@bun_windows_x64//:bun", - version = "1.1.38", + version = BUN_VERSION, ) toolchain( diff --git a/bun/repositories.bzl b/bun/repositories.bzl index 665bcf3..a5b0e32 100644 --- a/bun/repositories.bzl +++ b/bun/repositories.bzl @@ -1,6 +1,5 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -_BUN_VERSION = "1.1.38" +load(":version.bzl", "BUN_VERSION") _BUN_ARCHIVES = { "bun_linux_x64": { @@ -30,6 +29,8 @@ _BUN_ARCHIVES = { }, } +_BUN_GITHUB_RELEASE_URL_TEMPLATE = "https://github.com/oven-sh/bun/releases/download/bun-v{}/{}" + def _declare_bun_repo(name, asset, sha256, binary, version): if native.existing_rule(name): @@ -37,7 +38,7 @@ def _declare_bun_repo(name, asset, sha256, binary, version): http_archive( name = name, - urls = ["https://github.com/oven-sh/bun/releases/download/bun-v{}/{}".format(version, asset)], + urls = [_BUN_GITHUB_RELEASE_URL_TEMPLATE.format(version, asset)], sha256 = sha256, build_file_content = """ exports_files(["{binary}"]) @@ -51,7 +52,7 @@ filegroup( ) -def bun_repositories(version = _BUN_VERSION): +def bun_repositories(version = BUN_VERSION): for name, metadata in _BUN_ARCHIVES.items(): _declare_bun_repo( name = name, @@ -62,7 +63,7 @@ def bun_repositories(version = _BUN_VERSION): ) -def bun_register_toolchains(version = _BUN_VERSION): +def bun_register_toolchains(version = BUN_VERSION): bun_repositories(version = version) native.register_toolchains( "//bun:darwin_aarch64_toolchain", diff --git a/bun/version.bzl b/bun/version.bzl new file mode 100644 index 0000000..a0ad89c --- /dev/null +++ b/bun/version.bzl @@ -0,0 +1 @@ +BUN_VERSION = "1.1.38"