build_packages.yaml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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: boolean
  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: true
  48. default: 'emqx'
  49. publish:
  50. required: false
  51. type: boolean
  52. default: false
  53. otp_vsn:
  54. required: false
  55. type: string
  56. default: '26.2.1-2'
  57. elixir_vsn:
  58. required: false
  59. type: string
  60. default: '1.15.7'
  61. builder_vsn:
  62. required: false
  63. type: string
  64. default: '5.3-5'
  65. permissions:
  66. contents: read
  67. jobs:
  68. mac:
  69. strategy:
  70. fail-fast: false
  71. matrix:
  72. profile:
  73. - ${{ inputs.profile }}
  74. os:
  75. - macos-13
  76. - macos-14
  77. otp:
  78. - ${{ inputs.otp_vsn }}
  79. runs-on: ${{ matrix.os }}
  80. steps:
  81. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  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@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  95. if: success()
  96. with:
  97. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.otp }}
  98. path: _packages/${{ matrix.profile }}/
  99. retention-days: 7
  100. linux:
  101. runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch == 'arm64' && 'arm64' || 'x64' }}"]
  102. strategy:
  103. fail-fast: false
  104. matrix:
  105. profile:
  106. - ${{ inputs.profile }}
  107. os:
  108. - ubuntu24.04
  109. - ubuntu22.04
  110. - ubuntu20.04
  111. - ubuntu18.04
  112. - debian12
  113. - debian11
  114. - debian10
  115. - el9
  116. - el8
  117. - el7
  118. - amzn2
  119. - amzn2023
  120. arch:
  121. - amd64
  122. - arm64
  123. with_elixir:
  124. - 'no'
  125. otp:
  126. - ${{ inputs.otp_vsn }}
  127. builder:
  128. - ${{ inputs.builder_vsn }}
  129. elixir:
  130. - ${{ inputs.elixir_vsn }}
  131. include:
  132. - profile: ${{ inputs.profile }}
  133. os: ubuntu22.04
  134. arch: amd64
  135. with_elixir: 'yes'
  136. otp: ${{ inputs.otp_vsn }}
  137. builder: ${{ inputs.builder_vsn }}
  138. elixir: ${{ inputs.elixir_vsn }}
  139. defaults:
  140. run:
  141. shell: bash
  142. steps:
  143. - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
  144. with:
  145. ref: ${{ github.event.inputs.ref }}
  146. fetch-depth: 0
  147. - name: build tgz
  148. env:
  149. PROFILE: ${{ matrix.profile }}
  150. ARCH: ${{ matrix.arch }}
  151. OS: ${{ matrix.os }}
  152. IS_ELIXIR: ${{ matrix.with_elixir }}
  153. BUILDER: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  154. BUILDER_SYSTEM: force_docker
  155. run: |
  156. ./scripts/buildx.sh \
  157. --profile $PROFILE \
  158. --arch $ARCH \
  159. --builder $BUILDER \
  160. --elixir $IS_ELIXIR \
  161. --pkgtype tgz
  162. - name: build pkg
  163. if: matrix.with_elixir == 'no'
  164. env:
  165. PROFILE: ${{ matrix.profile }}
  166. ARCH: ${{ matrix.arch }}
  167. OS: ${{ matrix.os }}
  168. IS_ELIXIR: ${{ matrix.with_elixir }}
  169. BUILDER: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  170. BUILDER_SYSTEM: force_docker
  171. run: |
  172. ./scripts/buildx.sh \
  173. --profile $PROFILE \
  174. --arch $ARCH \
  175. --builder $BUILDER \
  176. --elixir $IS_ELIXIR \
  177. --pkgtype pkg
  178. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  179. with:
  180. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.with_elixir == 'yes' && '-elixir' || '' }}-${{ matrix.builder }}-${{ matrix.otp }}-${{ matrix.elixir }}
  181. path: _packages/${{ matrix.profile }}/
  182. retention-days: 7
  183. publish_artifacts:
  184. runs-on: ubuntu-latest
  185. needs:
  186. - mac
  187. - linux
  188. if: inputs.publish
  189. strategy:
  190. fail-fast: false
  191. matrix:
  192. profile:
  193. - ${{ inputs.profile }}
  194. steps:
  195. - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
  196. with:
  197. pattern: "${{ matrix.profile }}-*"
  198. path: packages/${{ matrix.profile }}
  199. merge-multiple: true
  200. - name: install dos2unix
  201. run: sudo apt-get update -y && sudo apt install -y dos2unix
  202. - name: get packages
  203. run: |
  204. set -eu
  205. cd packages/${{ matrix.profile }}
  206. # fix the .sha256 file format
  207. for f in *.sha256; do
  208. dos2unix $f
  209. echo "$(cat $f) ${f%.*}" | sha256sum -c || exit 1
  210. done
  211. cd -
  212. - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
  213. with:
  214. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  215. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  216. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  217. - name: upload to aws s3
  218. env:
  219. PROFILE: ${{ matrix.profile }}
  220. REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
  221. AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
  222. AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
  223. run: |
  224. set -eu
  225. if [ $PROFILE = 'emqx' ]; then
  226. s3dir='emqx-ce'
  227. elif [ $PROFILE = 'emqx-enterprise' ]; then
  228. s3dir='emqx-ee'
  229. else
  230. echo "unknown profile $PROFILE"
  231. exit 1
  232. fi
  233. aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME
  234. aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*"