11name : " Setup Bun"
22description : " Setup Bun with caching and install dependencies"
3+ inputs :
4+ cross-compile :
5+ description : " Pre-cache canary cross-compile binaries for all targets"
6+ required : false
7+ default : " false"
38runs :
49 using : " composite"
510 steps :
@@ -16,13 +21,12 @@ runs:
1621 shell : bash
1722 run : |
1823 if [ "$RUNNER_ARCH" = "X64" ]; then
19- V=$(node -p "require('./package.json').packageManager.split('@')[1]")
2024 case "$RUNNER_OS" in
2125 macOS) OS=darwin ;;
2226 Linux) OS=linux ;;
2327 Windows) OS=windows ;;
2428 esac
25- echo "url=https://bun. sh/download/${V}/ ${OS}/ x64?avx2=false&profile=false " >> "$GITHUB_OUTPUT"
29+ echo "url=https://github.com/oven- sh/bun/releases/ download/canary/bun- ${OS}- x64-baseline.zip " >> "$GITHUB_OUTPUT"
2630 fi
2731
2832 - name : Setup Bun
3135 bun-version-file : ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
3236 bun-download-url : ${{ steps.bun-url.outputs.url }}
3337
38+ - name : Pre-cache canary cross-compile binaries
39+ if : inputs.cross-compile == 'true'
40+ shell : bash
41+ run : |
42+ BUN_VERSION=$(bun --revision)
43+ if echo "$BUN_VERSION" | grep -q "canary"; then
44+ SEMVER=$(echo "$BUN_VERSION" | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')
45+ echo "Bun version: $BUN_VERSION (semver: $SEMVER)"
46+ CACHE_DIR="$HOME/.bun/install/cache"
47+ mkdir -p "$CACHE_DIR"
48+ TMP_DIR=$(mktemp -d)
49+ for TARGET in linux-aarch64 linux-x64 linux-x64-baseline linux-aarch64-musl linux-x64-musl linux-x64-musl-baseline darwin-aarch64 darwin-x64 windows-x64 windows-x64-baseline; do
50+ DEST="$CACHE_DIR/bun-${TARGET}-v${SEMVER}"
51+ if [ -f "$DEST" ]; then
52+ echo "Already cached: $DEST"
53+ continue
54+ fi
55+ URL="https://github.com/oven-sh/bun/releases/download/canary/bun-${TARGET}.zip"
56+ echo "Downloading $TARGET from $URL"
57+ if curl -sfL -o "$TMP_DIR/bun.zip" "$URL"; then
58+ unzip -qo "$TMP_DIR/bun.zip" -d "$TMP_DIR"
59+ if echo "$TARGET" | grep -q "windows"; then
60+ BIN_NAME="bun.exe"
61+ else
62+ BIN_NAME="bun"
63+ fi
64+ mv "$TMP_DIR/bun-${TARGET}/$BIN_NAME" "$DEST"
65+ chmod +x "$DEST"
66+ rm -rf "$TMP_DIR/bun-${TARGET}" "$TMP_DIR/bun.zip"
67+ echo "Cached: $DEST"
68+ # baseline bun resolves "bun-darwin-x64" to the baseline cache key
69+ # so copy the modern binary there too
70+ if [ "$TARGET" = "darwin-x64" ]; then
71+ BASELINE_DEST="$CACHE_DIR/bun-darwin-x64-baseline-v${SEMVER}"
72+ if [ ! -f "$BASELINE_DEST" ]; then
73+ cp "$DEST" "$BASELINE_DEST"
74+ echo "Cached (baseline alias): $BASELINE_DEST"
75+ fi
76+ fi
77+ else
78+ echo "Skipped: $TARGET (not available)"
79+ fi
80+ done
81+ rm -rf "$TMP_DIR"
82+ else
83+ echo "Not a canary build ($BUN_VERSION), skipping pre-cache"
84+ fi
85+
3486 - name : Install dependencies
3587 run : bun install
3688 shell : bash
0 commit comments