action.yaml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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
  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
  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. export CFLAGS="-O2 -g -I$(brew --prefix unixodbc)/include"
  83. export LDFLAGS="-L$(brew --prefix unixodbc)/lib"
  84. WITH_ODBC="--with-odbc=$(brew --prefix unixodbc)"
  85. else
  86. WITH_ODBC=""
  87. fi
  88. ./configure --disable-dynamic-ssl-lib --with-ssl=$(brew --prefix openssl@1.1) ${WITH_ODBC} --disable-hipe --disable-jit --prefix="$OTP_INSTALL_PATH"
  89. make -j$(nproc)
  90. rm -rf "$OTP_INSTALL_PATH"
  91. make install
  92. if [ "$(arch)" = arm64 ]; then
  93. unset CFLAGS
  94. unset LDFLAGS
  95. fi
  96. - name: build
  97. env:
  98. HOMEBREW_NO_AUTO_UPDATE: 1
  99. HOMEBREW_NO_INSTALL_UPGRADE: 1
  100. HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
  101. AUTO_INSTALL_BUILD_DEPS: 1
  102. APPLE_SIGN_BINARIES: 1
  103. APPLE_ID: developers@emqx.io
  104. APPLE_TEAM_ID: 26N6HYJLZA
  105. APPLE_ID_PASSWORD: ${{ inputs.apple_id_password }}
  106. APPLE_DEVELOPER_IDENTITY: ${{ inputs.apple_developer_identity }}
  107. APPLE_DEVELOPER_ID_BUNDLE: ${{ inputs.apple_developer_id_bundle }}
  108. APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ inputs.apple_developer_id_bundle_password }}
  109. shell: bash
  110. run: |
  111. export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
  112. # inspec erl in PATH
  113. which erl
  114. # inspec erl command banner
  115. erl -s init stop
  116. make ensure-rebar3
  117. mkdir -p $HOME/bin
  118. cp rebar3 $HOME/bin/rebar3
  119. export PATH="$HOME/bin:$PATH"
  120. make ${{ inputs.profile }}-tgz
  121. - name: test ${{ inputs.profile }}
  122. shell: bash
  123. run: |
  124. export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
  125. pkg_name=$(find _packages/${{ inputs.profile }} -mindepth 1 -maxdepth 1 -iname \*.zip)
  126. mkdir emqx
  127. unzip -d emqx $pkg_name > /dev/null
  128. # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins
  129. ./emqx/bin/emqx start || cat emqx/log/erlang.log.1
  130. ready='no'
  131. for i in {1..30}; do
  132. if curl -fs 127.0.0.1:18083/status > /dev/null; then
  133. ready='yes'
  134. break
  135. fi
  136. sleep 1
  137. done
  138. if [ "$ready" != "yes" ]; then
  139. echo "Timed out waiting for emqx to be ready"
  140. cat emqx/log/erlang.log.1
  141. exit 1
  142. fi
  143. ./emqx/bin/emqx_ctl status
  144. ./emqx/bin/emqx stop
  145. rm -rf emqx