build_wamrc.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. name: build wamrc
  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. llvm_cache_key:
  13. description: the cache key of llvm libraries
  14. type: string
  15. required: true
  16. release:
  17. description: it is a part of the release process
  18. type: boolean
  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. permissions:
  33. contents: read
  34. jobs:
  35. build:
  36. runs-on: ${{ inputs.runner }}
  37. permissions:
  38. contents: write # for uploading release artifacts
  39. steps:
  40. - uses: actions/checkout@v6.0.1
  41. - name: get cached LLVM libraries
  42. id: retrieve_llvm_libs
  43. uses: actions/cache@v5
  44. with:
  45. path: |
  46. ./core/deps/llvm/build/bin
  47. ./core/deps/llvm/build/include
  48. ./core/deps/llvm/build/lib
  49. ./core/deps/llvm/build/libexec
  50. ./core/deps/llvm/build/share
  51. key: ${{ inputs.llvm_cache_key }}
  52. fail-on-cache-miss: true
  53. - name: generate wamrc binary release
  54. run: |
  55. cmake -S . -B build
  56. cmake --build build --config Release --parallel 4
  57. working-directory: wamr-compiler
  58. - name: smoke test on non-windows
  59. if: ${{ !startsWith(inputs.runner, 'windows') }}
  60. shell: bash
  61. run: |
  62. if [[ ! -f build/wamrc ]]; then
  63. echo "wamrc binary is not found in the expected location."
  64. exit 1
  65. fi
  66. build/wamrc --version
  67. working-directory: wamr-compiler
  68. - name: smoke test on Windows
  69. if: ${{ startsWith(inputs.runner, 'windows') }}
  70. shell: bash
  71. run: |
  72. if [[ ! -f build/Release/wamrc ]]; then
  73. echo "wamrc binary is not found in the expected location."
  74. exit 1
  75. fi
  76. build/Release/wamrc --version
  77. working-directory: wamr-compiler
  78. - name: Compress the binary on Windows
  79. if: inputs.runner == 'windows-2022' && inputs.release
  80. run: |
  81. tar -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc.exe
  82. Compress-Archive -Path wamrc.exe -DestinationPath wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
  83. mv wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.* ../
  84. working-directory: wamr-compiler/build/Release
  85. - name: compress the binary on non-Windows
  86. if: inputs.runner != 'windows-2022' && inputs.release
  87. run: |
  88. # Follow the symlink to the actual binary file
  89. tar --dereference -czf wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz wamrc
  90. zip wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip wamrc
  91. working-directory: wamr-compiler/build
  92. - name: upload release tar.gz
  93. if: inputs.release
  94. uses: actions/upload-release-asset@v1
  95. env:
  96. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  97. with:
  98. upload_url: ${{ inputs.upload_url }}
  99. asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.tar.gz
  100. asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.tar.gz
  101. asset_content_type: application/x-gzip
  102. - name: upload release zip
  103. if: inputs.release
  104. uses: actions/upload-release-asset@v1
  105. env:
  106. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  107. with:
  108. upload_url: ${{ inputs.upload_url }}
  109. asset_path: wamr-compiler/build/wamrc-${{ inputs.ver_num }}-${{ inputs.runner }}.zip
  110. asset_name: wamrc-${{ inputs.ver_num }}-${{ inputs.arch }}-${{ inputs.runner }}.zip
  111. asset_content_type: application/zip