build_packages.yaml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: 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. os:
  74. - macos-12
  75. - macos-12-arm64
  76. - macos-13
  77. otp:
  78. - ${{ inputs.otp_vsn }}
  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@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. - ubuntu22.04
  109. - ubuntu20.04
  110. - ubuntu18.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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  143. with:
  144. ref: ${{ github.event.inputs.ref }}
  145. fetch-depth: 0
  146. - name: build emqx packages
  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 pkg
  161. - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
  162. with:
  163. name: ${{ matrix.profile }}-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.with_elixir == 'yes' && '-elixir' || '' }}-${{ matrix.builder }}-${{ matrix.otp }}-${{ matrix.elixir }}
  164. path: _packages/${{ matrix.profile }}/
  165. retention-days: 7
  166. publish_artifacts:
  167. runs-on: ubuntu-latest
  168. needs:
  169. - mac
  170. - linux
  171. if: inputs.publish
  172. strategy:
  173. fail-fast: false
  174. matrix:
  175. profile:
  176. - ${{ inputs.profile }}
  177. steps:
  178. - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2
  179. with:
  180. pattern: "${{ matrix.profile }}-*"
  181. path: packages/${{ matrix.profile }}
  182. merge-multiple: true
  183. - name: install dos2unix
  184. run: sudo apt-get update -y && sudo apt install -y dos2unix
  185. - name: get packages
  186. run: |
  187. set -eu
  188. cd packages/${{ matrix.profile }}
  189. # fix the .sha256 file format
  190. for var in $(ls | grep emqx | grep -v sha256); do
  191. dos2unix $var.sha256
  192. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  193. done
  194. cd -
  195. - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
  196. with:
  197. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  198. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  199. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  200. - name: upload to aws s3
  201. env:
  202. PROFILE: ${{ matrix.profile }}
  203. REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
  204. AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
  205. AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
  206. run: |
  207. set -eu
  208. if [ $PROFILE = 'emqx' ]; then
  209. s3dir='emqx-ce'
  210. elif [ $PROFILE = 'emqx-enterprise' ]; then
  211. s3dir='emqx-ee'
  212. else
  213. echo "unknown profile $PROFILE"
  214. exit 1
  215. fi
  216. aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME
  217. aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*"