@fugood/llama.node 0.3.17 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/CMakeLists.txt +3 -1
  2. package/bin/darwin/arm64/llama-node.node +0 -0
  3. package/bin/darwin/x64/llama-node.node +0 -0
  4. package/bin/linux/arm64/llama-node.node +0 -0
  5. package/bin/linux/x64/llama-node.node +0 -0
  6. package/bin/linux-cuda/arm64/llama-node.node +0 -0
  7. package/bin/linux-cuda/x64/llama-node.node +0 -0
  8. package/bin/linux-vulkan/arm64/llama-node.node +0 -0
  9. package/bin/linux-vulkan/x64/llama-node.node +0 -0
  10. package/bin/win32/arm64/llama-node.node +0 -0
  11. package/bin/win32/arm64/node.lib +0 -0
  12. package/bin/win32/x64/llama-node.node +0 -0
  13. package/bin/win32/x64/node.lib +0 -0
  14. package/bin/win32-vulkan/arm64/llama-node.node +0 -0
  15. package/bin/win32-vulkan/arm64/node.lib +0 -0
  16. package/bin/win32-vulkan/x64/llama-node.node +0 -0
  17. package/bin/win32-vulkan/x64/node.lib +0 -0
  18. package/lib/binding.ts +39 -2
  19. package/lib/index.js +132 -1
  20. package/lib/index.ts +203 -3
  21. package/package.json +2 -1
  22. package/src/EmbeddingWorker.cpp +1 -1
  23. package/src/LlamaCompletionWorker.cpp +366 -19
  24. package/src/LlamaCompletionWorker.h +30 -10
  25. package/src/LlamaContext.cpp +213 -5
  26. package/src/LlamaContext.h +12 -0
  27. package/src/common.hpp +15 -0
  28. package/src/llama.cpp/.github/workflows/build-linux-cross.yml +133 -24
  29. package/src/llama.cpp/.github/workflows/build.yml +41 -762
  30. package/src/llama.cpp/.github/workflows/docker.yml +5 -2
  31. package/src/llama.cpp/.github/workflows/release.yml +716 -0
  32. package/src/llama.cpp/.github/workflows/server.yml +12 -12
  33. package/src/llama.cpp/CMakeLists.txt +5 -17
  34. package/src/llama.cpp/cmake/build-info.cmake +8 -2
  35. package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -6
  36. package/src/llama.cpp/common/CMakeLists.txt +31 -3
  37. package/src/llama.cpp/common/arg.cpp +48 -29
  38. package/src/llama.cpp/common/chat.cpp +128 -106
  39. package/src/llama.cpp/common/chat.h +2 -0
  40. package/src/llama.cpp/common/common.cpp +37 -1
  41. package/src/llama.cpp/common/common.h +18 -9
  42. package/src/llama.cpp/common/llguidance.cpp +1 -0
  43. package/src/llama.cpp/common/minja/chat-template.hpp +9 -5
  44. package/src/llama.cpp/common/minja/minja.hpp +69 -36
  45. package/src/llama.cpp/common/regex-partial.cpp +204 -0
  46. package/src/llama.cpp/common/regex-partial.h +56 -0
  47. package/src/llama.cpp/common/sampling.cpp +57 -50
  48. package/src/llama.cpp/examples/CMakeLists.txt +2 -23
  49. package/src/llama.cpp/examples/embedding/embedding.cpp +2 -11
  50. package/src/llama.cpp/examples/parallel/parallel.cpp +86 -14
  51. package/src/llama.cpp/examples/training/CMakeLists.txt +5 -0
  52. package/src/llama.cpp/examples/training/finetune.cpp +96 -0
  53. package/src/llama.cpp/ggml/CMakeLists.txt +27 -0
  54. package/src/llama.cpp/ggml/include/ggml-backend.h +4 -4
  55. package/src/llama.cpp/ggml/include/ggml-cpp.h +1 -1
  56. package/src/llama.cpp/ggml/include/ggml-opt.h +47 -28
  57. package/src/llama.cpp/ggml/include/ggml.h +10 -7
  58. package/src/llama.cpp/ggml/src/CMakeLists.txt +1 -1
  59. package/src/llama.cpp/ggml/src/ggml-alloc.c +4 -1
  60. package/src/llama.cpp/ggml/src/ggml-backend.cpp +9 -5
  61. package/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +20 -13
  62. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +0 -2
  63. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-quants.c +306 -6
  64. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +4 -13
  65. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +29 -16
  66. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.cpp +88 -5
  67. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.h +47 -12
  68. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +264 -69
  69. package/src/llama.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +501 -0
  70. package/src/llama.cpp/ggml/src/ggml-cpu/ops.cpp +0 -13
  71. package/src/llama.cpp/ggml/src/ggml-cpu/vec.cpp +0 -6
  72. package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +23 -4
  73. package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +36 -11
  74. package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -2
  75. package/src/llama.cpp/ggml/src/ggml-opt.cpp +368 -190
  76. package/src/llama.cpp/ggml/src/ggml-quants.c +0 -6
  77. package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +41 -27
  78. package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +29 -23
  79. package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +9 -8
  80. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +121 -232
  81. package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +7 -15
  82. package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +72 -25
  83. package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +14 -7
  84. package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +59 -21
  85. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +7 -1
  86. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -23
  87. package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +37 -8
  88. package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +338 -166
  89. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +185 -89
  90. package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +83 -0
  91. package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +128 -53
  92. package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +81 -70
  93. package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +657 -193
  94. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +20 -0
  95. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +123 -29
  96. package/src/llama.cpp/ggml/src/ggml.c +29 -20
  97. package/src/llama.cpp/ggml/src/gguf.cpp +33 -33
  98. package/src/llama.cpp/include/llama.h +52 -11
  99. package/src/llama.cpp/requirements/requirements-all.txt +3 -3
  100. package/src/llama.cpp/scripts/xxd.cmake +1 -1
  101. package/src/llama.cpp/src/CMakeLists.txt +1 -0
  102. package/src/llama.cpp/src/llama-adapter.cpp +6 -0
  103. package/src/llama.cpp/src/llama-arch.cpp +3 -0
  104. package/src/llama.cpp/src/llama-batch.cpp +5 -1
  105. package/src/llama.cpp/src/llama-batch.h +2 -1
  106. package/src/llama.cpp/src/llama-chat.cpp +17 -7
  107. package/src/llama.cpp/src/llama-chat.h +1 -0
  108. package/src/llama.cpp/src/llama-context.cpp +389 -501
  109. package/src/llama.cpp/src/llama-context.h +44 -32
  110. package/src/llama.cpp/src/llama-cparams.h +1 -0
  111. package/src/llama.cpp/src/llama-graph.cpp +20 -38
  112. package/src/llama.cpp/src/llama-graph.h +12 -8
  113. package/src/llama.cpp/src/llama-kv-cache.cpp +1503 -389
  114. package/src/llama.cpp/src/llama-kv-cache.h +271 -85
  115. package/src/llama.cpp/src/llama-memory.h +11 -1
  116. package/src/llama.cpp/src/llama-model-loader.cpp +24 -15
  117. package/src/llama.cpp/src/llama-model-saver.cpp +281 -0
  118. package/src/llama.cpp/src/llama-model-saver.h +37 -0
  119. package/src/llama.cpp/src/llama-model.cpp +316 -69
  120. package/src/llama.cpp/src/llama-model.h +8 -1
  121. package/src/llama.cpp/src/llama-quant.cpp +15 -13
  122. package/src/llama.cpp/src/llama-sampling.cpp +18 -6
  123. package/src/llama.cpp/src/llama-vocab.cpp +42 -4
  124. package/src/llama.cpp/src/llama-vocab.h +6 -0
  125. package/src/llama.cpp/src/llama.cpp +14 -0
  126. package/src/llama.cpp/tests/CMakeLists.txt +10 -2
  127. package/src/llama.cpp/tests/test-backend-ops.cpp +107 -47
  128. package/src/llama.cpp/tests/test-chat-template.cpp +10 -11
  129. package/src/llama.cpp/tests/test-chat.cpp +3 -1
  130. package/src/llama.cpp/tests/test-mtmd-c-api.c +63 -0
  131. package/src/llama.cpp/tests/test-opt.cpp +33 -21
  132. package/src/llama.cpp/tests/test-regex-partial.cpp +288 -0
  133. package/src/llama.cpp/tests/test-sampling.cpp +1 -1
  134. package/src/llama.cpp/tools/CMakeLists.txt +39 -0
  135. package/src/llama.cpp/{examples → tools}/batched-bench/batched-bench.cpp +2 -2
  136. package/src/llama.cpp/{examples → tools}/imatrix/imatrix.cpp +11 -9
  137. package/src/llama.cpp/{examples → tools}/llama-bench/llama-bench.cpp +495 -348
  138. package/src/llama.cpp/{examples → tools}/main/main.cpp +6 -9
  139. package/src/llama.cpp/{examples/llava → tools/mtmd}/CMakeLists.txt +1 -35
  140. package/src/llama.cpp/{examples/llava → tools/mtmd}/clip-impl.h +25 -5
  141. package/src/llama.cpp/{examples/llava → tools/mtmd}/clip.cpp +1440 -1349
  142. package/src/llama.cpp/tools/mtmd/clip.h +99 -0
  143. package/src/llama.cpp/{examples/llava → tools/mtmd}/mtmd-cli.cpp +70 -44
  144. package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +310 -0
  145. package/src/llama.cpp/{examples/llava → tools/mtmd}/mtmd.cpp +251 -281
  146. package/src/llama.cpp/tools/mtmd/mtmd.h +331 -0
  147. package/src/llama.cpp/{examples → tools}/perplexity/perplexity.cpp +4 -2
  148. package/src/llama.cpp/{examples → tools}/quantize/quantize.cpp +13 -76
  149. package/src/llama.cpp/{examples → tools}/rpc/rpc-server.cpp +70 -74
  150. package/src/llama.cpp/{examples → tools}/run/run.cpp +18 -4
  151. package/src/llama.cpp/{examples → tools}/server/CMakeLists.txt +2 -1
  152. package/src/llama.cpp/{examples → tools}/server/server.cpp +291 -76
  153. package/src/llama.cpp/{examples → tools}/server/utils.hpp +377 -5
  154. package/src/llama.cpp/cmake/arm64-windows-msvc.cmake +0 -6
  155. package/src/llama.cpp/examples/infill/CMakeLists.txt +0 -5
  156. package/src/llama.cpp/examples/infill/infill.cpp +0 -590
  157. package/src/llama.cpp/examples/llava/android/build_64.sh +0 -8
  158. package/src/llama.cpp/examples/llava/clip-quantize-cli.cpp +0 -59
  159. package/src/llama.cpp/examples/llava/clip.h +0 -135
  160. package/src/llama.cpp/examples/llava/llava.cpp +0 -586
  161. package/src/llama.cpp/examples/llava/llava.h +0 -49
  162. package/src/llama.cpp/examples/llava/mtmd.h +0 -168
  163. package/src/llama.cpp/examples/llava/qwen2vl-test.cpp +0 -636
  164. /package/src/llama.cpp/{examples → tools}/batched-bench/CMakeLists.txt +0 -0
  165. /package/src/llama.cpp/{examples → tools}/cvector-generator/CMakeLists.txt +0 -0
  166. /package/src/llama.cpp/{examples → tools}/cvector-generator/completions.txt +0 -0
  167. /package/src/llama.cpp/{examples → tools}/cvector-generator/cvector-generator.cpp +0 -0
  168. /package/src/llama.cpp/{examples → tools}/cvector-generator/mean.hpp +0 -0
  169. /package/src/llama.cpp/{examples → tools}/cvector-generator/negative.txt +0 -0
  170. /package/src/llama.cpp/{examples → tools}/cvector-generator/pca.hpp +0 -0
  171. /package/src/llama.cpp/{examples → tools}/cvector-generator/positive.txt +0 -0
  172. /package/src/llama.cpp/{examples → tools}/export-lora/CMakeLists.txt +0 -0
  173. /package/src/llama.cpp/{examples → tools}/export-lora/export-lora.cpp +0 -0
  174. /package/src/llama.cpp/{examples → tools}/gguf-split/CMakeLists.txt +0 -0
  175. /package/src/llama.cpp/{examples → tools}/gguf-split/gguf-split.cpp +0 -0
  176. /package/src/llama.cpp/{examples → tools}/imatrix/CMakeLists.txt +0 -0
  177. /package/src/llama.cpp/{examples → tools}/llama-bench/CMakeLists.txt +0 -0
  178. /package/src/llama.cpp/{examples → tools}/main/CMakeLists.txt +0 -0
  179. /package/src/llama.cpp/{examples/llava → tools/mtmd}/deprecation-warning.cpp +0 -0
  180. /package/src/llama.cpp/{examples/llava → tools/mtmd}/requirements.txt +0 -0
  181. /package/src/llama.cpp/{examples → tools}/perplexity/CMakeLists.txt +0 -0
  182. /package/src/llama.cpp/{examples → tools}/quantize/CMakeLists.txt +0 -0
  183. /package/src/llama.cpp/{examples → tools}/rpc/CMakeLists.txt +0 -0
  184. /package/src/llama.cpp/{examples → tools}/run/CMakeLists.txt +0 -0
  185. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.cpp +0 -0
  186. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.h +0 -0
  187. /package/src/llama.cpp/{examples → tools}/server/bench/requirements.txt +0 -0
  188. /package/src/llama.cpp/{examples → tools}/server/httplib.h +0 -0
  189. /package/src/llama.cpp/{examples → tools}/server/tests/requirements.txt +0 -0
  190. /package/src/llama.cpp/{examples → tools}/tokenize/CMakeLists.txt +0 -0
  191. /package/src/llama.cpp/{examples → tools}/tokenize/tokenize.cpp +0 -0
  192. /package/src/llama.cpp/{examples → tools}/tts/CMakeLists.txt +0 -0
  193. /package/src/llama.cpp/{examples → tools}/tts/tts.cpp +0 -0
