build_packages.yaml 8.1 KB

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