fix(ci): add owpenbot sidecar stub to build.rs and enable Bun on all platforms

- Add ensure_owpenbot_sidecar() to build.rs to create debug stubs when binary missing
- Remove 'if: matrix.os_type == windows' from Bun setup in CI workflows
- This fixes PreRelease builds failing because prepare:sidecar needs bun to compile owpenbot
This commit is contained in:
Benjamin Shafii
2026-01-28 19:51:27 -08:00
parent be4f591e18
commit 660f1b4086
3 changed files with 94 additions and 2 deletions

View File

@@ -121,7 +121,6 @@ jobs:
version: 10.27.0
- name: Setup Bun
if: matrix.os_type == 'windows'
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1.29"

View File

@@ -219,7 +219,6 @@ jobs:
version: 10.27.0
- name: Setup Bun
if: matrix.os_type == 'windows'
uses: oven-sh/setup-bun@v1
with:
bun-version: "1.1.29"

View File

@@ -8,6 +8,7 @@ use std::os::unix::fs::PermissionsExt;
fn main() {
ensure_opencode_sidecar();
ensure_openwork_server_sidecar();
ensure_owpenbot_sidecar();
tauri_build::build();
}
@@ -188,6 +189,99 @@ fn ensure_openwork_server_sidecar() {
}
}
fn ensure_owpenbot_sidecar() {
let target = env::var("CARGO_CFG_TARGET_TRIPLE")
.or_else(|_| env::var("TARGET"))
.or_else(|_| env::var("TAURI_ENV_TARGET_TRIPLE"))
.unwrap_or_default();
if target.is_empty() {
return;
}
let manifest_dir = env::var("CARGO_MANIFEST_DIR")
.map(PathBuf::from)
.unwrap_or_else(|_| PathBuf::from("."));
let sidecar_dir = manifest_dir.join("sidecars");
let canonical_name = if target.contains("windows") {
"owpenbot.exe"
} else {
"owpenbot"
};
let mut target_name = format!("owpenbot-{target}");
if target.contains("windows") {
target_name.push_str(".exe");
}
let dest_path = sidecar_dir.join(canonical_name);
let target_dest_path = sidecar_dir.join(target_name);
if dest_path.exists() {
return;
}
if target_dest_path.exists() {
if copy_sidecar(&target_dest_path, &dest_path, &target) {
return;
}
}
let source_path = env::var("OWPENBOT_BIN_PATH")
.ok()
.map(PathBuf::from)
.filter(|path| path.is_file())
.or_else(|| {
find_in_path(if target.contains("windows") {
"owpenbot.exe"
} else {
"owpenbot"
})
});
let profile = env::var("PROFILE").unwrap_or_default();
let Some(source_path) = source_path else {
println!(
"cargo:warning=Owpenbot sidecar missing at {} (set OWPENBOT_BIN_PATH or install owpenbot)",
dest_path.display()
);
create_debug_stub(&dest_path, &sidecar_dir, &profile, &target);
create_debug_stub(&target_dest_path, &sidecar_dir, &profile, &target);
return;
};
if fs::create_dir_all(&sidecar_dir).is_err() {
return;
}
let copied = copy_sidecar(&source_path, &dest_path, &target);
if copied {
#[cfg(unix)]
{
let _ = fs::set_permissions(&dest_path, fs::Permissions::from_mode(0o755));
}
let _ = copy_sidecar(&dest_path, &target_dest_path, &target);
} else {
println!(
"cargo:warning=Failed to copy Owpenbot sidecar from {} to {}",
source_path.display(),
dest_path.display()
);
create_debug_stub(&dest_path, &sidecar_dir, &profile, &target);
create_debug_stub(&target_dest_path, &sidecar_dir, &profile, &target);
}
if !dest_path.exists() {
create_debug_stub(&dest_path, &sidecar_dir, &profile, &target);
}
if !target_dest_path.exists() {
create_debug_stub(&target_dest_path, &sidecar_dir, &profile, &target);
}
}
fn copy_sidecar(source_path: &PathBuf, dest_path: &PathBuf, target: &str) -> bool {
let mut copied = fs::copy(source_path, dest_path).is_ok();