build.yml 8.6 KB

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