From 5d8d323e5e7d3cb8e3e1c68bdd9e7a41623f8efa Mon Sep 17 00:00:00 2001 From: luckeyfaraday Date: Mon, 15 Jun 2026 22:58:30 +0200 Subject: [PATCH] Retry bun install in build.sh to survive transient GitHub 5xx bun install resolves git dependencies (e.g. ghostty-web pinned to #main) by fetching tarballs from the GitHub API. That endpoint intermittently returns 504, which failed four of six platform legs of the v0.4.0 release build even though the code and lockfile were sound. Wrap the install in a 3-attempt retry with linear backoff so a transient blip no longer sinks a tagged release; a genuinely broken lockfile still fails after the final attempt. Co-Authored-By: Claude Opus 4.8 --- scripts/build.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 7a1107e..5b92843 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -85,7 +85,25 @@ done cp -R "$ROOT/overlay/." "$SOURCE/" cd "$SOURCE" -npx --yes bun@1.3.14 install --frozen-lockfile +# bun install resolves git dependencies (e.g. ghostty-web pinned to a branch) by +# fetching tarballs from the GitHub API, which intermittently returns 5xx and +# fails the whole release. Retry with backoff so a transient blip doesn't sink a +# tagged build; a genuinely broken lockfile still fails after the last attempt. +bun_install() { + local attempt + for attempt in 1 2 3; do + if npx --yes bun@1.3.14 install --frozen-lockfile; then + return 0 + fi + if [[ "$attempt" -lt 3 ]]; then + echo "bun install failed (attempt $attempt/3); retrying in $((attempt * 10))s..." >&2 + sleep "$((attempt * 10))" + fi + done + echo "error: bun install failed after 3 attempts." >&2 + return 1 +} +bun_install OPENCODE_VERSION="$VERSION" npx --yes bun@1.3.14 run --cwd packages/opencode script/build.ts --single --skip-install --skip-embed-web-ui mkdir -p "$ROOT/runtime-bin/$TARGET" cp "packages/opencode/dist/opencode-$UPSTREAM_TARGET/bin/$EXECUTABLE" "$ROOT/runtime-bin/$TARGET/$OUTPUT_NAME"