build_packages.yaml 6.6 KB

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