ci: define otp source and install path in one place

This commit is contained in:
Ivan Dyachkov 2022-11-22 11:01:12 +01:00
parent 262e53eed2
commit d0d99378b4
1 changed files with 12 additions and 7 deletions

View File

@ -26,25 +26,30 @@ inputs:
runs: runs:
using: composite using: composite
steps: steps:
- name: prepare - id: prepare
shell: bash shell: bash
run: | run: |
brew update brew update
brew install curl zip unzip coreutils openssl@1.1 brew install curl zip unzip coreutils openssl@1.1
mkdir -p $HOME/src $HOME/otp
echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH echo "/usr/local/opt/bison/bin" >> $GITHUB_PATH
echo "/usr/local/bin" >> $GITHUB_PATH echo "/usr/local/bin" >> $GITHUB_PATH
echo "OTP_SOURCE_PATH=$HOME/src/otp-${{ inputs.otp }}" >> $GITHUB_ENV echo "emqx_name=${emqx_name}" >> $GITHUB_OUTPUT
echo "OTP_INSTALL_PATH=$HOME/otp/${{ inputs.otp }}" >> $GITHUB_ENV 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"
- uses: actions/cache@v3 - uses: actions/cache@v3
id: cache id: cache
with: with:
path: $HOME/otp/${{ inputs.otp }} path: ${{ steps.prepare.outputs.OTP_INSTALL_PATH }}
key: otp-install-${{ inputs.otp }}-${{ inputs.os }}-static-ssl-disable-hipe-disable-jit key: otp-install-${{ inputs.otp }}-${{ inputs.os }}-static-ssl-disable-hipe-disable-jit
- name: build erlang - name: build erlang
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
shell: bash shell: bash
run: | run: |
OTP_SOURCE_PATH="${{ steps.prepare.outputs.OTP_SOURCE_PATH }}"
OTP_INSTALL_PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}"
if [ -d "$OTP_SOURCE_PATH" ]; then if [ -d "$OTP_SOURCE_PATH" ]; then
rm -rf "$OTP_SOURCE_PATH" rm -rf "$OTP_SOURCE_PATH"
fi fi
@ -66,7 +71,7 @@ runs:
APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ inputs.apple_developer_id_bundle_password }} APPLE_DEVELOPER_ID_BUNDLE_PASSWORD: ${{ inputs.apple_developer_id_bundle_password }}
shell: bash shell: bash
run: | run: |
export PATH="$OTP_INSTALL_PATH/bin:$PATH" export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
make ensure-rebar3 make ensure-rebar3
mkdir -p $HOME/bin mkdir -p $HOME/bin
cp rebar3 $HOME/bin/rebar3 cp rebar3 $HOME/bin/rebar3
@ -75,7 +80,7 @@ runs:
- name: test ${{ inputs.profile }} - name: test ${{ inputs.profile }}
shell: bash shell: bash
run: | run: |
export PATH="$OTP_INSTALL_PATH/bin:$PATH" export PATH="${{ steps.prepare.outputs.OTP_INSTALL_PATH }}/bin:$PATH"
pkg_name=$(find _packages/${{ inputs.profile }} -mindepth 1 -maxdepth 1 -iname \*.zip) pkg_name=$(find _packages/${{ inputs.profile }} -mindepth 1 -maxdepth 1 -iname \*.zip)
mkdir emqx mkdir emqx
unzip -d emqx $pkg_name > /dev/null unzip -d emqx $pkg_name > /dev/null