1
0

build.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. name: CI
  2. on:
  3. workflow_dispatch: # allows manual triggering
  4. inputs:
  5. create_release:
  6. description: 'Create new release'
  7. required: true
  8. type: boolean
  9. push:
  10. branches:
  11. - master
  12. paths: ['.github/workflows/**', '**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  13. pull_request:
  14. types: [opened, synchronize, reopened]
  15. paths: ['**/CMakeLists.txt', '**/Makefile', '**/*.h', '**/*.hpp', '**/*.c', '**/*.cpp', '**/*.cu', '**/*.swift', '**/*.m']
  16. env:
  17. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  18. GGML_NLOOP: 3
  19. GGML_N_THREADS: 1
  20. jobs:
  21. ubuntu-focal-make:
  22. runs-on: ubuntu-20.04
  23. steps:
  24. - name: Clone
  25. id: checkout
  26. uses: actions/checkout@v3
  27. - name: Dependencies
  28. id: depends
  29. run: |
  30. sudo apt-get update
  31. sudo apt-get install build-essential gcc-8
  32. - name: Build
  33. id: make_build
  34. run: |
  35. CC=gcc-8 make -j $(nproc)
  36. - name: Test
  37. id: make_test
  38. run: |
  39. CC=gcc-8 make tests -j $(nproc)
  40. make test -j $(nproc)
  41. ubuntu-latest-cmake:
  42. runs-on: ubuntu-latest
  43. steps:
  44. - name: Clone
  45. id: checkout
  46. uses: actions/checkout@v3
  47. - name: Dependencies
  48. id: depends
  49. run: |
  50. sudo apt-get update
  51. sudo apt-get install build-essential
  52. - name: Build
  53. id: cmake_build
  54. run: |
  55. mkdir build
  56. cd build
  57. cmake ..
  58. cmake --build . --config Release -j $(nproc)
  59. - name: Test
  60. id: cmake_test
  61. run: |
  62. cd build
  63. ctest --verbose --timeout 900
  64. ubuntu-latest-cmake-sanitizer:
  65. runs-on: ubuntu-latest
  66. continue-on-error: true
  67. strategy:
  68. matrix:
  69. sanitizer: [ADDRESS, THREAD, UNDEFINED]
  70. build_type: [Debug, Release]
  71. steps:
  72. - name: Clone
  73. id: checkout
  74. uses: actions/checkout@v3
  75. - name: Dependencies
  76. id: depends
  77. run: |
  78. sudo apt-get update
  79. sudo apt-get install build-essential
  80. - name: Build
  81. id: cmake_build
  82. run: |
  83. mkdir build
  84. cd build
  85. cmake .. -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
  86. cmake --build . --config ${{ matrix.build_type }} -j $(nproc)
  87. - name: Test
  88. id: cmake_test
  89. run: |
  90. cd build
  91. ctest --verbose --timeout 900
  92. ubuntu-latest-cmake-mpi:
  93. runs-on: ubuntu-latest
  94. continue-on-error: true
  95. strategy:
  96. matrix:
  97. mpi_library: [mpich, libopenmpi-dev]
  98. steps:
  99. - name: Clone
  100. id: checkout
  101. uses: actions/checkout@v3
  102. - name: Dependencies
  103. id: depends
  104. run: |
  105. sudo apt-get update
  106. sudo apt-get install build-essential ${{ matrix.mpi_library }}
  107. - name: Build
  108. id: cmake_build
  109. run: |
  110. mkdir build
  111. cd build
  112. cmake -DLLAMA_MPI=ON ..
  113. cmake --build . --config Release -j $(nproc)
  114. - name: Test
  115. id: cmake_test
  116. run: |
  117. cd build
  118. ctest --verbose
  119. macOS-latest-make:
  120. runs-on: macos-latest
  121. steps:
  122. - name: Clone
  123. id: checkout
  124. uses: actions/checkout@v3
  125. - name: Dependencies
  126. id: depends
  127. continue-on-error: true
  128. run: |
  129. brew update
  130. - name: Build
  131. id: make_build
  132. run: |
  133. make -j $(sysctl -n hw.logicalcpu)
  134. - name: Test
  135. id: make_test
  136. run: |
  137. make tests -j $(sysctl -n hw.logicalcpu)
  138. make test -j $(sysctl -n hw.logicalcpu)
  139. macOS-latest-cmake:
  140. runs-on: macos-latest
  141. steps:
  142. - name: Clone
  143. id: checkout
  144. uses: actions/checkout@v3
  145. - name: Dependencies
  146. id: depends
  147. continue-on-error: true
  148. run: |
  149. brew update
  150. - name: Build
  151. id: cmake_build
  152. run: |
  153. sysctl -a
  154. mkdir build
  155. cd build
  156. cmake ..
  157. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  158. - name: Test
  159. id: cmake_test
  160. run: |
  161. cd build
  162. ctest --verbose --timeout 900
  163. macOS-latest-cmake-ios:
  164. runs-on: macos-latest
  165. steps:
  166. - name: Clone
  167. id: checkout
  168. uses: actions/checkout@v1
  169. - name: Dependencies
  170. id: depends
  171. continue-on-error: true
  172. run: |
  173. brew update
  174. - name: Build
  175. id: cmake_build
  176. run: |
  177. sysctl -a
  178. mkdir build
  179. cd build
  180. cmake -G Xcode .. \
  181. -DLLAMA_BUILD_EXAMPLES=OFF \
  182. -DLLAMA_BUILD_TESTS=OFF \
  183. -DLLAMA_BUILD_SERVER=OFF \
  184. -DCMAKE_SYSTEM_NAME=iOS \
  185. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  186. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  187. macOS-latest-cmake-tvos:
  188. runs-on: macos-latest
  189. steps:
  190. - name: Clone
  191. id: checkout
  192. uses: actions/checkout@v1
  193. - name: Dependencies
  194. id: depends
  195. continue-on-error: true
  196. run: |
  197. brew update
  198. - name: Build
  199. id: cmake_build
  200. run: |
  201. sysctl -a
  202. mkdir build
  203. cd build
  204. cmake -G Xcode .. \
  205. -DLLAMA_BUILD_EXAMPLES=OFF \
  206. -DLLAMA_BUILD_TESTS=OFF \
  207. -DLLAMA_BUILD_SERVER=OFF \
  208. -DCMAKE_SYSTEM_NAME=tvOS \
  209. -DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
  210. cmake --build . --config Release -j $(sysctl -n hw.logicalcpu)
  211. macOS-latest-swift:
  212. runs-on: macos-latest
  213. strategy:
  214. matrix:
  215. destination: ['generic/platform=macOS', 'generic/platform=iOS', 'generic/platform=tvOS']
  216. steps:
  217. - name: Clone
  218. id: checkout
  219. uses: actions/checkout@v1
  220. - name: Dependencies
  221. id: depends
  222. continue-on-error: true
  223. run: |
  224. brew update
  225. - name: xcodebuild for swift package
  226. id: xcodebuild
  227. run: |
  228. xcodebuild -scheme llama -destination "${{ matrix.destination }}"
  229. - name: Build Swift Example
  230. id: make_build_swift_example
  231. run: |
  232. make swift
  233. windows-latest-cmake:
  234. runs-on: windows-latest
  235. env:
  236. OPENBLAS_VERSION: 0.3.23
  237. OPENCL_VERSION: 2023.04.17
  238. CLBLAST_VERSION: 1.6.0
  239. SDE_VERSION: 9.21.1-2023-04-24
  240. strategy:
  241. matrix:
  242. include:
  243. - build: 'noavx'
  244. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF -DBUILD_SHARED_LIBS=ON'
  245. - build: 'avx2'
  246. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
  247. - build: 'avx'
  248. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX2=OFF -DBUILD_SHARED_LIBS=ON'
  249. - build: 'avx512'
  250. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_AVX512=ON -DBUILD_SHARED_LIBS=ON'
  251. - build: 'clblast'
  252. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CLBLAST=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_PREFIX_PATH="$env:RUNNER_TEMP/clblast"'
  253. - build: 'openblas'
  254. defines: '-DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_BLAS=ON -DBUILD_SHARED_LIBS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS -DBLAS_INCLUDE_DIRS="$env:RUNNER_TEMP/openblas/include" -DBLAS_LIBRARIES="$env:RUNNER_TEMP/openblas/lib/openblas.lib"'
  255. steps:
  256. - name: Clone
  257. id: checkout
  258. uses: actions/checkout@v3
  259. with:
  260. fetch-depth: 0
  261. - name: Download OpenCL SDK
  262. id: get_opencl
  263. if: ${{ matrix.build == 'clblast' }}
  264. run: |
  265. curl.exe -o $env:RUNNER_TEMP/opencl.zip -L "https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v${env:OPENCL_VERSION}/OpenCL-SDK-v${env:OPENCL_VERSION}-Win-x64.zip"
  266. mkdir $env:RUNNER_TEMP/opencl
  267. tar.exe -xvf $env:RUNNER_TEMP/opencl.zip --strip-components=1 -C $env:RUNNER_TEMP/opencl
  268. - name: Download CLBlast
  269. id: get_clblast
  270. if: ${{ matrix.build == 'clblast' }}
  271. run: |
  272. curl.exe -o $env:RUNNER_TEMP/clblast.7z -L "https://github.com/CNugteren/CLBlast/releases/download/${env:CLBLAST_VERSION}/CLBlast-${env:CLBLAST_VERSION}-windows-x64.7z"
  273. curl.exe -o $env:RUNNER_TEMP/CLBlast.LICENSE.txt -L "https://github.com/CNugteren/CLBlast/raw/${env:CLBLAST_VERSION}/LICENSE"
  274. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/clblast.7z
  275. rename-item $env:RUNNER_TEMP/CLBlast-${env:CLBLAST_VERSION}-windows-x64 clblast
  276. foreach ($f in (gci -Recurse -Path "$env:RUNNER_TEMP/clblast" -Filter '*.cmake')) {
  277. $txt = Get-Content -Path $f -Raw
  278. $txt.Replace('C:/vcpkg/packages/opencl_x64-windows/', "$($env:RUNNER_TEMP.Replace('\','/'))/opencl/") | Set-Content -Path $f -Encoding UTF8
  279. }
  280. - name: Download OpenBLAS
  281. id: get_openblas
  282. if: ${{ matrix.build == 'openblas' }}
  283. run: |
  284. 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"
  285. curl.exe -o $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt -L "https://github.com/xianyi/OpenBLAS/raw/v${env:OPENBLAS_VERSION}/LICENSE"
  286. mkdir $env:RUNNER_TEMP/openblas
  287. tar.exe -xvf $env:RUNNER_TEMP/openblas.zip -C $env:RUNNER_TEMP/openblas
  288. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  289. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  290. $lib = $(join-path $msvc 'bin\Hostx64\x64\lib.exe')
  291. & $lib /machine:x64 "/def:${env:RUNNER_TEMP}/openblas/lib/libopenblas.def" "/out:${env:RUNNER_TEMP}/openblas/lib/openblas.lib" /name:openblas.dll
  292. - name: Build
  293. id: cmake_build
  294. run: |
  295. mkdir build
  296. cd build
  297. cmake .. ${{ matrix.defines }}
  298. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  299. - name: Add clblast.dll
  300. id: add_clblast_dll
  301. if: ${{ matrix.build == 'clblast' }}
  302. run: |
  303. cp $env:RUNNER_TEMP/clblast/lib/clblast.dll ./build/bin/Release
  304. cp $env:RUNNER_TEMP/CLBlast.LICENSE.txt ./build/bin/Release/CLBlast-${env:CLBLAST_VERSION}.txt
  305. - name: Add libopenblas.dll
  306. id: add_libopenblas_dll
  307. if: ${{ matrix.build == 'openblas' }}
  308. run: |
  309. cp $env:RUNNER_TEMP/openblas/bin/libopenblas.dll ./build/bin/Release/openblas.dll
  310. cp $env:RUNNER_TEMP/OpenBLAS.LICENSE.txt ./build/bin/Release/OpenBLAS-${env:OPENBLAS_VERSION}.txt
  311. - name: Check AVX512F support
  312. id: check_avx512f
  313. if: ${{ matrix.build == 'avx512' }}
  314. continue-on-error: true
  315. run: |
  316. cd build
  317. $vcdir = $(vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
  318. $msvc = $(join-path $vcdir $('VC\Tools\MSVC\'+$(gc -raw $(join-path $vcdir 'VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt')).Trim()))
  319. $cl = $(join-path $msvc 'bin\Hostx64\x64\cl.exe')
  320. echo 'int main(void){unsigned int a[4];__cpuid(a,7);return !(a[1]&65536);}' >> avx512f.c
  321. & $cl /O2 /GS- /kernel avx512f.c /link /nodefaultlib /entry:main
  322. .\avx512f.exe && echo "AVX512F: YES" && ( echo HAS_AVX512F=1 >> $env:GITHUB_ENV ) || echo "AVX512F: NO"
  323. - name: Test
  324. id: cmake_test
  325. if: ${{ matrix.build != 'clblast' && (matrix.build != 'avx512' || env.HAS_AVX512F == '1') }} # not all machines have native AVX-512
  326. run: |
  327. cd build
  328. ctest -C Release --verbose --timeout 900
  329. - name: Test (Intel SDE)
  330. id: cmake_test_sde
  331. if: ${{ matrix.build == 'avx512' && env.HAS_AVX512F == '0' }} # use Intel SDE for AVX-512 emulation
  332. run: |
  333. curl.exe -o $env:RUNNER_TEMP/sde.tar.xz -L "https://downloadmirror.intel.com/777395/sde-external-${env:SDE_VERSION}-win.tar.xz"
  334. # for some weird reason windows tar doesn't like sde tar.xz
  335. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar.xz
  336. 7z x "-o${env:RUNNER_TEMP}" $env:RUNNER_TEMP/sde.tar
  337. $sde = $(join-path $env:RUNNER_TEMP sde-external-${env:SDE_VERSION}-win/sde.exe)
  338. cd build
  339. & $sde -future -- ctest -C Release --verbose --timeout 900
  340. - name: Determine tag name
  341. id: tag
  342. shell: bash
  343. run: |
  344. BUILD_NUMBER="$(git rev-list --count HEAD)"
  345. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  346. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  347. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  348. else
  349. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  350. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  351. fi
  352. - name: Pack artifacts
  353. id: pack_artifacts
  354. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  355. run: |
  356. Copy-Item LICENSE .\build\bin\Release\llama.cpp.txt
  357. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip .\build\bin\Release\*
  358. - name: Upload artifacts
  359. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  360. uses: actions/upload-artifact@v3
  361. with:
  362. path: |
  363. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-x64.zip
  364. windows-latest-cmake-cublas:
  365. runs-on: windows-latest
  366. strategy:
  367. matrix:
  368. cuda: ['12.2.0', '11.7.1']
  369. build: ['cublas']
  370. steps:
  371. - name: Clone
  372. id: checkout
  373. uses: actions/checkout@v3
  374. with:
  375. fetch-depth: 0
  376. - uses: Jimver/cuda-toolkit@v0.2.11
  377. id: cuda-toolkit
  378. with:
  379. cuda: ${{ matrix.cuda }}
  380. method: 'network'
  381. sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
  382. - name: Build
  383. id: cmake_build
  384. run: |
  385. mkdir build
  386. cd build
  387. cmake .. -DLLAMA_NATIVE=OFF -DLLAMA_BUILD_SERVER=ON -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON
  388. cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
  389. - name: Determine tag name
  390. id: tag
  391. shell: bash
  392. run: |
  393. BUILD_NUMBER="$(git rev-list --count HEAD)"
  394. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  395. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  396. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  397. else
  398. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  399. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  400. fi
  401. - name: Pack artifacts
  402. id: pack_artifacts
  403. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  404. run: |
  405. 7z a llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip .\build\bin\Release\*
  406. - name: Upload artifacts
  407. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  408. uses: actions/upload-artifact@v3
  409. with:
  410. path: |
  411. llama-${{ steps.tag.outputs.name }}-bin-win-${{ matrix.build }}-cu${{ matrix.cuda }}-x64.zip
  412. - name: Copy and pack Cuda runtime
  413. run: |
  414. echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
  415. $dst='.\build\bin\cudart\'
  416. robocopy "${{steps.cuda-toolkit.outputs.CUDA_PATH}}\bin" $dst cudart64_*.dll cublas64_*.dll cublasLt64_*.dll
  417. 7z a cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip $dst\*
  418. - name: Upload Cuda runtime
  419. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  420. uses: actions/upload-artifact@v3
  421. with:
  422. path: |
  423. cudart-llama-bin-win-cu${{ matrix.cuda }}-x64.zip
  424. # freeBSD-latest:
  425. # runs-on: macos-12
  426. # steps:
  427. # - name: Clone
  428. # uses: actions/checkout@v3
  429. #
  430. # - name: Build
  431. # uses: cross-platform-actions/action@v0.19.0
  432. # with:
  433. # operating_system: freebsd
  434. # version: '13.2'
  435. # hypervisor: 'qemu'
  436. # run: |
  437. # sudo pkg update
  438. # sudo pkg install -y gmake automake autoconf pkgconf llvm15 clinfo clover opencl clblast openblas
  439. # gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j `sysctl -n hw.ncpu`
  440. release:
  441. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  442. runs-on: ubuntu-latest
  443. needs:
  444. - ubuntu-focal-make
  445. - ubuntu-latest-cmake
  446. - macOS-latest-make
  447. - macOS-latest-cmake
  448. - windows-latest-cmake
  449. - windows-latest-cmake-cublas
  450. steps:
  451. - name: Clone
  452. id: checkout
  453. uses: actions/checkout@v3
  454. with:
  455. fetch-depth: 0
  456. - name: Determine tag name
  457. id: tag
  458. shell: bash
  459. run: |
  460. BUILD_NUMBER="$(git rev-list --count HEAD)"
  461. SHORT_HASH="$(git rev-parse --short=7 HEAD)"
  462. if [[ "${{ env.BRANCH_NAME }}" == "master" ]]; then
  463. echo "name=b${BUILD_NUMBER}" >> $GITHUB_OUTPUT
  464. else
  465. SAFE_NAME=$(echo "${{ env.BRANCH_NAME }}" | tr '/' '-')
  466. echo "name=${SAFE_NAME}-b${BUILD_NUMBER}-${SHORT_HASH}" >> $GITHUB_OUTPUT
  467. fi
  468. - name: Download artifacts
  469. id: download-artifact
  470. uses: actions/download-artifact@v3
  471. - name: Create release
  472. id: create_release
  473. uses: anzz1/action-create-release@v1
  474. env:
  475. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  476. with:
  477. tag_name: ${{ steps.tag.outputs.name }}
  478. - name: Upload release
  479. id: upload_release
  480. uses: actions/github-script@v3
  481. with:
  482. github-token: ${{secrets.GITHUB_TOKEN}}
  483. script: |
  484. const path = require('path');
  485. const fs = require('fs');
  486. const release_id = '${{ steps.create_release.outputs.id }}';
  487. for (let file of await fs.readdirSync('./artifact')) {
  488. if (path.extname(file) === '.zip') {
  489. console.log('uploadReleaseAsset', file);
  490. await github.repos.uploadReleaseAsset({
  491. owner: context.repo.owner,
  492. repo: context.repo.repo,
  493. release_id: release_id,
  494. name: file,
  495. data: await fs.readFileSync(`./artifact/${file}`)
  496. });
  497. }
  498. }
  499. # ubuntu-latest-gcc:
  500. # runs-on: ubuntu-latest
  501. #
  502. # strategy:
  503. # matrix:
  504. # build: [Debug, Release]
  505. #
  506. # steps:
  507. # - name: Clone
  508. # uses: actions/checkout@v3
  509. #
  510. # - name: Dependencies
  511. # run: |
  512. # sudo apt-get update
  513. # sudo apt-get install build-essential
  514. # sudo apt-get install cmake
  515. #
  516. # - name: Configure
  517. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  518. #
  519. # - name: Build
  520. # run: |
  521. # make
  522. #
  523. # ubuntu-latest-clang:
  524. # runs-on: ubuntu-latest
  525. #
  526. # strategy:
  527. # matrix:
  528. # build: [Debug, Release]
  529. #
  530. # steps:
  531. # - name: Clone
  532. # uses: actions/checkout@v3
  533. #
  534. # - name: Dependencies
  535. # run: |
  536. # sudo apt-get update
  537. # sudo apt-get install build-essential
  538. # sudo apt-get install cmake
  539. #
  540. # - name: Configure
  541. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  542. #
  543. # - name: Build
  544. # run: |
  545. # make
  546. #
  547. # ubuntu-latest-gcc-sanitized:
  548. # runs-on: ubuntu-latest
  549. #
  550. # strategy:
  551. # matrix:
  552. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  553. #
  554. # steps:
  555. # - name: Clone
  556. # uses: actions/checkout@v3
  557. #
  558. # - name: Dependencies
  559. # run: |
  560. # sudo apt-get update
  561. # sudo apt-get install build-essential
  562. # sudo apt-get install cmake
  563. #
  564. # - name: Configure
  565. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  566. #
  567. # - name: Build
  568. # run: |
  569. # make
  570. #
  571. # windows:
  572. # runs-on: windows-latest
  573. #
  574. # strategy:
  575. # matrix:
  576. # build: [Release]
  577. # arch: [Win32, x64]
  578. # include:
  579. # - arch: Win32
  580. # s2arc: x86
  581. # - arch: x64
  582. # s2arc: x64
  583. #
  584. # steps:
  585. # - name: Clone
  586. # uses: actions/checkout@v3
  587. #
  588. # - name: Add msbuild to PATH
  589. # uses: microsoft/setup-msbuild@v1
  590. #
  591. # - name: Configure
  592. # run: >
  593. # cmake -S . -B ./build -A ${{ matrix.arch }}
  594. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  595. #
  596. # - name: Build
  597. # run: |
  598. # cd ./build
  599. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  600. #
  601. # - name: Upload binaries
  602. # uses: actions/upload-artifact@v1
  603. # with:
  604. # name: llama-bin-${{ matrix.arch }}
  605. # path: build/bin/${{ matrix.build }}
  606. #
  607. # windows-blas:
  608. # runs-on: windows-latest
  609. #
  610. # strategy:
  611. # matrix:
  612. # build: [Release]
  613. # arch: [Win32, x64]
  614. # blas: [ON]
  615. # include:
  616. # - arch: Win32
  617. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  618. # s2arc: x86
  619. # - arch: x64
  620. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  621. # s2arc: x64
  622. #
  623. # steps:
  624. # - name: Clone
  625. # uses: actions/checkout@v3
  626. #
  627. # - name: Add msbuild to PATH
  628. # uses: microsoft/setup-msbuild@v1
  629. #
  630. # - name: Fetch OpenBLAS
  631. # if: matrix.blas == 'ON'
  632. # run: |
  633. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  634. # 7z x blas.zip -oblas -y
  635. # copy blas/include/cblas.h .
  636. # copy blas/include/openblas_config.h .
  637. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  638. #
  639. # - name: Configure
  640. # run: >
  641. # cmake -S . -B ./build -A ${{ matrix.arch }}
  642. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  643. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  644. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  645. #
  646. # - name: Build
  647. # run: |
  648. # cd ./build
  649. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  650. #
  651. # - name: Copy libopenblas.dll
  652. # if: matrix.blas == 'ON'
  653. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  654. #
  655. # - name: Upload binaries
  656. # if: matrix.blas == 'ON'
  657. # uses: actions/upload-artifact@v1
  658. # with:
  659. # name: llama-blas-bin-${{ matrix.arch }}
  660. # path: build/bin/${{ matrix.build }}
  661. #
  662. # emscripten:
  663. # runs-on: ubuntu-latest
  664. #
  665. # strategy:
  666. # matrix:
  667. # build: [Release]
  668. #
  669. # steps:
  670. # - name: Clone
  671. # uses: actions/checkout@v3
  672. #
  673. # - name: Dependencies
  674. # run: |
  675. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  676. # tar -xvf master.tar.gz
  677. # emsdk-master/emsdk update
  678. # emsdk-master/emsdk install latest
  679. # emsdk-master/emsdk activate latest
  680. #
  681. # - name: Configure
  682. # run: echo "tmp"
  683. #
  684. # - name: Build
  685. # run: |
  686. # pushd emsdk-master
  687. # source ./emsdk_env.sh
  688. # popd
  689. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  690. # make