From 36906d83724c11da480b4026b1253be8251d128a Mon Sep 17 00:00:00 2001 From: Littlegnal <8847263+littleGnAl@users.noreply.github.com> Date: Thu, 6 Jun 2024 17:41:37 +0800 Subject: [PATCH] [ci][code-gen.yaml] Support modify version in tool/terra/terra_config_main.yaml (#1818) --- .github/workflows/code-gen.yaml | 2 +- scripts/code_gen.sh | 4 ++-- tool/terra/build.sh | 27 +++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-gen.yaml b/.github/workflows/code-gen.yaml index e8858f1fc..9a7549c2a 100644 --- a/.github/workflows/code-gen.yaml +++ b/.github/workflows/code-gen.yaml @@ -42,7 +42,7 @@ jobs: channel: 'stable' - name: Run code-gen run: | - bash scripts/code_gen.sh + bash scripts/code_gen.sh ${{ inputs.version }} - name: Get current date id: date diff --git a/scripts/code_gen.sh b/scripts/code_gen.sh index 993a31074..b1d4ebdb3 100644 --- a/scripts/code_gen.sh +++ b/scripts/code_gen.sh @@ -2,14 +2,14 @@ set -e set -x -TERRA_PATH=$1 +RTC_VERSION=$1 MY_PATH=$(realpath $(dirname "$0")) PROJECT_ROOT=$(realpath ${MY_PATH}/..) pushd ${PROJECT_ROOT} flutter packages get -bash ${PROJECT_ROOT}/tool/terra/build.sh ${TERRA_PATH} +bash ${PROJECT_ROOT}/tool/terra/build.sh ${RTC_VERSION} bash ${MY_PATH}/flutter-build-runner.sh bash ${PROJECT_ROOT}/tool/testcase_gen/build.sh diff --git a/tool/terra/build.sh b/tool/terra/build.sh index 8acb61af0..bb1c376cd 100644 --- a/tool/terra/build.sh +++ b/tool/terra/build.sh @@ -2,13 +2,36 @@ set -e set -x +NEW_VERSION=$1 MY_PATH=$(realpath $(dirname "$0")) PROJECT_ROOT=$(realpath ${MY_PATH}/../..) +TERRA_MAIN_FILE=${PROJECT_ROOT}/tool/terra/terra_config_main.yaml + +if [ -n "$NEW_VERSION" ]; then + # Check the operating system type + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + sed -i '' -E "s/rtc_[0-9]+\.[0-9]+\.[0-9]+/${NEW_VERSION}/g" $TERRA_MAIN_FILE + else + # Linux and other Unix-like systems + sed -i -E "s/rtc_[0-9]+\.[0-9]+\.[0-9]+/${NEW_VERSION}/g" $TERRA_MAIN_FILE + fi + echo "Updated version to ${NEW_VERSION} in $TERRA_MAIN_FILE" +fi + +bash ${MY_PATH}/prepare.sh + pushd ${MY_PATH} npm exec terra -- run \ - --config ${PROJECT_ROOT}/tool/terra/terra_config_main.yaml \ - --output-dir=${PROJECT_ROOT}/lib/src + --config ${TERRA_MAIN_FILE} \ + --output-dir=${PROJECT_ROOT} + +popd + +pushd ${PROJECT_ROOT} + +dart format . popd \ No newline at end of file