build_packages.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. runner:
  21. required: true
  22. type: string
  23. builder_vsn:
  24. required: true
  25. type: string
  26. secrets:
  27. AWS_ACCESS_KEY_ID:
  28. required: true
  29. AWS_SECRET_ACCESS_KEY:
  30. required: true
  31. AWS_DEFAULT_REGION:
  32. required: true
  33. AWS_S3_BUCKET:
  34. required: true
  35. AWS_CLOUDFRONT_ID:
  36. required: true
  37. APPLE_ID_PASSWORD:
  38. required: true
  39. APPLE_DEVELOPER_IDENTITY:
  40. required: true
  41. APPLE_DEVELOPER_ID_BUNDLE:
  42. required: true
  43. APPLE_DEVELOPER_ID_BUNDLE_PASSWORD:
  44. required: true
  45. workflow_dispatch:
  46. inputs:
  47. ref:
  48. required: false
  49. profile:
  50. required: false
  51. publish:
  52. required: false
  53. type: boolean
  54. default: false
  55. otp_vsn:
  56. required: false
  57. type: string
  58. default: '25.3.2-2'
  59. elixir_vsn:
  60. required: false
  61. type: string
  62. default: '1.14.5'
  63. runner:
  64. required: false
  65. type: string
  66. default: 'ubuntu-22.04'
  67. builder_vsn:
  68. required: false
  69. type: string
  70. default: '5.1-4'
  71. jobs:
  72. windows:
  73. runs-on: windows-2019
  74. if: inputs.profile == 'emqx'
  75. strategy:
  76. fail-fast: false
  77. matrix:
  78. profile: # for now only CE for windows
  79. - emqx
  80. steps:
  81. - uses: actions/checkout@v3
  82. with:
  83. ref: ${{ github.event.inputs.ref }}
  84. fetch-depth: 0
  85. - uses: ilammy/msvc-dev-cmd@v1.12.0
  86. - uses: erlef/setup-beam@v1.16.0
  87. with:
  88. otp-version: 25.3.2
  89. - name: build
  90. env:
  91. PYTHON: python
  92. DIAGNOSTIC: 1
  93. run: |
  94. # ensure crypto app (openssl)
  95. erl -eval "erlang:display(crypto:info_lib())" -s init stop
  96. make ${{ matrix.profile }}-tgz
  97. - name: run emqx
  98. timeout-minutes: 5
  99. run: |
  100. $ErrorActionPreference = "Stop"
  101. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx start
  102. Start-Sleep -s 10
  103. $pingOutput = ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx ping
  104. if ($pingOutput = 'pong') {
  105. echo "EMQX started OK"
  106. } else {
  107. echo "Failed to ping EMQX $pingOutput"
  108. Exit 1
  109. }
  110. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx stop
  111. echo "EMQX stopped"
  112. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx install
  113. echo "EMQX installed"
  114. ./_build/${{ matrix.profile }}/rel/emqx/bin/emqx uninstall
  115. echo "EMQX uninstalled"
  116. - uses: actions/upload-artifact@v3
  117. if: success()
  118. with:
  119. name: ${{ matrix.profile }}
  120. path: _packages/${{ matrix.profile }}/
  121. mac:
  122. strategy:
  123. fail-fast: false
  124. matrix:
  125. profile:
  126. - ${{ inputs.profile }}
  127. otp:
  128. - ${{ inputs.otp_vsn }}
  129. os:
  130. - macos-11
  131. - macos-12
  132. - macos-12-arm64
  133. runs-on: ${{ matrix.os }}
  134. steps:
  135. - uses: emqx/self-hosted-cleanup-action@v1.0.3
  136. - uses: actions/checkout@v3
  137. with:
  138. ref: ${{ github.event.inputs.ref }}
  139. fetch-depth: 0
  140. - uses: ./.github/actions/package-macos
  141. with:
  142. profile: ${{ matrix.profile }}
  143. otp: ${{ matrix.otp }}
  144. os: ${{ matrix.os }}
  145. apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
  146. apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
  147. apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
  148. apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
  149. - uses: actions/upload-artifact@v3
  150. if: success()
  151. with:
  152. name: ${{ matrix.profile }}
  153. path: _packages/${{ matrix.profile }}/
  154. linux:
  155. runs-on: ${{ matrix.build_machine }}
  156. # always run in builder container because the host might have the wrong OTP version etc.
  157. # otherwise buildx.sh does not run docker if arch and os matches the target arch and os.
  158. container:
  159. image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  160. strategy:
  161. fail-fast: false
  162. matrix:
  163. profile:
  164. - ${{ inputs.profile }}
  165. otp:
  166. - ${{ inputs.otp_vsn }}
  167. arch:
  168. - amd64
  169. - arm64
  170. os:
  171. - ubuntu22.04
  172. - ubuntu20.04
  173. - ubuntu18.04
  174. - debian12
  175. - debian11
  176. - debian10
  177. - el9
  178. - el8
  179. - el7
  180. - amzn2
  181. - amzn2023
  182. build_machine:
  183. - aws-arm64
  184. - aws-amd64
  185. builder:
  186. - ${{ inputs.builder_vsn }}
  187. elixir:
  188. - ${{ inputs.elixir_vsn }}
  189. with_elixir:
  190. - 'no'
  191. exclude:
  192. - arch: arm64
  193. build_machine: aws-amd64
  194. - arch: amd64
  195. build_machine: aws-arm64
  196. include:
  197. - profile: emqx
  198. otp: ${{ inputs.otp_vsn }}
  199. arch: amd64
  200. os: ubuntu22.04
  201. build_machine: aws-amd64
  202. builder: ${{ inputs.builder_vsn }}
  203. elixir: ${{ inputs.elixir_vsn }}
  204. with_elixir: 'yes'
  205. defaults:
  206. run:
  207. shell: bash
  208. steps:
  209. - uses: AutoModality/action-clean@v1
  210. - uses: actions/checkout@v3
  211. with:
  212. ref: ${{ github.event.inputs.ref }}
  213. fetch-depth: 0
  214. - name: fix workdir
  215. run: |
  216. set -eu
  217. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  218. # Align path for CMake caches
  219. if [ ! "$PWD" = "/emqx" ]; then
  220. ln -s $PWD /emqx
  221. cd /emqx
  222. fi
  223. echo "pwd is $PWD"
  224. - name: build emqx packages
  225. env:
  226. PROFILE: ${{ matrix.profile }}
  227. IS_ELIXIR: ${{ matrix.with_elixir }}
  228. ACLOCAL_PATH: "/usr/share/aclocal:/usr/local/share/aclocal"
  229. run: |
  230. set -eu
  231. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  232. make "${PROFILE}-elixir-tgz"
  233. else
  234. make "${PROFILE}-tgz"
  235. make "${PROFILE}-pkg"
  236. fi
  237. - name: test emqx packages
  238. env:
  239. PROFILE: ${{ matrix.profile }}
  240. IS_ELIXIR: ${{ matrix.with_elixir }}
  241. run: |
  242. set -eu
  243. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  244. ./scripts/pkg-tests.sh "${PROFILE}-elixir-tgz"
  245. else
  246. ./scripts/pkg-tests.sh "${PROFILE}-tgz"
  247. ./scripts/pkg-tests.sh "${PROFILE}-pkg"
  248. fi
  249. - uses: actions/upload-artifact@v3
  250. with:
  251. name: ${{ matrix.profile }}
  252. path: _packages/${{ matrix.profile }}/
  253. publish_artifacts:
  254. runs-on: ubuntu-latest
  255. needs:
  256. - mac
  257. - linux
  258. if: inputs.publish == 'true' || inputs.publish
  259. strategy:
  260. fail-fast: false
  261. matrix:
  262. profile:
  263. - ${{ inputs.profile }}
  264. steps:
  265. - uses: actions/download-artifact@v3
  266. with:
  267. name: ${{ matrix.profile }}
  268. path: packages/${{ matrix.profile }}
  269. - name: install dos2unix
  270. run: sudo apt-get update && sudo apt install -y dos2unix
  271. - name: get packages
  272. run: |
  273. set -eu
  274. cd packages/${{ matrix.profile }}
  275. # fix the .sha256 file format
  276. for var in $(ls | grep emqx | grep -v sha256); do
  277. dos2unix $var.sha256
  278. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  279. done
  280. cd -
  281. - uses: aws-actions/configure-aws-credentials@v2
  282. with:
  283. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  284. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  285. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  286. - name: upload to aws s3
  287. env:
  288. PROFILE: ${{ matrix.profile }}
  289. run: |
  290. set -eu
  291. if [ $PROFILE = 'emqx' ]; then
  292. s3dir='emqx-ce'
  293. elif [ $PROFILE = 'emqx-enterprise' ]; then
  294. s3dir='emqx-ee'
  295. else
  296. echo "unknown profile $PROFILE"
  297. exit 1
  298. fi
  299. aws s3 cp --recursive packages/$PROFILE s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }}
  300. aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*"