Skip to content

Commit

Permalink
Prepare v0.2 for OH 5.0.1 support
Browse files Browse the repository at this point in the history
To add OH 5.0.1 to the SDK mirror, we need to make
a breaking change, otherwise users specifying
5.0 would get auto-updated to 5.0.1, which is a
newer API version and would thus likely break
them.

Signed-off-by: Jonathan Schwender <[email protected]>
  • Loading branch information
jschwe committed Nov 29, 2024
1 parent a75b74e commit 7b885ce
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
version: [ "4.0", "4.1", "5.0"]
version: [ "4.0", "4.1", "5.0.0"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v0.2 (2024-11-29)

- Bumped the default SDK version to 5.0.0
- Do not attempt to resolve SDK versions anymore when downloading from the mirror.
Instead of '5.0' Users should now specify the exact version '5.0.0', since
'5.0.1' is already API-level 13.
- Updated the documentation to use '5.0.0' where appropriate.

# v0.1.4 (2024-10-08)

- Fixed a bug introduced in v0.1.3, which caused the action to not set output variables,
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ jobs:
**inputs**:
| Name | Type | Default | Description |
|------------|---------|---------|----------------------------------------------------------------------------------------------------------------------------|
| version | String | 4.1 | Version of the OpenHarmony SDK (e.g. `4.0`, `4.1` or `5.0`) |
| cache | Boolean | true | Uses the GitHub actions cache to cache the SDK when enabled. |
| components | String | all | SDK components that should be added. `all` or semicolon seperated list of components. |
| mirror | Boolean | true | Download from Github Releases mirror of the SDK if possible. |
| Name | Type | Default | Description |
|------------|---------|---------|---------------------------------------------------------------------------------------|
| version | String | 5.0.0 | Version of the OpenHarmony SDK (e.g. `4.0`, `4.1`, `5.0.0` or `5.0.1`) |
| cache | Boolean | true | Uses the GitHub actions cache to cache the SDK when enabled. |
| components | String | all | SDK components that should be added. `all` or semicolon seperated list of components. |
| mirror | Boolean | true | Download from Github Releases mirror of the SDK if possible. |

**outputs**:


| Name | Type | Description |
|-----------------|--------|--------------------------------------------------------|
| api-version | String | API Version of the SDK (e.g. `12` for OpenHarmony 5.0) |
| sdk-version | String | Specific SDK version (e.g. `4.1.7.5`) |
| ohos_sdk_native | String | Path to the `native` directory in the OpenHarmony SDK. |
| Name | Type | Description |
|-----------------|--------|-----------------------------------------------------------------------------------------|
| api-version | String | API Version of the SDK (e.g. `12` for OpenHarmony 5.0.0, or `13` for OpenHarmony 5.0.1) |
| sdk-version | String | Specific SDK version (e.g. `4.1.7.5`) |
| ohos_sdk_native | String | Path to the `native` directory in the OpenHarmony SDK. |
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
version:
description: 'OpenHarmony SDK release version'
required: false
default: '4.1'
default: '5.0.0'
cache:
description: "Whether to cache the SDK or not"
required: false
Expand Down
26 changes: 0 additions & 26 deletions install_ohos_sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,6 @@ WORK_DIR="${HOME}/setup-ohos-sdk"
mkdir -p "${WORK_DIR}"
cd "${WORK_DIR}"

# RESOLVED_MIRROR_VERSION_TAG is both in- and output of this function.
# If the user provides a version like `5.0`, we try to resolve the version to something more specific like `5.0.0`,
# since we can't easily have aliasing releases on Github. (e.g. 5.0 pointing to the latest 5.0.x release)
function select_version() {
local base_tag_version="${RESOLVED_MIRROR_VERSION_TAG}"
local available_releases
local exact_version_res
local latest_compatible_version
available_releases=$(gh release list --repo openharmony-rs/ohos-sdk --json 'tagName')
# Note: jq doesn't seem to return an error if select doesn't find anything
exact_version_res=$(jq ".[] | select(.tagName == \"${base_tag_version}\")" <<< "${available_releases}")
if [[ -n "${exact_version_res}" ]]; then
# If we found an exactly matching release, then we don't need to do anything.
return 0
fi
# Otherwise, get the first (== latest) release matching the start of our version tag (e.g. `5.0.3` for input `5.0`)
latest_compatible_version=$(jq "[.[] | select(.tagName | startswith(\"${base_tag_version}.\"))][0].tagName" <<< "${available_releases}" | tr -d '"')
if [[ -n "${latest_compatible_version}" ]]; then
echo "Resolved version ${base_tag_version} to release ${latest_compatible_version}"
RESOLVED_MIRROR_VERSION_TAG="${latest_compatible_version}"
else
echo "Couldn't find any compatible release on the mirror."
fi
}

# Assumption: cwd contains the zipped components.
# Outputs: API_VERSION
function extract_sdk_components() {
Expand Down Expand Up @@ -99,7 +74,6 @@ function download_and_extract_sdk() {
MIRROR_DOWNLOAD_SUCCESS=false
if [[ "${INPUT_MIRROR}" == "true" || "${INPUT_MIRROR}" == "force" ]]; then
RESOLVED_MIRROR_VERSION_TAG="v${INPUT_VERSION}"
select_version # This will update RESOLVED_MIRROR_VERSION_TAG.
gh release download "${RESOLVED_MIRROR_VERSION_TAG}" --pattern "${OS_FILENAME}*" --repo openharmony-rs/ohos-sdk && MIRROR_DOWNLOAD_SUCCESS=true
if [[ "${MIRROR_DOWNLOAD_SUCCESS}" == "true" ]]; then
# The mirror may have split the archives due to the Github releases size limits.
Expand Down

0 comments on commit 7b885ce

Please sign in to comment.