build_packages.yaml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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. 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. retention-days: 7
  115. mac:
  116. strategy:
  117. fail-fast: false
  118. matrix:
  119. profile:
  120. - ${{ inputs.profile }}
  121. otp:
  122. - ${{ inputs.otp_vsn }}
  123. os:
  124. - macos-11
  125. - macos-12
  126. - macos-12-arm64
  127. runs-on: ${{ matrix.os }}
  128. steps:
  129. - uses: emqx/self-hosted-cleanup-action@v1.0.3
  130. - uses: actions/checkout@v3
  131. with:
  132. ref: ${{ github.event.inputs.ref }}
  133. fetch-depth: 0
  134. - uses: ./.github/actions/package-macos
  135. with:
  136. profile: ${{ matrix.profile }}
  137. otp: ${{ matrix.otp }}
  138. os: ${{ matrix.os }}
  139. apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
  140. apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
  141. apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
  142. apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
  143. - uses: actions/upload-artifact@v3
  144. if: success()
  145. with:
  146. name: ${{ matrix.profile }}
  147. path: _packages/${{ matrix.profile }}/
  148. retention-days: 7
  149. linux:
  150. runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch }}"]
  151. # always run in builder container because the host might have the wrong OTP version etc.
  152. # otherwise buildx.sh does not run docker if arch and os matches the target arch and os.
  153. container:
  154. image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  155. strategy:
  156. fail-fast: false
  157. matrix:
  158. profile:
  159. - ${{ inputs.profile }}
  160. otp:
  161. - ${{ inputs.otp_vsn }}
  162. arch:
  163. - x64
  164. - arm64
  165. os:
  166. - ubuntu22.04
  167. - ubuntu20.04
  168. - ubuntu18.04
  169. - debian12
  170. - debian11
  171. - debian10
  172. - el9
  173. - el8
  174. - el7
  175. - amzn2
  176. - amzn2023
  177. builder:
  178. - ${{ inputs.builder_vsn }}
  179. elixir:
  180. - ${{ inputs.elixir_vsn }}
  181. with_elixir:
  182. - 'no'
  183. include:
  184. - profile: emqx
  185. otp: ${{ inputs.otp_vsn }}
  186. arch: x64
  187. os: ubuntu22.04
  188. builder: ${{ inputs.builder_vsn }}
  189. elixir: ${{ inputs.elixir_vsn }}
  190. with_elixir: 'yes'
  191. defaults:
  192. run:
  193. shell: bash
  194. steps:
  195. - uses: actions/checkout@v3
  196. with:
  197. ref: ${{ github.event.inputs.ref }}
  198. fetch-depth: 0
  199. - name: fix workdir
  200. run: |
  201. set -eu
  202. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  203. # Align path for CMake caches
  204. if [ ! "$PWD" = "/emqx" ]; then
  205. ln -s $PWD /emqx
  206. cd /emqx
  207. fi
  208. echo "pwd is $PWD"
  209. - name: build emqx packages
  210. env:
  211. PROFILE: ${{ matrix.profile }}
  212. IS_ELIXIR: ${{ matrix.with_elixir }}
  213. ACLOCAL_PATH: "/usr/share/aclocal:/usr/local/share/aclocal"
  214. run: |
  215. set -eu
  216. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  217. make "${PROFILE}-elixir-tgz"
  218. else
  219. make "${PROFILE}-tgz"
  220. make "${PROFILE}-pkg"
  221. fi
  222. - name: test emqx packages
  223. env:
  224. PROFILE: ${{ matrix.profile }}
  225. IS_ELIXIR: ${{ matrix.with_elixir }}
  226. run: |
  227. set -eu
  228. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  229. ./scripts/pkg-tests.sh "${PROFILE}-elixir-tgz"
  230. else
  231. ./scripts/pkg-tests.sh "${PROFILE}-tgz"
  232. ./scripts/pkg-tests.sh "${PROFILE}-pkg"
  233. fi
  234. - uses: actions/upload-artifact@v3
  235. with:
  236. name: ${{ matrix.profile }}
  237. path: _packages/${{ matrix.profile }}/
  238. retention-days: 7
  239. publish_artifacts:
  240. runs-on: ubuntu-latest
  241. needs:
  242. - mac
  243. - linux
  244. if: inputs.publish == 'true' || inputs.publish
  245. strategy:
  246. fail-fast: false
  247. matrix:
  248. profile:
  249. - ${{ inputs.profile }}
  250. steps:
  251. - uses: actions/download-artifact@v3
  252. with:
  253. name: ${{ matrix.profile }}
  254. path: packages/${{ matrix.profile }}
  255. - name: install dos2unix
  256. run: sudo apt-get update -y && sudo apt install -y dos2unix
  257. - name: get packages
  258. run: |
  259. set -eu
  260. cd packages/${{ matrix.profile }}
  261. # fix the .sha256 file format
  262. for var in $(ls | grep emqx | grep -v sha256); do
  263. dos2unix $var.sha256
  264. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  265. done
  266. cd -
  267. - uses: aws-actions/configure-aws-credentials@v2
  268. with:
  269. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  270. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  271. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  272. - name: upload to aws s3
  273. env:
  274. PROFILE: ${{ matrix.profile }}
  275. run: |
  276. set -eu
  277. if [ $PROFILE = 'emqx' ]; then
  278. s3dir='emqx-ce'
  279. elif [ $PROFILE = 'emqx-enterprise' ]; then
  280. s3dir='emqx-ee'
  281. else
  282. echo "unknown profile $PROFILE"
  283. exit 1
  284. fi
  285. aws s3 cp --recursive packages/$PROFILE s3://${{ secrets.AWS_S3_BUCKET }}/$s3dir/${{ github.ref_name }}
  286. aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_CLOUDFRONT_ID }} --paths "/$s3dir/${{ github.ref_name }}/*"