build.yml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. paths: ['.github/workflows/**', 'CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  11. pull_request:
  12. types: [opened, synchronize, edited, reopened, review_requested, ready_for_review]
  13. paths: ['CMakeLists.txt', 'Makefile', '**.h', '*.c', '**.cpp']
  14. env:
  15. BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
  16. jobs:
  17. ubuntu-latest-make:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - name: Clone
  21. id: checkout
  22. uses: actions/checkout@v1
  23. - name: Dependencies
  24. id: depends
  25. run: |
  26. sudo apt-get update
  27. sudo apt-get install build-essential
  28. - name: Build
  29. id: make_build
  30. run: |
  31. make
  32. ubuntu-latest-cmake:
  33. runs-on: ubuntu-latest
  34. steps:
  35. - name: Clone
  36. uses: actions/checkout@v1
  37. - name: Dependencies
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get install build-essential
  41. - name: Build
  42. run: |
  43. mkdir build
  44. cd build
  45. cmake ..
  46. cmake --build . --config Release
  47. macOS-latest-make:
  48. runs-on: macos-latest
  49. steps:
  50. - name: Clone
  51. id: checkout
  52. uses: actions/checkout@v1
  53. - name: Dependencies
  54. id: depends
  55. run: |
  56. brew update
  57. - name: Build
  58. id: make_build
  59. run: |
  60. make
  61. macOS-latest-cmake:
  62. runs-on: macOS-latest
  63. steps:
  64. - name: Clone
  65. uses: actions/checkout@v1
  66. - name: Dependencies
  67. run: |
  68. brew update
  69. - name: Build
  70. run: |
  71. mkdir build
  72. cd build
  73. cmake ..
  74. cmake --build . --config Release
  75. windows-latest-cmake:
  76. runs-on: windows-latest
  77. steps:
  78. - name: Clone
  79. id: checkout
  80. uses: actions/checkout@v1
  81. - name: Build
  82. id: cmake_build
  83. run: |
  84. mkdir build
  85. cd build
  86. cmake ..
  87. cmake --build . --config Release
  88. - name: Get commit hash
  89. id: commit
  90. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  91. uses: pr-mpt/actions-commit-hash@v2
  92. - name: Pack artifacts
  93. id: pack_artifacts
  94. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  95. run: |
  96. 7z a llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip .\build\Release\*
  97. - name: Create release
  98. id: create_release
  99. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  100. uses: zendesk/action-create-release@v1
  101. env:
  102. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  103. with:
  104. tag_name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}
  105. - name: Upload release
  106. id: upload_release
  107. if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
  108. uses: actions/upload-release-asset@v1
  109. env:
  110. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  111. with:
  112. upload_url: ${{ steps.create_release.outputs.upload_url }}
  113. asset_path: .\llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
  114. asset_name: llama-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-x64.zip
  115. asset_content_type: application/octet-stream
  116. # ubuntu-latest-gcc:
  117. # runs-on: ubuntu-latest
  118. #
  119. # strategy:
  120. # matrix:
  121. # build: [Debug, Release]
  122. #
  123. # steps:
  124. # - name: Clone
  125. # uses: actions/checkout@v1
  126. #
  127. # - name: Dependencies
  128. # run: |
  129. # sudo apt-get update
  130. # sudo apt-get install build-essential
  131. # sudo apt-get install cmake
  132. #
  133. # - name: Configure
  134. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  135. #
  136. # - name: Build
  137. # run: |
  138. # make
  139. #
  140. # ubuntu-latest-clang:
  141. # runs-on: ubuntu-latest
  142. #
  143. # strategy:
  144. # matrix:
  145. # build: [Debug, Release]
  146. #
  147. # steps:
  148. # - name: Clone
  149. # uses: actions/checkout@v1
  150. #
  151. # - name: Dependencies
  152. # run: |
  153. # sudo apt-get update
  154. # sudo apt-get install build-essential
  155. # sudo apt-get install cmake
  156. #
  157. # - name: Configure
  158. # run: cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }} -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang
  159. #
  160. # - name: Build
  161. # run: |
  162. # make
  163. #
  164. # ubuntu-latest-gcc-sanitized:
  165. # runs-on: ubuntu-latest
  166. #
  167. # strategy:
  168. # matrix:
  169. # sanitizer: [ADDRESS, THREAD, UNDEFINED]
  170. #
  171. # steps:
  172. # - name: Clone
  173. # uses: actions/checkout@v1
  174. #
  175. # - name: Dependencies
  176. # run: |
  177. # sudo apt-get update
  178. # sudo apt-get install build-essential
  179. # sudo apt-get install cmake
  180. #
  181. # - name: Configure
  182. # run: cmake . -DCMAKE_BUILD_TYPE=Debug -DLLAMA_SANITIZE_${{ matrix.sanitizer }}=ON
  183. #
  184. # - name: Build
  185. # run: |
  186. # make
  187. #
  188. # windows:
  189. # runs-on: windows-latest
  190. #
  191. # strategy:
  192. # matrix:
  193. # build: [Release]
  194. # arch: [Win32, x64]
  195. # include:
  196. # - arch: Win32
  197. # s2arc: x86
  198. # - arch: x64
  199. # s2arc: x64
  200. #
  201. # steps:
  202. # - name: Clone
  203. # uses: actions/checkout@v1
  204. #
  205. # - name: Add msbuild to PATH
  206. # uses: microsoft/setup-msbuild@v1
  207. #
  208. # - name: Configure
  209. # run: >
  210. # cmake -S . -B ./build -A ${{ matrix.arch }}
  211. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  212. #
  213. # - name: Build
  214. # run: |
  215. # cd ./build
  216. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  217. #
  218. # - name: Upload binaries
  219. # uses: actions/upload-artifact@v1
  220. # with:
  221. # name: llama-bin-${{ matrix.arch }}
  222. # path: build/bin/${{ matrix.build }}
  223. #
  224. # windows-blas:
  225. # runs-on: windows-latest
  226. #
  227. # strategy:
  228. # matrix:
  229. # build: [Release]
  230. # arch: [Win32, x64]
  231. # blas: [ON]
  232. # include:
  233. # - arch: Win32
  234. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x86.zip
  235. # s2arc: x86
  236. # - arch: x64
  237. # obzip: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.21/OpenBLAS-0.3.21-x64.zip
  238. # s2arc: x64
  239. #
  240. # steps:
  241. # - name: Clone
  242. # uses: actions/checkout@v1
  243. #
  244. # - name: Add msbuild to PATH
  245. # uses: microsoft/setup-msbuild@v1
  246. #
  247. # - name: Fetch OpenBLAS
  248. # if: matrix.blas == 'ON'
  249. # run: |
  250. # C:/msys64/usr/bin/wget.exe -qO blas.zip ${{ matrix.obzip }}
  251. # 7z x blas.zip -oblas -y
  252. # copy blas/include/cblas.h .
  253. # copy blas/include/openblas_config.h .
  254. # echo "blasdir=$env:GITHUB_WORKSPACE/blas" >> $env:GITHUB_ENV
  255. #
  256. # - name: Configure
  257. # run: >
  258. # cmake -S . -B ./build -A ${{ matrix.arch }}
  259. # -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  260. # -DLLAMA_SUPPORT_OPENBLAS=${{ matrix.blas }}
  261. # -DCMAKE_LIBRARY_PATH="$env:blasdir/lib"
  262. #
  263. # - name: Build
  264. # run: |
  265. # cd ./build
  266. # msbuild ALL_BUILD.vcxproj -t:build -p:configuration=${{ matrix.build }} -p:platform=${{ matrix.arch }}
  267. #
  268. # - name: Copy libopenblas.dll
  269. # if: matrix.blas == 'ON'
  270. # run: copy "$env:blasdir/bin/libopenblas.dll" build/bin/${{ matrix.build }}
  271. #
  272. # - name: Upload binaries
  273. # if: matrix.blas == 'ON'
  274. # uses: actions/upload-artifact@v1
  275. # with:
  276. # name: llama-blas-bin-${{ matrix.arch }}
  277. # path: build/bin/${{ matrix.build }}
  278. #
  279. # emscripten:
  280. # runs-on: ubuntu-latest
  281. #
  282. # strategy:
  283. # matrix:
  284. # build: [Release]
  285. #
  286. # steps:
  287. # - name: Clone
  288. # uses: actions/checkout@v1
  289. #
  290. # - name: Dependencies
  291. # run: |
  292. # wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz
  293. # tar -xvf master.tar.gz
  294. # emsdk-master/emsdk update
  295. # emsdk-master/emsdk install latest
  296. # emsdk-master/emsdk activate latest
  297. #
  298. # - name: Configure
  299. # run: echo "tmp"
  300. #
  301. # - name: Build
  302. # run: |
  303. # pushd emsdk-master
  304. # source ./emsdk_env.sh
  305. # popd
  306. # emcmake cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build }}
  307. # make