action.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: "Setup Bun"
  2. description: "Setup Bun with caching and install dependencies"
  3. runs:
  4. using: "composite"
  5. steps:
  6. - name: Get baseline download URL
  7. id: bun-url
  8. shell: bash
  9. run: |
  10. if [ "$RUNNER_ARCH" = "X64" ]; then
  11. V=$(node -p "require('./package.json').packageManager.split('@')[1]")
  12. case "$RUNNER_OS" in
  13. macOS) OS=darwin ;;
  14. Linux) OS=linux ;;
  15. Windows) OS=windows ;;
  16. esac
  17. echo "url=https://github.com/oven-sh/bun/releases/download/bun-v${V}/bun-${OS}-x64-baseline.zip" >> "$GITHUB_OUTPUT"
  18. fi
  19. - name: Setup Bun
  20. uses: oven-sh/setup-bun@v2
  21. with:
  22. bun-version-file: ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
  23. bun-download-url: ${{ steps.bun-url.outputs.url }}
  24. - name: Get cache directory
  25. id: cache
  26. shell: bash
  27. run: echo "dir=$(bun pm cache)" >> "$GITHUB_OUTPUT"
  28. - name: Cache Bun dependencies
  29. uses: actions/cache@v4
  30. with:
  31. path: ${{ steps.cache.outputs.dir }}
  32. key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
  33. restore-keys: |
  34. ${{ runner.os }}-bun-
  35. - name: Install setuptools for distutils compatibility
  36. run: python3 -m pip install setuptools || pip install setuptools || true
  37. shell: bash
  38. - name: Install dependencies
  39. run: |
  40. # Workaround for patched peer variants
  41. # e.g. ./patches/ for standard-openapi
  42. # https://github.com/oven-sh/bun/issues/28147
  43. if [ "$RUNNER_OS" = "Windows" ]; then
  44. bun install --linker hoisted
  45. else
  46. bun install
  47. fi
  48. shell: bash