|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-natives: |
| 10 | + name: Build ${{ matrix.package }} |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + # macOS |
| 17 | + - os: macos-14 |
| 18 | + arch: arm64 |
| 19 | + gpu: metal |
| 20 | + package: darwin-arm64 |
| 21 | + - os: macos-13 |
| 22 | + arch: x64 |
| 23 | + gpu: cpu |
| 24 | + package: darwin-x64 |
| 25 | + |
| 26 | + # Linux |
| 27 | + - os: ubuntu-22.04 |
| 28 | + arch: x64 |
| 29 | + gpu: cpu |
| 30 | + package: linux-x64 |
| 31 | + - os: ubuntu-22.04 |
| 32 | + arch: x64 |
| 33 | + gpu: cuda |
| 34 | + package: linux-x64-cuda |
| 35 | + - os: ubuntu-22.04 |
| 36 | + arch: x64 |
| 37 | + gpu: vulkan |
| 38 | + package: linux-x64-vulkan |
| 39 | + |
| 40 | + # Windows |
| 41 | + - os: windows-2022 |
| 42 | + arch: x64 |
| 43 | + gpu: cpu |
| 44 | + package: win32-x64 |
| 45 | + - os: windows-2022 |
| 46 | + arch: x64 |
| 47 | + gpu: cuda |
| 48 | + cuda_version: 12.2.0 |
| 49 | + package: win32-x64-cuda |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Checkout code |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + submodules: recursive |
| 56 | + |
| 57 | + - name: Setup Node.js |
| 58 | + uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: 20 |
| 61 | + registry-url: 'https://registry.npmjs.org' |
| 62 | + |
| 63 | + # Platform-specific dependencies |
| 64 | + - name: Install build tools (Linux) |
| 65 | + if: runner.os == 'Linux' && matrix.gpu == 'cpu' |
| 66 | + run: | |
| 67 | + sudo apt-get update |
| 68 | + sudo apt-get install -y build-essential cmake |
| 69 | +
|
| 70 | + - name: Install CUDA toolkit (Linux) |
| 71 | + if: matrix.gpu == 'cuda' && runner.os == 'Linux' |
| 72 | + run: | |
| 73 | + wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb |
| 74 | + sudo dpkg -i cuda-keyring_1.1-1_all.deb |
| 75 | + sudo apt-get update |
| 76 | + sudo apt-get install -y cuda-toolkit-12-2 build-essential cmake |
| 77 | +
|
| 78 | + - name: Install Vulkan SDK (Linux) |
| 79 | + if: matrix.gpu == 'vulkan' && runner.os == 'Linux' |
| 80 | + run: | |
| 81 | + sudo apt-get update |
| 82 | + sudo apt-get install -y build-essential cmake libvulkan-dev vulkan-tools |
| 83 | +
|
| 84 | + - name: Install CUDA toolkit (Windows) |
| 85 | + if: matrix.gpu == 'cuda' && runner.os == 'Windows' |
| 86 | + uses: Jimver/cuda-toolkit@v0.2.11 |
| 87 | + with: |
| 88 | + cuda: '12.2.0' |
| 89 | + |
| 90 | + # Build |
| 91 | + - name: Install npm dependencies |
| 92 | + run: npm install |
| 93 | + |
| 94 | + - name: Build native module |
| 95 | + run: npm run build |
| 96 | + env: |
| 97 | + LLOYAL_GPU: ${{ matrix.gpu }} |
| 98 | + |
| 99 | + # Package |
| 100 | + - name: Create platform package |
| 101 | + shell: bash |
| 102 | + run: | |
| 103 | + PKG_NAME="${{ matrix.package }}" |
| 104 | + node scripts/create-platform-package.js "$PKG_NAME" "${{ matrix.os }}" "${{ matrix.arch }}" |
| 105 | +
|
| 106 | + # Publish |
| 107 | + - name: Publish platform package |
| 108 | + working-directory: packages/${{ matrix.package }} |
| 109 | + run: npm publish --access public |
| 110 | + env: |
| 111 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 112 | + |
| 113 | + publish-main: |
| 114 | + name: Publish main package |
| 115 | + needs: build-natives |
| 116 | + runs-on: ubuntu-latest |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Checkout code |
| 120 | + uses: actions/checkout@v4 |
| 121 | + |
| 122 | + - name: Setup Node.js |
| 123 | + uses: actions/setup-node@v4 |
| 124 | + with: |
| 125 | + node-version: 20 |
| 126 | + registry-url: 'https://registry.npmjs.org' |
| 127 | + |
| 128 | + - name: Sync package versions |
| 129 | + run: node scripts/sync-versions.js |
| 130 | + |
| 131 | + - name: Publish main package |
| 132 | + run: npm publish |
| 133 | + env: |
| 134 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
0 commit comments