Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor github outputs into install script #10

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ jobs:
API_VERSION: "${{ steps.sdk-with-fixup.outputs.api-version }}"
run: |
${SDK_PATH}/*/${API_VERSION}/native/llvm/bin/clang --version


build_result:
name: Result
runs-on: ubuntu-latest
needs: ["build"]
if: ${{ always() }}
steps:
- name: Mark the job as successful
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
run: exit 0
- name: Mark the job as unsuccessful
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1
32 changes: 5 additions & 27 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ inputs:
outputs:
sdk-path:
description: "Root directory of the OpenHarmony SDK installation"
value: ${{ steps.set_outputs.outputs.sdk-path }}
value: ${{ steps.install_ohos_sdk.outputs.sdk-path }}
ohos_sdk_native:
description: "The `native` directory inside the OpenHarmony SDK"
value: ${{ steps.set_outputs.outputs.ohos_sdk_native }}
value: ${{ steps.install_ohos_sdk.outputs.ohos_sdk_native }}
sdk-version:
description: "Specific version of the OpenHarmony SDK (e.g. 4.1.7.5)"
value: ${{ steps.set_outputs.outputs.sdk-version }}
value: ${{ steps.install_ohos_sdk.outputs.sdk-version }}
api-version:
description: "OpenHarmony API version of the SDK"
value: ${{ steps.set_outputs.outputs.api-version }}
value: ${{ steps.install_ohos_sdk.outputs.api-version }}
ohos-base-sdk-home:
description: "Path to the OpenHarmony SDK for the host platform"
value: ${{ steps.set_outputs.outputs.ohos-base-sdk-home }}
value: ${{ steps.install_ohos_sdk.outputs.ohos-base-sdk-home }}
runs:
using: "composite"
steps:
Expand Down 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"

24 changes: 23 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,15 +83,34 @@ else
cd darwin
fi

OHOS_BASE_SDK_HOME="$PWD"

IFS=";" read -ra COMPONENTS <<< "${INPUT_COMPONENTS}"
for COMPONENT in "${COMPONENTS[@]}"
do
echo "Extracting component ${COMPONENT}"
echo "::group::Unzipping archive"
unzip "${COMPONENT}"-*.zip
echo "::endgroup::"
API_VERSION=$(cat "${COMPONENT}/oh-uni-package.json" | jq -r '.apiVersion')
if [ "$INPUT_FIXUP_PATH" = "true" ]; then
mkdir -p "${API_VERSION}"
mv "${COMPONENT}" "${API_VERSION}/"
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"