From fa028119c1a3f0815d054dc0f209d04e590b572b Mon Sep 17 00:00:00 2001 From: "alewoj@on.sinch.com" Date: Tue, 23 Apr 2024 08:17:46 +0000 Subject: [PATCH] Auto update iOS XCFramework in CI once new version is released RV-174 --- .gitlab/gitlab-ci.yml | 14 ++++++++++++++ .gitlab/rules.yml | 6 ++++++ scripts/ci_update_android_version.sh | 17 +++++------------ scripts/ci_update_in_pipeline.include.sh | 23 +++++++++++++++++++++++ scripts/ci_update_ios_version.sh | 23 +++++++++++++++++++++++ 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100755 scripts/ci_update_in_pipeline.include.sh create mode 100755 scripts/ci_update_ios_version.sh diff --git a/.gitlab/gitlab-ci.yml b/.gitlab/gitlab-ci.yml index 2104d44..e2aee2b 100644 --- a/.gitlab/gitlab-ci.yml +++ b/.gitlab/gitlab-ci.yml @@ -99,4 +99,18 @@ update:sdk:version:android: job: ${ARTIFACT_JOB_NAME} ref: ${PARENT_REF} artifacts: true + +update:sdk:version:ios: + stage: Update SDK version + extends: + - .conf:rule:ios:update:sdk + tags: + - rtc-mac + script: + - ./scripts/ci_update_ios_version.sh "$SDK_VERSION%2b$SDK_REVISION" + needs: + - project: sinch/sinch-projects/voice/vvc-client-sdk/ios-sdk + job: ${ARTIFACT_JOB_NAME} + ref: ${PARENT_REF} + artifacts: true diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index 3d6de3f..7fd0a90 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -33,3 +33,9 @@ workflow: - if: '$CI_PIPELINE_SOURCE == "pipeline" && $UPDATE_PLATFORM == "android"' when: on_success - when: never + +.conf:rule:ios:update:sdk: + rules: + - if: '$CI_PIPELINE_SOURCE == "pipeline" && $UPDATE_PLATFORM == "ios"' + when: on_success + - when: never diff --git a/scripts/ci_update_android_version.sh b/scripts/ci_update_android_version.sh index f93c609..9baa419 100755 --- a/scripts/ci_update_android_version.sh +++ b/scripts/ci_update_android_version.sh @@ -1,13 +1,14 @@ #!/bin/bash set -euo pipefail -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - if [[ "$#" -ne 2 ]]; then echo "Usage: $0 " exit 1 fi +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPT_DIR}/ci_update_in_pipeline.include.sh" + NEW_VERSION="$1" NEW_REVISION="$2" MAKEFILE="$SCRIPT_DIR/../android/Makefile" @@ -21,15 +22,7 @@ SDK_REVISION=$NEW_REVISION\\ " $MAKEFILE echo "Makefile version updated new version: $NEW_VERSION revision: $NEW_REVISION" -echo "Pushing updated Makefile to master..." - -git config user.name "CI Pipeline" -git config user.email "dev@sinch.com" -git remote add gitlab_origin https://oauth2:$CI_GITLAB_TOKEN@gitlab.com/sinch/sinch-projects/voice/vvc-client-sdk/rtc-vvc-reference-applications.git -git fetch gitlab_origin -git checkout -t gitlab_origin/master -git add ./android/Makefile -git commit -m "Auto update Android SDK to:$NEW_VERSION+$NEW_REVISION" -git push gitlab_origin master -o ci.skip + +push_version_update_to_gitlab "Auto update Android SDK to $NEW_VERSION+$NEW_REVISION" "$MAKEFILE" echo "DONE" diff --git a/scripts/ci_update_in_pipeline.include.sh b/scripts/ci_update_in_pipeline.include.sh new file mode 100755 index 0000000..4442f3e --- /dev/null +++ b/scripts/ci_update_in_pipeline.include.sh @@ -0,0 +1,23 @@ + +function push_version_update_to_gitlab() { + if [ -z "$1" ]; then + echo "No commit message provided. Exiting" + exit 1 + else + echo "Will push changes with commit message: $1" + fi + if [ -z "$2" ]; then + echo "No update file path provided. Exiting" + exit 1 + else + echo "Will commit changes inside file: $2" + fi + git config user.name "CI Pipeline" + git config user.email "dev@sinch.com" + git remote add gitlab_origin https://oauth2:$CI_GITLAB_TOKEN@gitlab.com/sinch/sinch-projects/voice/vvc-client-sdk/rtc-vvc-reference-applications.git + git fetch gitlab_origin + git checkout -t gitlab_origin/master + git add "$2" + git commit -m "$1" + git push gitlab_origin master -o ci.skip +} \ No newline at end of file diff --git a/scripts/ci_update_ios_version.sh b/scripts/ci_update_ios_version.sh new file mode 100755 index 0000000..f4d55d1 --- /dev/null +++ b/scripts/ci_update_ios_version.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -euo pipefail +if [[ "$#" -ne 1 ]]; then + echo "Usage: $0 " + exit 1 +fi + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source "${SCRIPT_DIR}/ci_update_in_pipeline.include.sh" + +NEW_VERSION="$1" +UPDATE_SCRIPT="$SCRIPT_DIR/../ios/SinchReferenceApp/fetch_xcframework_if_needed.sh" + +sed -i '' "/^readonly SDK_VERSION/c\\ +readonly SDK_VERSION=\"$NEW_VERSION\"\\ +" $UPDATE_SCRIPT + +echo "Changed SDK version inside iOS SDK download script to new version: $NEW_VERSION" + +push_version_update_to_gitlab "Auto update iOS SDK to $NEW_VERSION" "$UPDATE_SCRIPT" + +echo "DONE"