build_packages.yaml 7.0 KB

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