build_packages.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. name: Cross build packages
  2. concurrency:
  3. group: build-packages-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. workflow_call:
  7. inputs:
  8. profile:
  9. required: true
  10. type: string
  11. publish:
  12. required: true
  13. type: string
  14. otp_vsn:
  15. required: true
  16. type: string
  17. elixir_vsn:
  18. required: true
  19. type: string
  20. builder_vsn:
  21. required: true
  22. type: string
  23. secrets:
  24. AWS_ACCESS_KEY_ID:
  25. required: true
  26. AWS_SECRET_ACCESS_KEY:
  27. required: true
  28. AWS_DEFAULT_REGION:
  29. required: true
  30. AWS_S3_BUCKET:
  31. required: true
  32. AWS_CLOUDFRONT_ID:
  33. required: true
  34. APPLE_ID_PASSWORD:
  35. required: true
  36. APPLE_DEVELOPER_IDENTITY:
  37. required: true
  38. APPLE_DEVELOPER_ID_BUNDLE:
  39. required: true
  40. APPLE_DEVELOPER_ID_BUNDLE_PASSWORD:
  41. required: true
  42. workflow_dispatch:
  43. inputs:
  44. ref:
  45. required: false
  46. profile:
  47. required: false
  48. publish:
  49. required: false
  50. type: boolean
  51. default: false
  52. otp_vsn:
  53. required: false
  54. type: string
  55. default: '25.3.2-2'
  56. elixir_vsn:
  57. required: false
  58. type: string
  59. default: '1.14.5'
  60. builder_vsn:
  61. required: false
  62. type: string
  63. default: '5.2-3'
  64. jobs:
  65. mac:
  66. strategy:
  67. fail-fast: false
  68. matrix:
  69. profile:
  70. - ${{ inputs.profile }}
  71. otp:
  72. - ${{ inputs.otp_vsn }}
  73. os:
  74. - macos-12
  75. - macos-12-arm64
  76. - macos-13
  77. runs-on: ${{ matrix.os }}
  78. steps:
  79. - uses: emqx/self-hosted-cleanup-action@v1.0.3
  80. - uses: actions/checkout@v3
  81. with:
  82. ref: ${{ github.event.inputs.ref }}
  83. fetch-depth: 0
  84. - uses: ./.github/actions/package-macos
  85. with:
  86. profile: ${{ matrix.profile }}
  87. otp: ${{ matrix.otp }}
  88. os: ${{ matrix.os }}
  89. apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
  90. apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
  91. apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
  92. apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
  93. - uses: actions/upload-artifact@v3
  94. if: success()
  95. with:
  96. name: ${{ matrix.profile }}
  97. path: _packages/${{ matrix.profile }}/
  98. retention-days: 7
  99. linux:
  100. runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch }}"]
  101. # always run in builder container because the host might have the wrong OTP version etc.
  102. # otherwise buildx.sh does not run docker if arch and os matches the target arch and os.
  103. container:
  104. image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  105. strategy:
  106. fail-fast: false
  107. matrix:
  108. profile:
  109. - ${{ inputs.profile }}
  110. otp:
  111. - ${{ inputs.otp_vsn }}
  112. arch:
  113. - x64
  114. - arm64
  115. os:
  116. - ubuntu22.04
  117. - ubuntu20.04
  118. - ubuntu18.04
  119. - debian12
  120. - debian11
  121. - debian10
  122. - el9
  123. - el8
  124. - el7
  125. - amzn2
  126. - amzn2023
  127. builder:
  128. - ${{ inputs.builder_vsn }}
  129. elixir:
  130. - ${{ inputs.elixir_vsn }}
  131. with_elixir:
  132. - 'no'
  133. include:
  134. - profile: emqx
  135. otp: ${{ inputs.otp_vsn }}
  136. arch: x64
  137. os: ubuntu22.04
  138. builder: ${{ inputs.builder_vsn }}
  139. elixir: ${{ inputs.elixir_vsn }}
  140. with_elixir: 'yes'
  141. defaults:
  142. run:
  143. shell: bash
  144. steps:
  145. - uses: actions/checkout@v3
  146. with:
  147. ref: ${{ github.event.inputs.ref }}
  148. fetch-depth: 0
  149. - name: fix workdir
  150. run: |
  151. set -eu
  152. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  153. # Align path for CMake caches
  154. if [ ! "$PWD" = "/emqx" ]; then
  155. ln -s $PWD /emqx
  156. cd /emqx
  157. fi
  158. echo "pwd is $PWD"
  159. - name: build emqx packages
  160. env:
  161. PROFILE: ${{ matrix.profile }}
  162. IS_ELIXIR: ${{ matrix.with_elixir }}
  163. ACLOCAL_PATH: "/usr/share/aclocal:/usr/local/share/aclocal"
  164. run: |
  165. set -eu
  166. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  167. make "${PROFILE}-elixir-tgz"
  168. else
  169. make "${PROFILE}-tgz"
  170. make "${PROFILE}-pkg"
  171. fi
  172. - name: test emqx packages
  173. env:
  174. PROFILE: ${{ matrix.profile }}
  175. IS_ELIXIR: ${{ matrix.with_elixir }}
  176. run: |
  177. set -eu
  178. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  179. ./scripts/pkg-tests.sh "${PROFILE}-elixir-tgz"
  180. else
  181. ./scripts/pkg-tests.sh "${PROFILE}-tgz"
  182. ./scripts/pkg-tests.sh "${PROFILE}-pkg"
  183. fi
  184. - uses: actions/upload-artifact@v3
  185. with:
  186. name: ${{ matrix.profile }}
  187. path: _packages/${{ matrix.profile }}/
  188. retention-days: 7
  189. publish_artifacts:
  190. runs-on: ubuntu-latest
  191. needs:
  192. - mac
  193. - linux
  194. if: inputs.publish == 'true' || inputs.publish
  195. strategy:
  196. fail-fast: false
  197. matrix:
  198. profile:
  199. - ${{ inputs.profile }}
  200. steps:
  201. - uses: actions/download-artifact@v3
  202. with:
  203. name: ${{ matrix.profile }}
  204. path: packages/${{ matrix.profile }}
  205. - name: install dos2unix
  206. run: sudo apt-get update -y && sudo apt install -y dos2unix
  207. - name: get packages
  208. run: |
  209. set -eu
  210. cd packages/${{ matrix.profile }}
  211. # fix the .sha256 file format
  212. for var in $(ls | grep emqx | grep -v sha256); do
  213. dos2unix $var.sha256
  214. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  215. done
  216. cd -
  217. - uses: aws-actions/configure-aws-credentials@v2
  218. with:
  219. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  220. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  221. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  222. - name: upload to aws s3
  223. env:
  224. PROFILE: ${{ matrix.profile }}
  225. run: |
  226. set -eu
  227. if [ $PROFILE = 'emqx' ]; then
  228. s3dir='emqx-ce'
  229. elif [ $PROFILE = 'emqx-enterprise' ]; then
  230. s3dir='emqx-ee'
  231. else
  232. echo "unknown profile $PROFILE"
  233. exit 1
  234. fi
  235. aws s3 cp --recursive packages/$PROFILE s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }}
  236. aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*"