name: 'Create MacOS package' inputs: profile: # emqx, emqx-enterprise required: true type: string otp: required: true type: string os: required: false type: string default: macos-11 apple_id_password: required: true type: string apple_developer_identity: required: true type: string apple_developer_id_bundle: required: true type: string apple_developer_id_bundle_password: required: true type: string runs: using: composite steps: - id: prepare shell: bash env: HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_UPGRADE: 1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 run: | brew install curl zip unzip coreutils openssl@1.1 echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH echo "/usr/local/bin" >> $GITHUB_PATH echo "emqx_name=${emqx_name}" >> $GITHUB_OUTPUT OTP_SOURCE_PATH="$HOME/src/otp-${{ inputs.otp }}" OTP_INSTALL_PATH="$HOME/otp/${{ inputs.otp }}" echo "OTP_SOURCE_PATH=$OTP_SOURCE_PATH" >> $GITHUB_OUTPUT echo "OTP_INSTALL_PATH=$OTP_INSTALL_PATH" >> $GITHUB_OUTPUT mkdir -p "$OTP_SOURCE_PATH" "$OTP_INSTALL_PATH" # we need this to skip using cache for self-hosted runners case ${{ inputs.os }} in *arm64) echo "SELF_HOSTED=true" >> $GITHUB_OUTPUT ;; *) echo "SELF_HOSTED=false" >> $GITHUB_OUTPUT ;; esac - uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 id: cache if: steps.prepare.outputs.SELF_HOSTED != 'true' with: path: ${{ steps.prepare.outputs.OTP_INSTALL_PATH }} key: otp-install-${{ inputs.otp }}-${{ inputs.os }}-static-ssl-disable-hipe-disable-jit - name: build erlang if: steps.cache.outputs.cache-hit != 'true' shell: bash run: | OTP_SOURCE_PATH="${{ steps.prepare.outputs.OTP_SOURCE_PATH }}" OTP_INSTALL_PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}" SELF_HOSTED="${{ steps.prepare.outputs.SELF_HOSTED }}" # when it's self-hosted, it never hits the cache, # skip rebuild if it's self-hosted and the install path already has a 'bin' if [ "${SELF_HOSTED:-false}" = 'true' ]; then if [ -n "$OTP_INSTALL_PATH" ] && [ -d "$OTP_INSTALL_PATH/bin" ]; then echo "Skip rebuilding OTP, found $OTP_INSTALL_PATH" exit 0 fi fi ## when it's not self-hosted, or the install path is not found, ## build otp from source code. if [ -d "$OTP_SOURCE_PATH" ]; then rm -rf "$OTP_SOURCE_PATH" fi git clone --depth 1 --branch OTP-${{ inputs.otp }} https://github.com/emqx/otp.git "$OTP_SOURCE_PATH" cd "$OTP_SOURCE_PATH" if [ "$(arch)" = arm64 ]; then export CFLAGS="-O2 -g -I$(brew --prefix unixodbc)/include" export LDFLAGS="-L$(brew --prefix unixodbc)/lib" WITH_ODBC="--with-odbc=$(brew --prefix unixodbc)" else WITH_ODBC="" fi ./configure --disable-dynamic-ssl-lib --with-ssl=$(brew --prefix openssl@1.1) ${WITH_ODBC} --disable-hipe --disable-jit --prefix="$OTP_INSTALL_PATH" make -j$(nproc) rm -rf "$OTP_INSTALL_PATH" make install if [ "$(arch)" = arm64 ]; then unset CFLAGS unset LDFLAGS fi - name: build env: HOMEBREW_NO_AUTO_UPDATE: 1 HOMEBREW_NO_INSTALL_UPGRADE: 1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 AUTO_INSTALL_BUILD_DEPS: 1 APPLE_SIGN_BINARIES: 1 APPLE_ID: developers@emqx.io APPLE_TEAM_ID: 26N6HYJLZA APPLE_ID_PASSWORD: ${{ inputs.apple_id_password }} APPLE_DEVELOPER_IDENTITY: ${{ inputs.apple_developer_identity }} APPLE_DEVELOPER_ID_BUNDLE: ${{ inputs.apple_developer_id_bundle }} APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ inputs.apple_developer_id_bundle_password }} shell: bash run: | export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH" # inspec erl in PATH which erl # inspec erl command banner erl -s init stop make ensure-rebar3 mkdir -p $HOME/bin cp rebar3 $HOME/bin/rebar3 export PATH="$HOME/bin:$PATH" make ${{ inputs.profile }}-tgz - name: test ${{ inputs.profile }} shell: bash run: | export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH" pkg_name=$(find _packages/${{ inputs.profile }} -mindepth 1 -maxdepth 1 -iname \*.zip) mkdir emqx unzip -d emqx $pkg_name > /dev/null # gsed -i '/emqx_telemetry/d' ./emqx/data/loaded_plugins ./emqx/bin/emqx start || cat emqx/log/erlang.log.1 ready='no' for i in {1..30}; do if curl -fs 127.0.0.1:18083/status > /dev/null; then ready='yes' break fi sleep 1 done if [ "$ready" != "yes" ]; then echo "Timed out waiting for emqx to be ready" cat emqx/log/erlang.log.1 exit 1 fi ./emqx/bin/emqx_ctl status ./emqx/bin/emqx stop rm -rf emqx