action.yaml 5.2 KB

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