@@ -0,0 +1,716 @@
1
+ name: Create Release
2
+
3
+ on:
4
+ workflow_dispatch: # allows manual triggering
5
+ inputs:
6
+ create_release:
7
+ description: 'Create new release'
8
+ required: true
9
+ type: boolean
10
+ push:
11
+ branches:
12
+ - master
13
+ paths: ['.github/workflows/release.yml', '**/CMakeLists.txt', '**/.cmake', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.cuh', '**/*.swift', '**/*.m', '**/*.metal', '**/*.comp']
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
17
+ cancel-in-progress: true
18
+
19
+ env:
20
+ BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
21
+ CMAKE_ARGS: "-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TESTS=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON -DGGML_RPC=ON"
22
+
23
+ jobs:
24
+ macOS-arm64:
25
+ runs-on: macos-14
26
+
27
+ steps:
28
+ - name: Clone
29
+ id: checkout
30
+ uses: actions/checkout@v4
31
+ with:
32
+ fetch-depth: 0
33
+
34
+ - name: ccache
35
+ uses: hendrikmuhs/ccache-action@v1.2.16
36
+ with:
37
+ key: macOS-latest-cmake-arm64
38
+ evict-old-files: 1d
39
+
40
+ - name: Dependencies
41
+ id: depends
42
+ continue-on-error: true
43
+ run: |
44
+ brew update
45
+ brew install curl
46
+
47
+ - name: Build
48
+ id: cmake_build
49
+ run: |
50
+ sysctl -a
51
+ cmake -B build \
52
+ -DCMAKE_BUILD_RPATH="@loader_path" \
53
+ -DLLAMA_FATAL_WARNINGS=ON \
54
+ -DGGML_METAL_USE_BF16=ON \
55
+ -DGGML_METAL_EMBED_LIBRARY=ON \
56
+ -DGGML_RPC=ON \
57
+ ${{ env.CMAKE_ARGS }}
58
+ cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
59
+
60
+ - name: Determine tag name
61
+ id: tag
62
+ uses: ./.github/actions/get-tag-name
63
+
64
+ - name: Pack artifacts
65
+ id: pack_artifacts
66
+ run: |
67
+ cp LICENSE ./build/bin/
68
+ zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip ./build/bin/*
69
+
70
+ - name: Upload artifacts
71
+ uses: actions/upload-artifact@v4
72
+ with:
73
+ path: llama-${{ steps.tag.outputs.name }}-bin-macos-arm64.zip
74
+ name: llama-bin-macos-arm64.zip
75
+
76
+ macOS-x64:
77
+ runs-on: macos-13
78
+
79
+ steps:
80
+ - name: Clone
81
+ id: checkout
82
+ uses: actions/checkout@v4
83
+ with:
84
+ fetch-depth: 0
85
+
86
+ - name: ccache
87
+ uses: hendrikmuhs/ccache-action@v1.2.16
88
+ with:
89
+ key: macOS-latest-cmake-x64
90
+ evict-old-files: 1d
91
+
92
+ - name: Dependencies
93
+ id: depends
94
+ continue-on-error: true
95
+ run: |
96
+ brew update
97
+ brew install curl
98
+
99
+ - name: Build
100
+ id: cmake_build
101
+ run: |
102
+ sysctl -a
103
+ # Metal is disabled due to intermittent failures with Github runners not having a GPU:
104
+ # https://github.com/ggml-org/llama.cpp/actions/runs/8635935781/job/23674807267#step:5:2313
105
+ cmake -B build \
106
+ -DCMAKE_BUILD_RPATH="@loader_path" \
107
+ -DLLAMA_FATAL_WARNINGS=ON \
108
+ -DGGML_METAL=OFF \
109
+ -DGGML_RPC=ON
110
+ cmake --build build --config Release -j $(sysctl -n hw.logicalcpu)
111
+
112
+ - name: Determine tag name
113
+ id: tag
114
+ uses: ./.github/actions/get-tag-name
115
+
116
+ - name: Pack artifacts
117
+ id: pack_artifacts
118
+ run: |
119
+ cp LICENSE ./build/bin/
120
+ zip -r llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip ./build/bin/*
121
+
122
+ - name: Upload artifacts
123
+ uses: actions/upload-artifact@v4
124
+ with:
125
+ path: llama-${{ steps.tag.outputs.name }}-bin-macos-x64.zip
126
+ name: llama-bin-macos-x64.zip
127
+
128
+ ubuntu-22-cpu:
129
+ strategy:
130
+ matrix:
131
+ include:
132
+ - build: 'x64'
133
+ os: ubuntu-22.04
134
+ - build: 'arm64'
135
+ os: ubuntu-22.04-arm
136
+
137
+ runs-on: ${{ matrix.os }}
138
+
139
+ steps:
140
+ - name: Clone
141
+ id: checkout
142
+ uses: actions/checkout@v4
143
+ with:
144
+ fetch-depth: 0
145
+
146
+ - name: ccache
147
+ uses: hendrikmuhs/ccache-action@v1.2.16
148
+ with:
149
+ key: ubuntu-cpu-cmake
150
+ evict-old-files: 1d
151
+
152
+ - name: Dependencies
153
+ id: depends
154
+ run: |
155
+ sudo apt-get update
156
+ sudo apt-get install build-essential libcurl4-openssl-dev
157
+
158
+ - name: Build
159
+ id: cmake_build
160
+ run: |
161
+ cmake -B build \
162
+ -DLLAMA_FATAL_WARNINGS=ON \
163
+ ${{ env.CMAKE_ARGS }}
164
+ cmake --build build --config Release -j $(nproc)
165
+
166
+ - name: Determine tag name
167
+ id: tag
168
+ uses: ./.github/actions/get-tag-name
169
+
170
+ - name: Pack artifacts
171
+ id: pack_artifacts
172
+ run: |
173
+ cp LICENSE ./build/bin/
174
+ zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.zip ./build/bin/*
175
+
176
+ - name: Upload artifacts
177
+ uses: actions/upload-artifact@v4
178
+ with:
179
+ path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-${{ matrix.build }}.zip
180
+ name: llama-bin-ubuntu-${{ matrix.build }}.zip
181
+
182
+ ubuntu-22-vulkan:
183
+ runs-on: ubuntu-22.04
184
+
185
+ steps:
186
+ - name: Clone
187
+ id: checkout
188
+ uses: actions/checkout@v4
189
+ with:
190
+ fetch-depth: 0
191
+
192
+ - name: ccache
193
+ uses: hendrikmuhs/ccache-action@v1.2.16
194
+ with:
195
+ key: ubuntu-22-cmake-vulkan
196
+ evict-old-files: 1d
197
+
198
+ - name: Dependencies
199
+ id: depends
200
+ run: |
201
+ wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add -
202
+ sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-jammy.list https://packages.lunarg.com/vulkan/lunarg-vulkan-jammy.list
203
+ sudo apt-get update -y
204
+ sudo apt-get install -y build-essential mesa-vulkan-drivers vulkan-sdk libcurl4-openssl-dev
205
+
206
+ - name: Build
207
+ id: cmake_build
208
+ run: |
209
+ cmake -B build \
210
+ -DGGML_VULKAN=ON \
211
+ ${{ env.CMAKE_ARGS }}
212
+ cmake --build build --config Release -j $(nproc)
213
+
214
+ - name: Determine tag name
215
+ id: tag
216
+ uses: ./.github/actions/get-tag-name
217
+
218
+ - name: Pack artifacts
219
+ id: pack_artifacts
220
+ run: |
221
+ cp LICENSE ./build/bin/
222
+ zip -r llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip ./build/bin/*
223
+
224
+ - name: Upload artifacts
225
+ uses: actions/upload-artifact@v4
226
+ with:
227
+ path: llama-${{ steps.tag.outputs.name }}-bin-ubuntu-vulkan-x64.zip
228
+ name: llama-bin-ubuntu-vulkan-x64.zip
229
+
230
+ windows:
231
+ runs-on: windows-latest
232
+
233
+ env:
234
+ OPENBLAS_VERSION: 0.3.23
235
+ VULKAN_VERSION: 1.4.309.0
236
+
237
+ strategy:
238
+ matrix:
239
+ include:
240
+ - build: 'cpu-x64'
241
+ arch: 'x64'
242
+ defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF'
243
+ #- build: 'openblas-x64'
244
+ # arch: 'x64'
245
+ # defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/x64-windows-llvm.cmake -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_OPENMP=OFF -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
246
+ - build: 'vulkan-x64'
247
+ arch: 'x64'
248
+ defines: '-DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON'
249
+ - build: 'cpu-arm64'
250
+ arch: 'arm64'
251
+ defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DGGML_NATIVE=OFF'
252
+ - build: 'opencl-adreno-arm64'
253
+ arch: 'arm64'
254
+ defines: '-G "Ninja Multi-Config" -D CMAKE_TOOLCHAIN_FILE=cmake/arm64-windows-llvm.cmake -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" -DGGML_OPENCL=ON -DGGML_OPENCL_USE_ADRENO_KERNELS=ON'
255
+
256
+ steps:
257
+ - name: Clone
258
+ id: checkout
259
+ uses: actions/checkout@v4
260
+ with:
261
+ fetch-depth: 0
262
+
263
+ - name: ccache
264
+ uses: hendrikmuhs/ccache-action@v1.2.16
265
+ with:
266
+ key: windows-latest-cmake-${{ matrix.build }}
267
+ variant: ccache
268
+ evict-old-files: 1d
269
+
270
+ - name: Download OpenBLAS
271
+ id: get_openblas
272
+ if: ${{ matrix.build == 'openblas-x64' }}
273
+ run: |
274
+ curl.exe -o $env:RUNNER_TEMP/openblas.zip -L "https://github.com/xianyi/OpenBLAS/releases/download/v${env:OPENBLAS_VERSION}/OpenBLAS-${env:OPENBLAS_VERSION}-x64.zip"
275
+ curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
276
+ mkdir $env:RUNNER_TEMP/openblas
277
+ tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
278
+ $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
279
+ $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
280
+ $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
281
+ & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
282
+
283
+ - name: Install Vulkan SDK
284
+ id: get_vulkan
285
+ if: ${{ matrix.build == 'vulkan-x64' }}
286
+ run: |
287
+ curl.exe -o $env:RUNNER_TEMP/VulkanSDK-Installer.exe -L "https://sdk.lunarg.com/sdk/download/${env:VULKAN_VERSION}/windows/VulkanSDK-${env:VULKAN_VERSION}-Installer.exe"
288
+ & "$env:RUNNER_TEMP\VulkanSDK-Installer.exe" --accept-licenses --default-answer --confirm-command install
289
+ Add-Content $env:GITHUB_ENV "VULKAN_SDK=C:\VulkanSDK\${env:VULKAN_VERSION}"
290
+ Add-Content $env:GITHUB_PATH "C:\VulkanSDK\${env:VULKAN_VERSION}\bin"
291
+
292
+ - name: Install Ninja
293
+ id: install_ninja
294
+ run: |
295
+ choco install ninja
296
+
297
+ - name: Install OpenCL Headers and Libs
298
+ id: install_opencl
299
+ if: ${{ matrix.build == 'opencl-adreno-arm64' }}
300
+ run: |
301
+ git clone https://github.com/KhronosGroup/OpenCL-Headers
302
+ cd OpenCL-Headers
303
+ cmake -B build `
304
+ -DBUILD_TESTING=OFF `
305
+ -DOPENCL_HEADERS_BUILD_TESTING=OFF `
306
+ -DOPENCL_HEADERS_BUILD_CXX_TESTS=OFF `
307
+ -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
308
+ cmake --build build --target install
309
+ git clone https://github.com/KhronosGroup/OpenCL-ICD-Loader
310
+ cd OpenCL-ICD-Loader
311
+ cmake -B build-arm64-release `
312
+ -A arm64 `
313
+ -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/opencl-arm64-release" `
314
+ -DCMAKE_INSTALL_PREFIX="$env:RUNNER_TEMP/opencl-arm64-release"
315
+ cmake --build build-arm64-release --target install --config release
316
+
317
+ - name: libCURL
318
+ id: get_libcurl
319
+ uses: ./.github/actions/windows-setup-curl
320
+ with:
321
+ architecture: ${{ matrix.arch == 'x64' && 'win64' || 'win64a' }}
322
+
323
+ - name: Build
324
+ id: cmake_build
325
+ env:
326
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
327
+ run: |
328
+ cmake -S . -B build ${{ matrix.defines }} `
329
+ -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
330
+ ${{ env.CMAKE_ARGS }}
331
+ cmake --build build --config Release -j ${env:NUMBER_OF_PROCESSORS}
332
+
333
+ - name: Add libopenblas.dll
334
+ id: add_libopenblas_dll
335
+ if: ${{ matrix.build == 'openblas-x64' }}
336
+ run: |
337
+ cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
338
+ cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
339
+
340
+ - name: Determine tag name
341
+ id: tag
342
+ uses: ./.github/actions/get-tag-name
343
+
344
+ - name: Pack artifacts
345
+ id: pack_artifacts
346
+ env:
347
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
348
+ run: |
349
+ Copy-Item $env:CURL_PATH\bin\libcurl-${{ matrix.arch }}.dll .\build\bin\Release\
350
+ 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip .\build\bin\Release\*
351
+
352
+ - name: Upload artifacts
353
+ uses: actions/upload-artifact@v4
354
+ with:
355
+ path: llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}.zip
356
+ name: llama-bin-win-${{ matrix.build }}.zip
357
+
358
+ windows-cuda:
359
+ runs-on: windows-2019
360
+
361
+ strategy:
362
+ matrix:
363
+ cuda: ['12.4', '11.7']
364
+
365
+ steps:
366
+ - name: Clone
367
+ id: checkout
368
+ uses: actions/checkout@v4
369
+ with:
370
+ fetch-depth: 0
371
+
372
+ - name: Install ccache
373
+ uses: hendrikmuhs/ccache-action@v1.2.16
374
+ with:
375
+ key: windows-cuda-${{ matrix.cuda }}
376
+ variant: ccache
377
+ evict-old-files: 1d
378
+
379
+ - name: Install Cuda Toolkit
380
+ uses: ./.github/actions/windows-setup-cuda
381
+ with:
382
+ cuda_version: ${{ matrix.cuda }}
383
+
384
+ - name: Install Ninja
385
+ id: install_ninja
386
+ run: |
387
+ choco install ninja
388
+
389
+ - name: libCURL
390
+ id: get_libcurl
391
+ uses: ./.github/actions/windows-setup-curl
392
+
393
+ - name: Build
394
+ id: cmake_build
395
+ shell: cmd
396
+ env:
397
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
398
+ run: |
399
+ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
400
+ cmake -S . -B build -G "Ninja Multi-Config" ^
401
+ -DGGML_NATIVE=OFF ^
402
+ -DGGML_BACKEND_DL=ON ^
403
+ -DGGML_CPU_ALL_VARIANTS=ON ^
404
+ -DGGML_CUDA=ON ^
405
+ -DCURL_LIBRARY="%CURL_PATH%/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="%CURL_PATH%/include" ^
406
+ ${{ env.CMAKE_ARGS }}
407
+ set /A NINJA_JOBS=%NUMBER_OF_PROCESSORS%-1
408
+ cmake --build build --config Release -j %NINJA_JOBS% -t ggml
409
+ cmake --build build --config Release
410
+
411
+ - name: Determine tag name
412
+ id: tag
413
+ uses: ./.github/actions/get-tag-name
414
+
415
+ - name: Pack artifacts
416
+ id: pack_artifacts
417
+ env:
418
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
419
+ run: |
420
+ cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\Release\libcurl-x64.dll
421
+ 7z a llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
422
+
423
+ - name: Upload artifacts
424
+ uses: actions/upload-artifact@v4
425
+ with:
426
+ path: llama-${{ steps.tag.outputs.name }}-bin-win-cuda${{ matrix.cuda }}-x64.zip
427
+ name: llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
428
+
429
+ - name: Copy and pack Cuda runtime
430
+ run: |
431
+ echo "Cuda install location: ${{ env.CUDA_PATH }}"
432
+ $dst='.\build\bin\cudart\'
433
+ robocopy "${{env.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
434
+ robocopy "${{env.CUDA_PATH}}\lib" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
435
+ 7z a cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip $dst\*
436
+
437
+ - name: Upload Cuda runtime
438
+ uses: actions/upload-artifact@v4
439
+ with:
440
+ path: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
441
+ name: cudart-llama-bin-win-cuda${{ matrix.cuda }}-x64.zip
442
+
443
+ windows-sycl:
444
+ runs-on: windows-latest
445
+
446
+ defaults:
447
+ run:
448
+ shell: bash
449
+
450
+ env:
451
+ WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/b380d914-366b-4b77-a74a-05e3c38b3514/intel-oneapi-base-toolkit-2025.0.0.882_offline.exe
452
+ WINDOWS_DPCPP_MKL: intel.oneapi.win.cpp-dpcpp-common:intel.oneapi.win.mkl.devel:intel.oneapi.win.dnnl:intel.oneapi.win.tbb.devel
453
+ ONEAPI_ROOT: "C:/Program Files (x86)/Intel/oneAPI"
454
+ steps:
455
+ - name: Clone
456
+ id: checkout
457
+ uses: actions/checkout@v4
458
+ with:
459
+ fetch-depth: 0
460
+
461
+ - name: ccache
462
+ uses: hendrikmuhs/ccache-action@v1.2.16
463
+ with:
464
+ key: windows-latest-cmake-sycl
465
+ variant: ccache
466
+ evict-old-files: 1d
467
+
468
+ - name: Install
469
+ run: |
470
+ scripts/install-oneapi.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_MKL
471
+
472
+ # TODO: add libcurl support ; we will also need to modify win-build-sycl.bat to accept user-specified args
473
+
474
+ - name: Build
475
+ id: cmake_build
476
+ run: examples/sycl/win-build-sycl.bat
477
+
478
+ - name: Determine tag name
479
+ id: tag
480
+ uses: ./.github/actions/get-tag-name
481
+
482
+ - name: Build the release package
483
+ id: pack_artifacts
484
+ run: |
485
+ echo "cp oneAPI running time dll files in ${{ env.ONEAPI_ROOT }} to ./build/bin"
486
+
487
+ cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_sycl_blas.5.dll" ./build/bin
488
+ cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_core.2.dll" ./build/bin
489
+ cp "${{ env.ONEAPI_ROOT }}/mkl/latest/bin/mkl_tbb_thread.2.dll" ./build/bin
490
+
491
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_level_zero.dll" ./build/bin
492
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_adapter_opencl.dll" ./build/bin
493
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_loader.dll" ./build/bin
494
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/ur_win_proxy_loader.dll" ./build/bin
495
+
496
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/sycl8.dll" ./build/bin
497
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/svml_dispmd.dll" ./build/bin
498
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libmmd.dll" ./build/bin
499
+ cp "${{ env.ONEAPI_ROOT }}/compiler/latest/bin/libiomp5md.dll" ./build/bin
500
+
501
+ cp "${{ env.ONEAPI_ROOT }}/dnnl/latest/bin/dnnl.dll" ./build/bin
502
+ cp "${{ env.ONEAPI_ROOT }}/tbb/latest/bin/tbb12.dll" ./build/bin
503
+
504
+ echo "cp oneAPI running time dll files to ./build/bin done"
505
+ 7z a llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip ./build/bin/*
506
+
507
+ - name: Upload the release package
508
+ uses: actions/upload-artifact@v4
509
+ with:
510
+ path: llama-${{ steps.tag.outputs.name }}-bin-win-sycl-x64.zip
511
+ name: llama-bin-win-sycl-x64.zip
512
+
513
+ windows-hip:
514
+ runs-on: windows-latest
515
+
516
+ strategy:
517
+ matrix:
518
+ gpu_target: [gfx1100, gfx1101, gfx1030]
519
+
520
+ steps:
521
+ - name: Clone
522
+ id: checkout
523
+ uses: actions/checkout@v4
524
+ with:
525
+ fetch-depth: 0
526
+
527
+ - name: Clone rocWMMA repository
528
+ id: clone_rocwmma
529
+ run: |
530
+ git clone https://github.com/rocm/rocwmma --branch rocm-6.2.4 --depth 1
531
+
532
+ - name: ccache
533
+ uses: hendrikmuhs/ccache-action@v1.2.16
534
+ with:
535
+ key: windows-latest-cmake-hip-release
536
+ evict-old-files: 1d
537
+
538
+ - name: Install
539
+ id: depends
540
+ run: |
541
+ $ErrorActionPreference = "Stop"
542
+ write-host "Downloading AMD HIP SDK Installer"
543
+ Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
544
+ write-host "Installing AMD HIP SDK"
545
+ Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
546
+ write-host "Completed AMD HIP SDK installation"
547
+
548
+ - name: Verify ROCm
549
+ id: verify
550
+ run: |
551
+ & 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
552
+
553
+ - name: libCURL
554
+ id: get_libcurl
555
+ uses: ./.github/actions/windows-setup-curl
556
+
557
+ - name: Build
558
+ id: cmake_build
559
+ env:
560
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
561
+ run: |
562
+ $env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
563
+ $env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
564
+ cmake -G "Unix Makefiles" -B build -S . `
565
+ -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" `
566
+ -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" `
567
+ -DCMAKE_CXX_FLAGS="-I$($PWD.Path.Replace('\', '/'))/rocwmma/library/include/" `
568
+ -DCMAKE_BUILD_TYPE=Release `
569
+ -DAMDGPU_TARGETS=${{ matrix.gpu_target }} `
570
+ -DGGML_HIP_ROCWMMA_FATTN=ON `
571
+ -DGGML_HIP=ON `
572
+ -DCURL_LIBRARY="$env:CURL_PATH/lib/libcurl.dll.a" -DCURL_INCLUDE_DIR="$env:CURL_PATH/include" `
573
+ ${{ env.CMAKE_ARGS }}
574
+ cmake --build build -j ${env:NUMBER_OF_PROCESSORS}
575
+ md "build\bin\rocblas\library\"
576
+ cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
577
+ cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
578
+ cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
579
+
580
+ - name: Determine tag name
581
+ id: tag
582
+ uses: ./.github/actions/get-tag-name
583
+
584
+ - name: Pack artifacts
585
+ id: pack_artifacts
586
+ env:
587
+ CURL_PATH: ${{ steps.get_libcurl.outputs.curl_path }}
588
+ run: |
589
+ cp $env:CURL_PATH\bin\libcurl-x64.dll .\build\bin\libcurl-x64.dll
590
+ 7z a llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip .\build\bin\*
591
+
592
+ - name: Upload artifacts
593
+ uses: actions/upload-artifact@v4
594
+ with:
595
+ path: llama-${{ steps.tag.outputs.name }}-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
596
+ name: llama-bin-win-hip-x64-${{ matrix.gpu_target }}.zip
597
+
598
+ ios-xcode-build:
599
+ runs-on: macos-latest
600
+
601
+ steps:
602
+ - name: Checkout code
603
+ uses: actions/checkout@v4
604
+ with:
605
+ fetch-depth: 0
606
+
607
+ - name: Build
608
+ id: cmake_build
609
+ run: |
610
+ sysctl -a
611
+ cmake -B build -G Xcode \
612
+ -DGGML_METAL_USE_BF16=ON \
613
+ -DGGML_METAL_EMBED_LIBRARY=ON \
614
+ -DLLAMA_CURL=OFF \
615
+ -DLLAMA_BUILD_EXAMPLES=OFF \
616
+ -DLLAMA_BUILD_TOOLS=OFF \
617
+ -DLLAMA_BUILD_TESTS=OFF \
618
+ -DLLAMA_BUILD_SERVER=OFF \
619
+ -DCMAKE_SYSTEM_NAME=iOS \
620
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0 \
621
+ -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=ggml
622
+ cmake --build build --config Release -j $(sysctl -n hw.logicalcpu) -- CODE_SIGNING_ALLOWED=NO
623
+
624
+ - name: xcodebuild for swift package
625
+ id: xcodebuild
626
+ run: |
627
+ ./build-xcframework.sh
628
+
629
+ - name: Build Xcode project
630
+ run: xcodebuild -project examples/llama.swiftui/llama.swiftui.xcodeproj -scheme llama.swiftui -sdk iphoneos CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= -destination 'generic/platform=iOS' FRAMEWORK_FOLDER_PATH=./build-ios build
631
+
632
+ - name: Determine tag name
633
+ id: tag
634
+ uses: ./.github/actions/get-tag-name
635
+
636
+ - name: Pack artifacts
637
+ id: pack_artifacts
638
+ run: |
639
+ zip --symlinks -r llama-${{ steps.tag.outputs.name }}-xcframework.zip build-apple/llama.xcframework
640
+
641
+ - name: Upload artifacts
642
+ uses: actions/upload-artifact@v4
643
+ with:
644
+ path: llama-${{ steps.tag.outputs.name }}-xcframework.zip
645
+ name: llama-${{ steps.tag.outputs.name }}-xcframework
646
+
647
+ release:
648
+ if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
649
+
650
+ # Fine-grant permission
651
+ # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
652
+ permissions:
653
+ contents: write # for creating release
654
+
655
+ runs-on: ubuntu-latest
656
+
657
+ needs:
658
+ - ubuntu-22-cpu
659
+ - ubuntu-22-vulkan
660
+ - windows
661
+ - windows-cuda
662
+ - windows-sycl
663
+ - windows-hip
664
+ - macOS-arm64
665
+ - macOS-x64
666
+
667
+ steps:
668
+ - name: Clone
669
+ id: checkout
670
+ uses: actions/checkout@v4
671
+ with:
672
+ fetch-depth: 0
673
+
674
+ - name: Determine tag name
675
+ id: tag
676
+ uses: ./.github/actions/get-tag-name
677
+
678
+ - name: Download artifacts
679
+ id: download-artifact
680
+ uses: actions/download-artifact@v4
681
+ with:
682
+ path: ./artifact
683
+
684
+ - name: Move artifacts
685
+ id: move_artifacts
686
+ run: mkdir -p ./artifact/release && mv ./artifact/*/*.zip ./artifact/release
687
+
688
+ - name: Create release
689
+ id: create_release
690
+ uses: ggml-org/action-create-release@v1
691
+ env:
692
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
693
+ with:
694
+ tag_name: ${{ steps.tag.outputs.name }}
695
+
696
+ - name: Upload release
697
+ id: upload_release
698
+ uses: actions/github-script@v3
699
+ with:
700
+ github-token: ${{secrets.GITHUB_TOKEN}}
701
+ script: |
702
+ const path = require('path');
703
+ const fs = require('fs');
704
+ const release_id = '${{ steps.create_release.outputs.id }}';
705
+ for (let file of await fs.readdirSync('./artifact/release')) {
706
+ if (path.extname(file) === '.zip') {
707
+ console.log('uploadReleaseAsset', file);
708
+ await github.repos.uploadReleaseAsset({
709
+ owner: context.repo.owner,
710
+ repo: context.repo.repo,
711
+ release_id: release_id,
712
+ name: file,
713
+ data: await fs.readFileSync(`./artifact/release/${file}`)
714
+ });
715
+ }
716
+ }