diff --git a/ci_resources/Dockerfile.android b/ci_resources/Dockerfile.android index 25edb6a0ec..f54bfd51ad 100644 --- a/ci_resources/Dockerfile.android +++ b/ci_resources/Dockerfile.android @@ -17,6 +17,7 @@ RUN apt-get update && apt-get install -y \ ruby \ ruby-dev \ build-essential \ + jq \ && locale-gen en_US.UTF-8 \ && update-locale LANG=en_US.UTF-8 \ && apt-get clean diff --git a/ci_resources/upload_aab_to_huawei_app_gallery.sh b/ci_resources/upload_aab_to_huawei_app_gallery.sh new file mode 100755 index 0000000000..653433461e --- /dev/null +++ b/ci_resources/upload_aab_to_huawei_app_gallery.sh @@ -0,0 +1,134 @@ +#!/bin/bash + +set -eo pipefail + +# ---------------------------------------- +# 1. Obtain OAuth access token +# ---------------------------------------- +# Sending a POST request to retrieve access token using client credentials +TOKEN=$(curl -s -v -X POST "https://connect-api.cloud.huawei.com/api/oauth2/v1/token" \ + -H "Content-Type: application/json" \ + -d "{ + \"grant_type\": \"client_credentials\", + \"client_id\": \"$CLIENT_ID\", + \"client_secret\": \"$CLIENT_SECRET\" + }" | jq -r .access_token) + +echo "------------------------------------------------" +echo "[INFO] Token = $TOKEN" +echo "------------------------------------------------" + +# ---------------------------------------- +# 2. Get upload information (temporary URL + required headers) +# ---------------------------------------- +# Extract file name and size for the upload request +echo "[INFO] File path = $FILE_PATH" +FILE_NAME=$(basename "$FILE_PATH") +echo "[INFO] File name = $FILE_NAME" +CONTENT_LENGTH=$(stat -c %s "$FILE_PATH") +echo "[INFO] Content length = $CONTENT_LENGTH" + +# Request upload URL and headers for OBS (Huawei Object Storage Service) +UPLOAD_INFO=$(curl -s -v -X GET \ + "https://connect-api.cloud.huawei.com/api/publish/v2/upload-url/for-obs?appId=$APP_ID&fileName=$FILE_NAME&contentLength=$CONTENT_LENGTH" \ + -H "Authorization: Bearer $TOKEN" \ + -H "client_id: $CLIENT_ID" \ + -H "Content-Type: application/json") + +echo "------------------------------------------------" +echo "[INFO] Upload: $UPLOAD_INFO" +echo "------------------------------------------------" + +# ---------------------------------------- +# 3. Upload the AAB file to Huawei OBS using signed URL and headers +# ---------------------------------------- +# Parse the response to get upload URL and required headers +UPLOAD_URL=$(echo "$UPLOAD_INFO" | jq -r '.urlInfo.url') +HEADERS=$(echo "$UPLOAD_INFO" | jq -r '.urlInfo.headers') + +echo "------------------------------------------------" +echo "[INFO] Parsed upload URL: $UPLOAD_URL" +echo "[INFO] Extracting headers..." +echo "------------------------------------------------" + +# Extract individual headers for the PUT request +AUTH_HEADER=$(echo "$HEADERS" | jq -r '."Authorization"') +SHA256_HEADER=$(echo "$HEADERS" | jq -r '."x-amz-content-sha256"') +DATE_HEADER=$(echo "$HEADERS" | jq -r '."x-amz-date"') +HOST_HEADER=$(echo "$HEADERS" | jq -r '."Host"') +UA_HEADER=$(echo "$HEADERS" | jq -r '."user-agent"') +CT_HEADER=$(echo "$HEADERS" | jq -r '."Content-Type"') + +# Log headers (for debug purposes) +echo "[INFO] Authorization: $AUTH_HEADER" +echo "[INFO] x-amz-content-sha256: $SHA256_HEADER" +echo "[INFO] x-amz-date: $DATE_HEADER" +echo "[INFO] Host: $HOST_HEADER" +echo "[INFO] user-agent: $UA_HEADER" +echo "[INFO] Content-Type: $CT_HEADER" +echo "------------------------------------------------" + +# Perform the actual file upload using the signed PUT URL +echo "[INFO] Uploading file '$FILE_PATH' to Huawei OBS..." +RESPONSE=$(curl -v -X PUT "$UPLOAD_URL" \ + -H "Authorization: $AUTH_HEADER" \ + -H "x-amz-content-sha256: $SHA256_HEADER" \ + -H "x-amz-date: $DATE_HEADER" \ + -H "Host: $HOST_HEADER" \ + -H "user-agent: $UA_HEADER" \ + -H "Content-Type: $CT_HEADER" \ + --data-binary @"$FILE_PATH" 2>&1) + +echo "$RESPONSE" +echo "------------------------------------------------" + +# Check if upload succeeded +if echo "$RESPONSE" | grep -q "HTTP/1.1 200"; then + echo "[SUCCESS] File upload completed successfully." +else + echo "[ERROR] File upload failed:" + echo "$RESPONSE" + exit 1 +fi + +# ---------------------------------------- +# 4. Commit the uploaded file to AppGallery (register the uploaded file) +# ---------------------------------------- +# Huawei requires an additional API call to register the uploaded file to the app +echo "[INFO] Committing uploaded AAB file to AppGallery..." + +# Extract path (excluding hostname) from the upload URL +FILE_DEST_URL=$(echo "$UPLOAD_URL" | sed -E 's|https://[^/]+/||') + +# Prepare commit payload +COMMIT_PAYLOAD=$(cat < /dev/null; then + echo "[SUCCESS] File committed successfully and is now visible in AppGallery Console." +else + echo "[ERROR] Failed to commit file:" + echo "$COMMIT_RESPONSE" + exit 1 +fi diff --git a/gradle.properties b/gradle.properties index a312f8c1a2..0e6c69b832 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs = -Xmx6144m -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +org.gradle.jvmargs = -Xmx6144m -XX:MaxMetaspaceSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects