build_packages.yaml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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-2'
  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-12
  76. - macos-12-arm64
  77. - macos-13
  78. otp:
  79. - ${{ inputs.otp_vsn }}
  80. runs-on: ${{ matrix.os }}
  81. steps:
  82. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  83. with:
  84. ref: ${{ github.event.inputs.ref }}
  85. fetch-depth: 0
  86. - uses: ./.github/actions/package-macos
  87. with:
  88. profile: ${{ matrix.profile }}
  89. otp: ${{ matrix.otp }}
  90. os: ${{ matrix.os }}
  91. apple_id_password: ${{ secrets.APPLE_ID_PASSWORD }}
  92. apple_developer_identity: ${{ secrets.APPLE_DEVELOPER_IDENTITY }}
  93. apple_developer_id_bundle: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE }}
  94. apple_developer_id_bundle_password: ${{ secrets.APPLE_DEVELOPER_ID_BUNDLE_PASSWORD }}
  95. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  96. if: success()
  97. with:
  98. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.otp }}
  99. path: _packages/${{ matrix.profile }}/
  100. retention-days: 7
  101. linux:
  102. runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch == 'arm64' && 'arm64' || 'x64' }}"]
  103. strategy:
  104. fail-fast: false
  105. matrix:
  106. profile:
  107. - ${{ inputs.profile }}
  108. os:
  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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  144. with:
  145. ref: ${{ github.event.inputs.ref }}
  146. fetch-depth: 0
  147. - name: build emqx packages
  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 pkg
  162. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  163. with:
  164. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.with_elixir == 'yes' && '-elixir' || '' }}-${{ matrix.builder }}-${{ matrix.otp }}-${{ matrix.elixir }}
  165. path: _packages/${{ matrix.profile }}/
  166. retention-days: 7
  167. publish_artifacts:
  168. runs-on: ubuntu-latest
  169. needs:
  170. - mac
  171. - linux
  172. if: inputs.publish
  173. strategy:
  174. fail-fast: false
  175. matrix:
  176. profile:
  177. - ${{ inputs.profile }}
  178. steps:
  179. - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
  180. with:
  181. pattern: "${{ matrix.profile }}-*"
  182. path: packages/${{ matrix.profile }}
  183. merge-multiple: true
  184. - name: install dos2unix
  185. run: sudo apt-get update -y && sudo apt install -y dos2unix
  186. - name: get packages
  187. run: |
  188. set -eu
  189. cd packages/${{ matrix.profile }}
  190. # fix the .sha256 file format
  191. for f in *.sha256; do
  192. dos2unix $f
  193. echo "$(cat $f) ${f%.*}" | sha256sum -c || exit 1
  194. done
  195. cd -
  196. - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
  197. with:
  198. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  199. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  200. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  201. - name: upload to aws s3
  202. env:
  203. PROFILE: ${{ matrix.profile }}
  204. REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
  205. AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
  206. AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
  207. run: |
  208. set -eu
  209. if [ $PROFILE = 'emqx' ]; then
  210. s3dir='emqx-ce'
  211. elif [ $PROFILE = 'emqx-enterprise' ]; then
  212. s3dir='emqx-ee'
  213. else
  214. echo "unknown profile $PROFILE"
  215. exit 1
  216. fi
  217. aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME
  218. aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*"