action.yaml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. name: 'Create MacOS package'
  2. description: 'Build MacOS package for emqx or emqx-enterprise'
  3. inputs:
  4. profile: # emqx, emqx-enterprise
  5. required: true
  6. type: string
  7. otp:
  8. required: true
  9. type: string
  10. os:
  11. required: false
  12. type: string
  13. default: macos-11
  14. apple_id_password:
  15. required: true
  16. type: string
  17. apple_developer_identity:
  18. required: true
  19. type: string
  20. apple_developer_id_bundle:
  21. required: true
  22. type: string
  23. apple_developer_id_bundle_password:
  24. required: true
  25. type: string
  26. runs:
  27. using: composite
  28. steps:
  29. - id: prepare
  30. shell: bash
  31. env:
  32. HOMEBREW_NO_AUTO_UPDATE: 1
  33. HOMEBREW_NO_INSTALL_UPGRADE: 1
  34. HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
  35. run: |
  36. brew install curl zip unzip coreutils openssl@1.1 unixodbc
  37. echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
  38. echo "/usr/local/bin" >> $GITHUB_PATH
  39. echo "emqx_name=${emqx_name}" >> $GITHUB_OUTPUT
  40. OTP_SOURCE_PATH="$HOME/src/otp-${{ inputs.otp }}"
  41. OTP_INSTALL_PATH="$HOME/otp/${{ inputs.otp }}"
  42. echo "OTP_SOURCE_PATH=$OTP_SOURCE_PATH" >> $GITHUB_OUTPUT
  43. echo "OTP_INSTALL_PATH=$OTP_INSTALL_PATH" >> $GITHUB_OUTPUT
  44. mkdir -p "$OTP_SOURCE_PATH" "$OTP_INSTALL_PATH"
  45. # we need this to skip using cache for self-hosted runners
  46. case ${{ inputs.os }} in
  47. *arm64)
  48. echo "SELF_HOSTED=true" >> $GITHUB_OUTPUT
  49. ;;
  50. *)
  51. echo "SELF_HOSTED=false" >> $GITHUB_OUTPUT
  52. ;;
  53. esac
  54. - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
  55. id: cache
  56. if: steps.prepare.outputs.SELF_HOSTED != 'true'
  57. with:
  58. path: ${{ steps.prepare.outputs.OTP_INSTALL_PATH }}
  59. key: otp-install-${{ inputs.otp }}-${{ inputs.os }}-static-ssl-disable-hipe-disable-jit-20240524-1
  60. - name: build erlang
  61. if: steps.cache.outputs.cache-hit != 'true'
  62. shell: bash
  63. run: |
  64. OTP_SOURCE_PATH="${{ steps.prepare.outputs.OTP_SOURCE_PATH }}"
  65. OTP_INSTALL_PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}"
  66. SELF_HOSTED="${{ steps.prepare.outputs.SELF_HOSTED }}"
  67. # when it's self-hosted, it never hits the cache,
  68. # skip rebuild if it's self-hosted and the install path already has a 'bin'
  69. if [ "${SELF_HOSTED:-false}" = 'true' ]; then
  70. if [ -n "$OTP_INSTALL_PATH" ] && [ -d "$OTP_INSTALL_PATH/bin" ]; then
  71. echo "Skip rebuilding OTP, found $OTP_INSTALL_PATH"
  72. exit 0
  73. fi
  74. fi
  75. ## when it's not self-hosted, or the install path is not found,
  76. ## build otp from source code.
  77. if [ -d "$OTP_SOURCE_PATH" ]; then
  78. rm -rf "$OTP_SOURCE_PATH"
  79. fi
  80. git clone --depth 1 --branch OTP-${{ inputs.otp }} https://github.com/emqx/otp.git "$OTP_SOURCE_PATH"
  81. cd "$OTP_SOURCE_PATH"
  82. if [ "$(arch)" = arm64 ]; then
  83. ODBCHOME="$(brew --prefix unixodbc)"
  84. export CFLAGS="-O2 -g -I${ODBCHOME}/include"
  85. export LDFLAGS="-L${ODBCHOME}/lib"
  86. WITH_ODBC="--with-odbc=${ODBCHOME}"
  87. else
  88. WITH_ODBC=""
  89. fi
  90. ./configure --disable-dynamic-ssl-lib --with-ssl=$(brew --prefix openssl@1.1) ${WITH_ODBC} --disable-hipe --disable-jit --prefix="$OTP_INSTALL_PATH"
  91. make -j$(nproc)
  92. rm -rf "$OTP_INSTALL_PATH"
  93. make install
  94. if [ "$(arch)" = arm64 ]; then
  95. unset CFLAGS
  96. unset LDFLAGS
  97. fi
  98. - name: build
  99. env:
  100. HOMEBREW_NO_AUTO_UPDATE: 1
  101. HOMEBREW_NO_INSTALL_UPGRADE: 1
  102. HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
  103. AUTO_INSTALL_BUILD_DEPS: 1
  104. APPLE_SIGN_BINARIES: 1
  105. APPLE_ID: developers@emqx.io
  106. APPLE_TEAM_ID: 26N6HYJLZA
  107. APPLE_ID_PASSWORD: ${{ inputs.apple_id_password }}
  108. APPLE_DEVELOPER_IDENTITY: ${{ inputs.apple_developer_identity }}
  109. APPLE_DEVELOPER_ID_BUNDLE: ${{ inputs.apple_developer_id_bundle }}
  110. APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ inputs.apple_developer_id_bundle_password }}
  111. shell: bash
  112. run: |
  113. export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
  114. # inspec erl in PATH
  115. which erl
  116. # inspec erl command banner
  117. erl -s init stop
  118. make ensure-rebar3
  119. mkdir -p $HOME/bin
  120. cp rebar3 $HOME/bin/rebar3
  121. export PATH="$HOME/bin:$PATH"
  122. make ${{ inputs.profile }}-tgz
  123. - name: test ${{ inputs.profile }}
  124. shell: bash
  125. run: |
  126. export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
  127. pkg_name=$(find _packages/${{ inputs.profile }} -mindepth 1 -maxdepth 1 -iname \*.zip)
  128. mkdir emqx
  129. unzip -d emqx $pkg_name > /dev/null
  130. # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
  131. ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
  132. ready='no'
  133. for i in {1..30}; do
  134. if curl -fs 127.0.0.1:18083/status > /dev/null; then
  135. ready='yes'
  136. break
  137. fi
  138. sleep 1
  139. done
  140. if [ "$ready" != "yes" ]; then
  141. echo "Timed out waiting for emqx to be ready"
  142. cat emqx/log/erlang.log.1
  143. exit 1
  144. fi
  145. ./emqx/bin/emqx_ctl status
  146. ./emqx/bin/emqx stop
  147. rm -rf emqx