build_iwasm_release.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: build iwasm release
  4. on:
  5. workflow_call:
  6. inputs:
  7. arch:
  8. description: arch of the release
  9. type: string
  10. required: false
  11. default: x86_64
  12. cwd:
  13. description: working directory
  14. type: string
  15. required: true
  16. llvm_cache_key:
  17. description: the cache key of llvm libraries
  18. type: string
  19. required: true
  20. runner:
  21. description: OS of compilation
  22. type: string
  23. required: true
  24. upload_url:
  25. description: upload binary assets to the URL of release
  26. type: string
  27. required: false
  28. ver_num:
  29. description: a semantic version number. it is required when `release` is true.
  30. type: string
  31. required: false
  32. env:
  33. DEFAULT_BUILD_OPTIONS:
  34. "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_JIT=1 \
  35. -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
  36. -DWAMR_BUILD_DEBUG_INTERP=0 \
  37. -DWAMR_BUILD_DEBUG_AOT=0 \
  38. -DWAMR_BUILD_DUMP_CALL_STACK=0 \
  39. -DWAMR_BUILD_LIBC_UVWASI=0 \
  40. -DWAMR_BUILD_LIBC_EMCC=0 \
  41. -DWAMR_BUILD_LIB_RATS=0 \
  42. -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
  43. -DWAMR_BUILD_MEMORY_PROFILING=0 \
  44. -DWAMR_BUILD_MINI_LOADER=0 \
  45. -DWAMR_BUILD_MULTI_MODULE=0 \
  46. -DWAMR_BUILD_PERF_PROFILING=0 \
  47. -DWAMR_BUILD_SPEC_TEST=0 \
  48. -DWAMR_BUILD_BULK_MEMORY=1 \
  49. -DWAMR_BUILD_LIB_PTHREAD=1 \
  50. -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
  51. -DWAMR_BUILD_LIB_WASI_THREADS=1 \
  52. -DWAMR_BUILD_LIBC_BUILTIN=1 \
  53. -DWAMR_BUILD_LIBC_WASI=1 \
  54. -DWAMR_BUILD_REF_TYPES=1 \
  55. -DWAMR_BUILD_SIMD=1 \
  56. -DWAMR_BUILD_SHARED_MEMORY=1 \
  57. -DWAMR_BUILD_TAIL_CALL=1 \
  58. -DWAMR_BUILD_THREAD_MGR=1"
  59. GC_EH_BUILD_OPTIONS:
  60. "-DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=1 -DWAMR_BUILD_FAST_INTERP=0 -DWAMR_BUILD_FAST_JIT=0 -DWAMR_BUILD_JIT=0 \
  61. -DWAMR_BUILD_CUSTOM_NAME_SECTION=0 \
  62. -DWAMR_BUILD_DEBUG_INTERP=0 \
  63. -DWAMR_BUILD_DEBUG_AOT=0 \
  64. -DWAMR_BUILD_DUMP_CALL_STACK=0 \
  65. -DWAMR_BUILD_LIBC_UVWASI=0 \
  66. -DWAMR_BUILD_LIBC_EMCC=0 \
  67. -DWAMR_BUILD_LIB_RATS=0 \
  68. -DWAMR_BUILD_LOAD_CUSTOM_SECTION=0 \
  69. -DWAMR_BUILD_MEMORY_PROFILING=0 \
  70. -DWAMR_BUILD_MINI_LOADER=0 \
  71. -DWAMR_BUILD_MULTI_MODULE=0 \
  72. -DWAMR_BUILD_PERF_PROFILING=0 \
  73. -DWAMR_BUILD_SPEC_TEST=0 \
  74. -DWAMR_BUILD_BULK_MEMORY=1 \
  75. -DWAMR_BUILD_LIB_PTHREAD=1 \
  76. -DWAMR_BUILD_LIB_PTHREAD_SEMAPHORE=1 \
  77. -DWAMR_BUILD_LIB_WASI_THREADS=1 \
  78. -DWAMR_BUILD_LIBC_BUILTIN=1 \
  79. -DWAMR_BUILD_LIBC_WASI=1 \
  80. -DWAMR_BUILD_REF_TYPES=1 \
  81. -DWAMR_BUILD_SIMD=1 \
  82. -DWAMR_BUILD_SHARED_MEMORY=1 \
  83. -DWAMR_BUILD_TAIL_CALL=1 \
  84. -DWAMR_BUILD_THREAD_MGR=1 \
  85. -DWAMR_BUILD_EXCE_HANDLING=1 \
  86. -DWAMR_BUILD_GC=1"
  87. permissions:
  88. contents: read
  89. jobs:
  90. build:
  91. runs-on: ${{ inputs.runner }}
  92. strategy:
  93. matrix:
  94. include:
  95. - build_options: $DEFAULT_BUILD_OPTIONS
  96. suffix: ""
  97. - build_options: $GC_EH_BUILD_OPTIONS
  98. suffix: "-gc-eh"
  99. permissions:
  100. contents: write # for uploading release artifacts
  101. steps:
  102. - uses: actions/checkout@v6.0.1
  103. - name: get cached LLVM libraries
  104. id: retrieve_llvm_libs
  105. uses: actions/cache@v5
  106. with:
  107. path: |
  108. ./core/deps/llvm/build/bin
  109. ./core/deps/llvm/build/include
  110. ./core/deps/llvm/build/lib
  111. ./core/deps/llvm/build/libexec
  112. ./core/deps/llvm/build/share
  113. key: ${{ inputs.llvm_cache_key }}
  114. fail-on-cache-miss: true
  115. - name: generate iwasm binary release
  116. shell: bash
  117. run: |
  118. cmake -S . -B build ${{ matrix.build_options }}
  119. cmake --build build --config Release --parallel 4
  120. working-directory: ${{ inputs.cwd }}
  121. - name: smoke test on non-Windows
  122. if: ${{ !startsWith(inputs.runner, 'windows') }}
  123. shell: bash
  124. run: |
  125. if [[ ! -f build/iwasm ]]; then
  126. echo "iwasm binary is not found in the expected location."
  127. exit 1
  128. fi
  129. build/iwasm --version
  130. working-directory: ${{ inputs.cwd }}
  131. - name: smoke test on Windows
  132. if: ${{ startsWith(inputs.runner, 'windows') }}
  133. shell: bash
  134. run: |
  135. if [[ ! -f build/Release/iwasm ]]; then
  136. echo "iwasm binary is not found in the expected location."
  137. exit 1
  138. fi
  139. build/Release/iwasm --version
  140. working-directory: ${{ inputs.cwd }}
  141. - name: Compress the binary on Windows
  142. if: inputs.runner == 'windows-2022'
  143. run: |
  144. tar -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm.exe
  145. Compress-Archive -Path iwasm.exe -DestinationPath iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
  146. mv iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
  147. working-directory: ${{ inputs.cwd }}/build/Release
  148. - name: compress the binary on non-Windows
  149. if: inputs.runner != 'windows-2022'
  150. run: |
  151. # Follow the symlink to the actual binary file
  152. tar --dereference -czf iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz iwasm
  153. zip iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip iwasm
  154. working-directory: ${{ inputs.cwd }}/build
  155. - name: upload release tar.gz
  156. uses: actions/upload-release-asset@v1
  157. env:
  158. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  159. with:
  160. upload_url: ${{ inputs.upload_url }}
  161. asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
  162. asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
  163. asset_content_type: application/x-gzip
  164. - name: upload release zip
  165. uses: actions/upload-release-asset@v1
  166. env:
  167. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  168. with:
  169. upload_url: ${{ inputs.upload_url }}
  170. asset_path: ${{ inputs.cwd }}/build/iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
  171. asset_name: iwasm${{ matrix.suffix }}-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
  172. asset_content_type: application/zip