build_packages.yaml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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.5-3'
  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-9'
  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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  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@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
  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. - debian12
  112. - debian11
  113. - debian10
  114. - el9
  115. - el8
  116. - amzn2
  117. - amzn2023
  118. arch:
  119. - amd64
  120. - arm64
  121. with_elixir:
  122. - 'no'
  123. otp:
  124. - ${{ inputs.otp_vsn }}
  125. builder:
  126. - ${{ inputs.builder_vsn }}
  127. elixir:
  128. - ${{ inputs.elixir_vsn }}
  129. include:
  130. - profile: ${{ inputs.profile }}
  131. os: ubuntu22.04
  132. arch: amd64
  133. with_elixir: 'yes'
  134. otp: ${{ inputs.otp_vsn }}
  135. builder: ${{ inputs.builder_vsn }}
  136. elixir: ${{ inputs.elixir_vsn }}
  137. defaults:
  138. run:
  139. shell: bash
  140. steps:
  141. - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
  142. with:
  143. ref: ${{ github.event.inputs.ref }}
  144. fetch-depth: 0
  145. - name: build tgz
  146. env:
  147. PROFILE: ${{ matrix.profile }}
  148. ARCH: ${{ matrix.arch }}
  149. OS: ${{ matrix.os }}
  150. IS_ELIXIR: ${{ matrix.with_elixir }}
  151. BUILDER: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  152. BUILDER_SYSTEM: force_docker
  153. run: |
  154. ./scripts/buildx.sh \
  155. --profile $PROFILE \
  156. --arch $ARCH \
  157. --builder $BUILDER \
  158. --elixir $IS_ELIXIR \
  159. --pkgtype tgz
  160. - name: build pkg
  161. if: matrix.with_elixir == 'no'
  162. env:
  163. PROFILE: ${{ matrix.profile }}
  164. ARCH: ${{ matrix.arch }}
  165. OS: ${{ matrix.os }}
  166. IS_ELIXIR: ${{ matrix.with_elixir }}
  167. BUILDER: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  168. BUILDER_SYSTEM: force_docker
  169. run: |
  170. ./scripts/buildx.sh \
  171. --profile $PROFILE \
  172. --arch $ARCH \
  173. --builder $BUILDER \
  174. --elixir $IS_ELIXIR \
  175. --pkgtype pkg
  176. - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
  177. with:
  178. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.with_elixir == 'yes' && '-elixir' || '' }}-${{ matrix.builder }}-${{ matrix.otp }}-${{ matrix.elixir }}
  179. path: _packages/${{ matrix.profile }}/
  180. retention-days: 7
  181. publish_artifacts:
  182. runs-on: ubuntu-latest
  183. needs:
  184. - mac
  185. - linux
  186. if: inputs.publish
  187. strategy:
  188. fail-fast: false
  189. matrix:
  190. profile:
  191. - ${{ inputs.profile }}
  192. steps:
  193. - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
  194. with:
  195. pattern: "${{ matrix.profile }}-*"
  196. path: packages/${{ matrix.profile }}
  197. merge-multiple: true
  198. - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
  199. with:
  200. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  201. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  202. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  203. - name: upload to aws s3
  204. env:
  205. PROFILE: ${{ matrix.profile }}
  206. REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
  207. AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
  208. AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
  209. run: |
  210. set -eu
  211. if [ $PROFILE = 'emqx' ]; then
  212. s3dir='emqx-ce'
  213. elif [ $PROFILE = 'emqx-enterprise' ]; then
  214. s3dir='emqx-ee'
  215. else
  216. echo "unknown profile $PROFILE"
  217. exit 1
  218. fi
  219. aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME
  220. aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*"