-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
fail-fast: false | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: ./ | ||
id: setup_sdk | ||
with: | ||
cache: false | ||
- name: Test clang is installed | ||
run: "${OHOS_SDK_NATIVE}/llvm/bin/clang" --version | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# OHOS SDK | ||
|
||
This is a simple GitHub action to automatically download and install the OpenHarmony SDK, | ||
so you can use it in your GitHub actions workflow. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: 'Setup OpenHarmony SDK' | ||
description: 'Download an install the OpenHarmony SDK' | ||
inputs: | ||
version: | ||
description: 'OpenHarmony SDK release version' | ||
required: false | ||
default: '4.1' | ||
cache: | ||
description: "Whether to cache the SDK or not" | ||
required: false | ||
default: true | ||
outputs: | ||
sdk-path: | ||
description: "Directory of the OpenHarmony SDK" | ||
value: ${{ steps.set_outputs.outputs.sdk-path }} | ||
ohos_sdk_native: | ||
description: "The `native` directory inside the OpenHarmony SDK" | ||
value: ${{ steps.set_outputs.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 }} | ||
api-version: | ||
description: "OpenHarmony API version of the SDK" | ||
api-version: ${{ steps.set_outputs.outputs.api-version }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set Greeting | ||
run: echo "Hello ${{ inputs.version }}." | ||
shell: bash | ||
- name: Cache SDK | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: ohos-sdk | ||
key: ${{ runner.os }}-ohos-sdk-${{ inputs.version }} | ||
if: ${{ inputs.cache }} == 'true' | ||
- name: Download and install OpenHarmony SDK | ||
id: install_ohos_sdk | ||
run: ./install_ohos_sdk.sh | ||
shell: bash | ||
if: ${{ inputs.cache }} != 'true' || steps.cache.outputs.cache-hit != 'true' | ||
env: | ||
INPUT_VERSION: "${{ inputs.version }}" | ||
- name: Set Outputs | ||
id: set_outputs | ||
shell: bash | ||
run: | | ||
echo "sdk-path=$HOME/ohos-sdk" >> "$GITHUB_OUTPUT" | ||
OHOS_SDK_NATIVE="$HOME/ohos-sdk/*/native" | ||
echo "OHOS_SDK_NATIVE=${OHOS_SDK_NATIVE}" >> "$GITHUB_ENV" | ||
echo "ohos_sdk_native=${OHOS_SDK_NATIVE}" >> "$GITHUB_OUTPUT" | ||
cd "${OHOS_SDK_NATIVE}" | ||
SDK_VERSION="$(jq .version < oh-uni-package.json )" | ||
API_VERSION="$(jq .apiVersion < oh-uni-package.json )" | ||
echo "sdk-version=${SDK_VERSION}" >> "$GITHUB_OUTPUT" | ||
echo "api-version=${API_VERSION}" >> "$GITHUB_OUTPUT" | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
: "${INPUT_VERSION:?INPUT_VERSION needs to be set}" | ||
|
||
# https://repo.huaweicloud.com/openharmony/os/4.0-Release/ohos-sdk-windows_linux-public.tar.gz | ||
|
||
URL_BASE="https://repo.huaweicloud.com/openharmony/os" | ||
|
||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
OS_FILENAME="ohos-sdk-windows_linux-public.tar.gz" | ||
OS=linux | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
if [[ $(uname -m) == 'arm64' ]]; then | ||
OS_FILENAME="L2-SDK-MAC-M1-PUBLIC.tar.gz" | ||
else | ||
OS_FILENAME="ohos-sdk-mac-public.tar.gz" | ||
fi | ||
OS=mac | ||
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then | ||
OS_FILENAME="ohos-sdk-windows_linux-public.tar.gz" | ||
OS=windows | ||
else | ||
echo "Unknown OS type. The OHOS SDK is only available for Windows, Linux and Mqd." | ||
fi | ||
|
||
DOWNLOAD_URL="${URL_BASE}/${INPUT_VERSION}-Release/${OS_FILENAME}" | ||
|
||
echo "Downloading OHOS SDK from ${DOWNLOAD_URL}" | ||
|
||
curl --fail -L -o "${HOME}/openharmony-sdk.tar.gz" "${DOWNLOAD_URL}" | ||
cd "${HOME}" | ||
if [[ "${OS}" == "linux" ]]; then | ||
tar -xvf openharmony-sdk.tar.gz --strip-components=2 | ||
else | ||
tar -xvf openharmony-sdk.tar.gz | ||
fi | ||
rm openharmony-sdk.tar.gz | ||
cd ohos-sdk | ||
|
||
if [[ "${OS}" == "linux" ]]; then | ||
rm -rf windows | ||
cd linux | ||
elif [[ "${OS}" == "windows" ]]; then | ||
rm -rf linux | ||
cd windows | ||
else | ||
cd darwin | ||
fi | ||
|
||
# Todo: expose available components via an input variable. | ||
# For now just extract native, to save disk space | ||
|
||
unzip native-*.zip | ||
rm ./*.zip | ||
|
||
cd native |