build_packages.yaml 7.9 KB

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