build_packages.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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: string
  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. otp:
  74. - ${{ inputs.otp_vsn }}
  75. os:
  76. - macos-12
  77. - macos-12-arm64
  78. - macos-13
  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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
  95. if: success()
  96. with:
  97. name: ${{ matrix.profile }}
  98. path: _packages/${{ matrix.profile }}/
  99. retention-days: 7
  100. linux:
  101. runs-on: [self-hosted, ephemeral, linux, "${{ matrix.arch }}"]
  102. # always run in builder container because the host might have the wrong OTP version etc.
  103. # otherwise buildx.sh does not run docker if arch and os matches the target arch and os.
  104. container:
  105. image: "ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}"
  106. strategy:
  107. fail-fast: false
  108. matrix:
  109. profile:
  110. - ${{ inputs.profile }}
  111. otp:
  112. - ${{ inputs.otp_vsn }}
  113. arch:
  114. - x64
  115. - arm64
  116. os:
  117. - ubuntu22.04
  118. - ubuntu20.04
  119. - ubuntu18.04
  120. - debian12
  121. - debian11
  122. - debian10
  123. - el9
  124. - el8
  125. - el7
  126. - amzn2
  127. - amzn2023
  128. builder:
  129. - ${{ inputs.builder_vsn }}
  130. elixir:
  131. - ${{ inputs.elixir_vsn }}
  132. with_elixir:
  133. - 'no'
  134. include:
  135. - profile: ${{ inputs.profile }}
  136. otp: ${{ inputs.otp_vsn }}
  137. arch: x64
  138. os: ubuntu22.04
  139. builder: ${{ inputs.builder_vsn }}
  140. elixir: ${{ inputs.elixir_vsn }}
  141. with_elixir: 'yes'
  142. defaults:
  143. run:
  144. shell: bash
  145. steps:
  146. - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
  147. with:
  148. ref: ${{ github.event.inputs.ref }}
  149. fetch-depth: 0
  150. - name: fix workdir
  151. run: |
  152. set -eu
  153. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  154. # Align path for CMake caches
  155. if [ ! "$PWD" = "/emqx" ]; then
  156. ln -s $PWD /emqx
  157. cd /emqx
  158. fi
  159. echo "pwd is $PWD"
  160. - name: build emqx packages
  161. env:
  162. PROFILE: ${{ matrix.profile }}
  163. IS_ELIXIR: ${{ matrix.with_elixir }}
  164. ACLOCAL_PATH: "/usr/share/aclocal:/usr/local/share/aclocal"
  165. run: |
  166. set -eu
  167. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  168. make "${PROFILE}-elixir-tgz"
  169. else
  170. make "${PROFILE}-tgz"
  171. make "${PROFILE}-pkg"
  172. fi
  173. - name: test emqx packages
  174. env:
  175. PROFILE: ${{ matrix.profile }}
  176. IS_ELIXIR: ${{ matrix.with_elixir }}
  177. run: |
  178. set -eu
  179. if [ "${IS_ELIXIR:-}" == 'yes' ]; then
  180. ./scripts/pkg-tests.sh "${PROFILE}-elixir-tgz"
  181. else
  182. ./scripts/pkg-tests.sh "${PROFILE}-tgz"
  183. ./scripts/pkg-tests.sh "${PROFILE}-pkg"
  184. fi
  185. - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
  186. with:
  187. name: ${{ matrix.profile }}
  188. path: _packages/${{ matrix.profile }}/
  189. retention-days: 7
  190. publish_artifacts:
  191. runs-on: ubuntu-latest
  192. needs:
  193. - mac
  194. - linux
  195. if: inputs.publish == 'true' || inputs.publish
  196. strategy:
  197. fail-fast: false
  198. matrix:
  199. profile:
  200. - ${{ inputs.profile }}
  201. steps:
  202. - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
  203. with:
  204. name: ${{ matrix.profile }}
  205. path: packages/${{ matrix.profile }}
  206. - name: install dos2unix
  207. run: sudo apt-get update -y && sudo apt install -y dos2unix
  208. - name: get packages
  209. run: |
  210. set -eu
  211. cd packages/${{ matrix.profile }}
  212. # fix the .sha256 file format
  213. for var in $(ls | grep emqx | grep -v sha256); do
  214. dos2unix $var.sha256
  215. echo "$(cat $var.sha256) $var" | sha256sum -c || exit 1
  216. done
  217. cd -
  218. - uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
  219. with:
  220. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  221. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  222. aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
  223. - name: upload to aws s3
  224. env:
  225. PROFILE: ${{ matrix.profile }}
  226. REF_NAME: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref_name }}
  227. AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
  228. AWS_CLOUDFRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID }}
  229. run: |
  230. set -eu
  231. if [ $PROFILE = 'emqx' ]; then
  232. s3dir='emqx-ce'
  233. elif [ $PROFILE = 'emqx-enterprise' ]; then
  234. s3dir='emqx-ee'
  235. else
  236. echo "unknown profile $PROFILE"
  237. exit 1
  238. fi
  239. aws s3 cp --recursive packages/$PROFILE s3://$AWS_S3_BUCKET/$s3dir/$REF_NAME
  240. aws cloudfront create-invalidation --distribution-id "$AWS_CLOUDFRONT_ID" --paths "/$s3dir/$REF_NAME/*"