Skip to content

Commit

Permalink
Refactor github outputs into install script
Browse files Browse the repository at this point in the history
This allows removing some globbing in favor of the
respective variables.

Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Oct 6, 2024
1 parent 15a618d commit d6aa7ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
22 changes: 0 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,4 @@ runs:
INPUT_FIXUP_PATH: ${{ inputs.fixup-path }}
INPUT_MIRROR: "${{ inputs.mirror }}"
GH_TOKEN: "${{ github.token }}"
- name: Set Outputs
id: set_outputs
shell: bash
env:
INPUT_FIXUP_PATH: ${{ inputs.fixup-path }}
run: |
echo "sdk-path=$HOME/ohos-sdk" >> "$GITHUB_OUTPUT"
OHOS_BASE_SDK_HOME=$(cd $HOME/ohos-sdk/*/ && pwd)
if [ "${INPUT_FIXUP_PATH}" = "true" ]; then
OHOS_SDK_NATIVE="$(cd $HOME/ohos-sdk/*/*/native && pwd)"
else
OHOS_SDK_NATIVE="$(cd $HOME/ohos-sdk/*/native && pwd)"
fi
cd "${OHOS_SDK_NATIVE}"
SDK_VERSION="$(jq -r .version < oh-uni-package.json )"
API_VERSION="$(jq -r .apiVersion < oh-uni-package.json )"
echo "OHOS_BASE_SDK_HOME=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_ENV"
echo "ohos-base-sdk-home=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_OUTPUT"
echo "OHOS_SDK_NATIVE=${OHOS_SDK_NATIVE}" >> "$GITHUB_ENV"
echo "ohos_sdk_native=${OHOS_SDK_NATIVE}" >> "$GITHUB_OUTPUT"
echo "sdk-version=${SDK_VERSION}" >> "$GITHUB_OUTPUT"
echo "api-version=${API_VERSION}" >> "$GITHUB_OUTPUT"

22 changes: 21 additions & 1 deletion install_ohos_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ else
exit 1
fi

cd "${HOME}"
WORK_DIR="${HOME}/setup-ohos-sdk"
mkdir -p "${WORK_DIR}"
cd "${WORK_DIR}"

MIRROR_DOWNLOAD_SUCCESS=false
if [[ "${INPUT_MIRROR}" == "true" || "${INPUT_MIRROR}" == "force" ]]; then
Expand Down Expand Up @@ -69,6 +71,7 @@ else
fi
rm "${OS_FILENAME}" "${OS_FILENAME}.sha256"
cd ohos-sdk
echo "sdk-path=$PWD" >> "$GITHUB_OUTPUT"

if [[ "${OS}" == "linux" ]]; then
rm -rf windows
Expand All @@ -80,6 +83,8 @@ else
cd darwin
fi

OHOS_BASE_SDK_HOME="$PWD"

IFS=";" read -ra COMPONENTS <<< "${INPUT_COMPONENTS}"
for COMPONENT in "${COMPONENTS[@]}"
do
Expand All @@ -92,3 +97,18 @@ do
fi
done
rm ./*.zip

if [ "${INPUT_FIXUP_PATH}" = "true" ]; then
OHOS_SDK_NATIVE="${OHOS_BASE_SDK_HOME}/${API_VERSION}/native"
else
OHOS_SDK_NATIVE="${OHOS_BASE_SDK_HOME}/native"
fi
cd "${OHOS_SDK_NATIVE}"
SDK_VERSION="$(jq -r .version < oh-uni-package.json )"
API_VERSION="$(jq -r .apiVersion < oh-uni-package.json )"
echo "OHOS_BASE_SDK_HOME=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_ENV"
echo "ohos-base-sdk-home=${OHOS_BASE_SDK_HOME}" >> "$GITHUB_OUTPUT"
echo "OHOS_SDK_NATIVE=${OHOS_SDK_NATIVE}" >> "$GITHUB_ENV"
echo "ohos_sdk_native=${OHOS_SDK_NATIVE}" >> "$GITHUB_OUTPUT"
echo "sdk-version=${SDK_VERSION}" >> "$GITHUB_OUTPUT"
echo "api-version=${API_VERSION}" >> "$GITHUB_OUTPUT"

0 comments on commit d6aa7ce

Please sign in to comment.