Skip to content

Commit

Permalink
Auto update iOS XCFramework in CI once new version is released
Browse files Browse the repository at this point in the history
RV-174
  • Loading branch information
olllo123 committed Apr 23, 2024
1 parent a8f1ca3 commit fa02811
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 12 deletions.
14 changes: 14 additions & 0 deletions .gitlab/gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

6 changes: 6 additions & 0 deletions .gitlab/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 5 additions & 12 deletions scripts/ci_update_android_version.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash

set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [[ "$#" -ne 2 ]]; then
echo "Usage: $0 <SDK_VERSION> <SDK_REVISION>"
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"
Expand All @@ -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 "[email protected]"
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"
23 changes: 23 additions & 0 deletions scripts/ci_update_in_pipeline.include.sh
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
}
23 changes: 23 additions & 0 deletions scripts/ci_update_ios_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -euo pipefail
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 <SDK_VERSION_FULL>"
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"

0 comments on commit fa02811

Please sign in to comment.