@@ -11,29 +11,14 @@ runs:
1111 # node-gyp@latest (invoked via bunx for native install scripts) requires Node >=22;
1212 # some runner images ship an older system Node on PATH
1313 - name : Setup Node
14- uses : actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4 .0
14+ uses : actions/setup-node@cdca7365b2dadb8aad0a33bc7601856eab26d477 # v4.5 .0
1515 with :
1616 node-version : " 24"
1717
18- - name : Get baseline download URL
19- id : bun-url
20- shell : bash
21- run : |
22- if [ "$RUNNER_ARCH" = "X64" ]; then
23- V=$(node -p "require('./package.json').packageManager.split('@')[1]")
24- case "$RUNNER_OS" in
25- macOS) OS=darwin ;;
26- Linux) OS=linux ;;
27- Windows) OS=windows ;;
28- esac
29- echo "url=https://github.com/oven-sh/bun/releases/download/bun-v${V}/bun-${OS}-x64-baseline.zip" >> "$GITHUB_OUTPUT"
30- fi
31-
3218 - name : Setup Bun
33- uses : oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
19+ uses : oven-sh/setup-bun@f4d14e878800623bd8c3ccbb031e8af6b68b24f9 # v2.3.2
3420 with :
35- bun-version-file : ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
36- bun-download-url : ${{ steps.bun-url.outputs.url }}
21+ bun-version-file : package.json
3722
3823 - name : Get cache directory
3924 id : cache
@@ -42,49 +27,34 @@ runs:
4227
4328 - name : Restore Bun dependencies
4429 id : bun-cache
45- uses : actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3 .0
30+ uses : actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.4 .0
4631 with :
4732 path : ${{ steps.cache.outputs.dir }}
4833 key : ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
4934 restore-keys : |
5035 ${{ runner.os }}-bun-
5136
52- - name : Install setuptools for distutils compatibility
53- run : python3 -m pip install setuptools || pip install setuptools || true
54- shell : bash
55-
5637 - name : Install dependencies (with retry)
5738 run : |
58- # 重试机制:Bun 下载某些包时可能失败(特别是 dev/beta 版本)
59- # 参考:https://github.com/oven-sh/bun/issues/xxxx
60-
6139 MAX_RETRIES=3
6240 RETRY_DELAY=5
63-
6441 for i in $(seq 1 $MAX_RETRIES); do
6542 echo "=== Install attempt $i/$MAX_RETRIES ==="
66-
67- # 清理可能的损坏缓存
6843 if [ $i -gt 1 ]; then
69- echo "Cleaning corrupted cache..."
44+ echo "Cleaning cache..."
7045 rm -rf node_modules/.bun node_modules
7146 bun pm cache rm || true
7247 fi
73-
74- # 尝试安装(先用 frozen lockfile,失败则允许更新)
7548 INSTALL_CMD="bun install --frozen-lockfile ${{ inputs.install-flags }}"
7649 if [ "$i" = "$MAX_RETRIES" ]; then
7750 echo "Last attempt: allowing lockfile updates..."
7851 INSTALL_CMD="bun install ${{ inputs.install-flags }}"
7952 fi
80-
8153 if [ "$RUNNER_OS" = "Windows" ]; then
8254 $INSTALL_CMD --linker hoisted && break
8355 else
8456 $INSTALL_CMD && break
8557 fi
86-
87- # 如果还有重试机会,等待后重试
8858 if [ $i -lt $MAX_RETRIES ]; then
8959 echo "Install failed, retrying in ${RETRY_DELAY}s..."
9060 sleep $RETRY_DELAY
@@ -93,17 +63,12 @@ runs:
9363 exit 1
9464 fi
9565 done
96-
9766 echo "✅ Dependencies installed successfully"
9867 shell : bash
9968
100- - name : Dedupe packages
101- run : bun run scripts/dedupe-keymap.ts
102- shell : bash
103-
10469 - name : Save Bun dependencies
10570 if : steps.bun-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
106- uses : actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3 .0
71+ uses : actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.4 .0
10772 with :
10873 path : ${{ steps.cache.outputs.dir }}
10974 key : ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
0 commit comments