action.yml 1.8 KB

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