From 21c249e8c8ac80960ffd93512512871ccd22e52b Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Fri, 27 Feb 2026 04:43:29 +0900 Subject: [PATCH] fix(ci): pre-download baseline compile targets to avoid Bun extraction failures Bun's internal download of baseline compile targets from npm registry consistently fails on Windows CI runners (ExtractionFailed error). Pre-download the baseline binary via curl into Bun's cache directory so the compile step finds it already cached and skips the download. Also makes publish job resilient with if: always() so one failed platform doesn't block publishing all other successful platforms. --- .github/workflows/publish-platform.yml | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/.github/workflows/publish-platform.yml b/.github/workflows/publish-platform.yml index 07144639..840710e9 100644 --- a/.github/workflows/publish-platform.yml +++ b/.github/workflows/publish-platform.yml @@ -82,6 +82,52 @@ jobs: cd packages/${{ matrix.platform }} jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json + - name: Pre-download baseline compile target + if: steps.check.outputs.skip != 'true' && endsWith(matrix.platform, '-baseline') + shell: bash + run: | + BUN_VERSION=$(bun --version) + PLATFORM="${{ matrix.platform }}" + PKG_NAME="bun-${PLATFORM}" + CACHE_DIR=$(bun pm cache) + CACHE_DEST="${CACHE_DIR}/${PKG_NAME}-v${BUN_VERSION}" + + if [[ -f "$CACHE_DEST" ]]; then + echo "✓ Compile target already cached at ${CACHE_DEST}" + exit 0 + fi + + echo "Pre-downloading ${PKG_NAME} v${BUN_VERSION} to ${CACHE_DEST}" + TARBALL_URL="https://registry.npmjs.org/@oven/bun-${PLATFORM}/-/bun-${PLATFORM}-${BUN_VERSION}.tgz" + echo "URL: ${TARBALL_URL}" + + mkdir -p "$(dirname "$CACHE_DEST")" + TMP_DIR=$(mktemp -d) + + # Download and extract the bun binary from npm tarball + curl -fsSL --retry 5 --retry-delay 5 "${TARBALL_URL}" | tar -xzf - -C "${TMP_DIR}" + + if [[ "$PLATFORM" == windows-* ]]; then + BIN_NAME="bun.exe" + else + BIN_NAME="bun" + fi + + # npm tarball has package/bin/bun structure + if [[ -f "${TMP_DIR}/package/bin/${BIN_NAME}" ]]; then + cp "${TMP_DIR}/package/bin/${BIN_NAME}" "${CACHE_DEST}" + elif [[ -f "${TMP_DIR}/package/${BIN_NAME}" ]]; then + cp "${TMP_DIR}/package/${BIN_NAME}" "${CACHE_DEST}" + else + echo "Could not find ${BIN_NAME} in tarball, listing contents:" + find "${TMP_DIR}" -type f + exit 1 + fi + + chmod +x "${CACHE_DEST}" 2>/dev/null || true + echo "✓ Pre-downloaded to ${CACHE_DEST}" + ls -lh "${CACHE_DEST}" + - name: Build binary if: steps.check.outputs.skip != 'true' uses: nick-fields/retry@v3