From b99a4a99d44f99dbcc928a6dcf80b1986eb735ab Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 9 May 2025 17:52:58 +0800 Subject: [PATCH 01/23] =?UTF-8?q?fix:=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85c78d24..45dfc905 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 星锁APP -fix:测试ci + 星云项目组旗下的智能锁应用,其中锁相关数据接入星云平台,业务数据接入星锁自有后台。 基于Flutter技术架构,支持Android和iOS平台。 From c7cc02c045e947e0c2b32d4adcc36d7ca6dd9ab9 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 9 May 2025 18:21:04 +0800 Subject: [PATCH 02/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BFtag=E5=88=A4=E6=96=AD=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 17a01616..b884f3a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ variables: - if: $CI_COMMIT_BRANCH == "release_sky" - if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/ - if: $CI_COMMIT_BRANCH == "canary_release" - - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^(sky_)?v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/ .notify_rule: tags: From 2f9328bd335889eb511929dc9906147cd61bed12 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 9 May 2025 18:28:32 +0800 Subject: [PATCH 03/23] =?UTF-8?q?fix:=E6=B5=8B=E8=AF=95ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45dfc905..85c78d24 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 星锁APP - +fix:测试ci 星云项目组旗下的智能锁应用,其中锁相关数据接入星云平台,业务数据接入星锁自有后台。 基于Flutter技术架构,支持Android和iOS平台。 From 7d4e2574040094cd1bfbe08a91e95831ab1fcb2f Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 17:06:49 +0800 Subject: [PATCH 04/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=BC=80=E5=85=B3?= =?UTF-8?q?=E9=9D=99=E9=9F=B3=E6=97=B6=E4=BD=BF=E7=94=A8=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=9A=84=E6=B8=85=E6=99=B0=E5=BA=A6=E4=BD=9C=E4=B8=BA=E6=9C=9F?= =?UTF-8?q?=E6=9C=9B=E6=95=B0=E6=8D=AE=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/native/talk_view_native_decode_logic.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart b/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart index 606ae73c..9ddf4a57 100644 --- a/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart +++ b/lib/talk/starChart/views/native/talk_view_native_decode_logic.dart @@ -576,17 +576,25 @@ class TalkViewNativeDecodeLogic extends BaseGetXController { /// 更新发送预期数据 void updateTalkExpect() { + // 清晰度与VideoTypeE的映射 + final Map qualityToVideoType = { + '标清': VideoTypeE.H264, + '高清': VideoTypeE.H264_720P, + // 可扩展更多清晰度 + }; TalkExpectReq talkExpectReq = TalkExpectReq(); state.isOpenVoice.value = !state.isOpenVoice.value; + // 根据当前清晰度动态设置videoType + VideoTypeE currentVideoType = qualityToVideoType[state.currentQuality.value] ?? VideoTypeE.H264; if (!state.isOpenVoice.value) { talkExpectReq = TalkExpectReq( - videoType: [VideoTypeE.H264], + videoType: [currentVideoType], audioType: [], ); showToast('已静音'.tr); } else { talkExpectReq = TalkExpectReq( - videoType: [VideoTypeE.H264], + videoType: [currentVideoType], audioType: [AudioTypeE.G711], ); } From 8e122e5a09b338ba48e5e98e8ae8de58d407c1e6 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 17:07:05 +0800 Subject: [PATCH 05/23] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E6=B7=B7mjpeg=E6=9C=9F=E6=9C=9B=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handle/impl/udp_talk_request_handler.dart | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart b/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart index 5b72e229..195c2ab6 100644 --- a/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart +++ b/lib/talk/starChart/handle/impl/udp_talk_request_handler.dart @@ -237,15 +237,18 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle if (isH264) { // 锁支持H264,发送H264视频和G711音频期望 startChartManage.sendOnlyH264VideoTalkExpectData(); - print('app收到的对讲请求后,发送的预期数据=========锁支持H264,发送H264视频格式期望数据'); + print( + 'app收到的对讲请求后,发送的预期数据=========锁支持H264,发送H264视频格式期望数据,peerID=${lockPeerID}'); } else if (isMJpeg) { // 锁只支持MJPEG,发送图像视频和G711音频期望 startChartManage.sendOnlyImageVideoTalkExpectData(); - print('app收到的对讲请求后,发送的预期数据=========锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据'); + print( + 'app收到的对讲请求后,发送的预期数据=========锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据,peerID=${lockPeerID}'); } else { // 默认使用图像视频 startChartManage.sendOnlyImageVideoTalkExpectData(); - print('app收到的对讲请求后,发送的预期数据=========锁不支持H264和MJPEG,默认发送图像视频格式期望数据'); + print( + 'app收到的对讲请求后,发送的预期数据=========锁不支持H264和MJPEG,默认发送MJPEG视频格式期望数据,peerID=${lockPeerID}'); } } @@ -281,15 +284,18 @@ class UdpTalkRequestHandler extends ScpMessageBaseHandle if (isH264) { // 锁支持H264,发送H264视频和G711音频期望 startChartManage.sendH264VideoAndG711AudioTalkExpectData(); - print('app主动发请求,收到回复后发送的预期数据=======锁支持H264,发送H264视频格式期望数据'); + AppLog.log( + 'app主动发对讲请求,收到回复后发送的预期数据=======锁支持H264,发送H264视频格式期望数据,peerID=${lockPeerID}'); } else if (isMJpeg) { // 锁只支持MJPEG,发送图像视频和G711音频期望 startChartManage.sendImageVideoAndG711AudioTalkExpectData(); - print('app主动发请求,收到回复后发送的预期数据=======锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据'); + AppLog.log( + 'app主动发对讲请求,收到回复后发送的预期数据=======锁不支持H264,支持MJPEG,发送MJPEG视频格式期望数据,peerID=${lockPeerID}'); } else { // 默认使用图像视频 startChartManage.sendImageVideoAndG711AudioTalkExpectData(); - print('app主动发请求,收到回复后发送的预期数据=======锁不支持H264和MJPEG,默认发送图像视频格式期望数据'); + AppLog.log( + 'app主动发对讲请求,收到回复后发送的预期数据=======锁不支持H264和MJPEG,默认发送MJPEG视频格式期望数据,peerID=${lockPeerID}'); } } } From e809adf98f8e7a514cb06c999f9fa17525ddcbfe Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 17:26:15 +0800 Subject: [PATCH 06/23] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0bundle=20install?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 ++--- scripts/bundle_install_retry.sh | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 scripts/bundle_install_retry.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69738d60..4e173a86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,8 +76,7 @@ variables: - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bundle config set --local path 'vendor/bundle_android' # Android独立依赖目录 - - bundle install --gemfile android/Gemfile # 去掉--quiet,便于观察进度 + - bash scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android - gem pristine --all || true # 修复所有未编译的gem扩展 script: # 输出调试信息,便于后续排查环境问题 @@ -108,8 +107,7 @@ variables: - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bundle config set --local path 'vendor/bundle_ios' # iOS独立依赖目录 - - bundle install --gemfile ios/Gemfile # 去掉--quiet,便于观察进度 + - bash scripts/bundle_install_retry.sh ios/Gemfile vendor/bundle_ios - gem pristine --all || true # 修复所有未编译的gem扩展 script: # 输出调试信息,便于后续排查环境问题 diff --git a/scripts/bundle_install_retry.sh b/scripts/bundle_install_retry.sh new file mode 100644 index 00000000..2678b221 --- /dev/null +++ b/scripts/bundle_install_retry.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# 用法: ./scripts/bundle_install_retry.sh +# 例如: ./scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android + +GEMFILE_PATH="$1" +BUNDLE_PATH="$2" + +if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ]; then + echo "用法: $0 " + exit 1 +fi + +try_count=0 +max_try=3 +success=0 + +# 先用阿里云镜像 +bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ +while [ $try_count -lt $max_try ]; do + echo "[INFO] 第$((try_count+1))次尝试使用阿里云镜像 bundle install..." + bundle config set --local path "$BUNDLE_PATH" + bundle install --gemfile "$GEMFILE_PATH" + if [ $? -eq 0 ]; then + echo "[SUCCESS] 使用阿里云镜像 bundle install 成功" + success=1 + break + fi + try_count=$((try_count+1)) + sleep 2 + echo "[WARN] 阿里云镜像 bundle install 第$try_count 次失败,准备重试..." +done + +if [ $success -eq 0 ]; then + echo "[ERROR] 阿里云镜像 bundle install 失败$max_try次,切换为官方源重试..." + bundle config mirror.https://rubygems.org https://rubygems.org + bundle config set --local path "$BUNDLE_PATH" + bundle install --gemfile "$GEMFILE_PATH" + if [ $? -eq 0 ]; then + echo "[SUCCESS] 官方源 bundle install 成功" + exit 0 + else + echo "[FATAL] 官方源 bundle install 依然失败,请检查网络或Gemfile配置。" + exit 2 + fi +fi +exit 0 \ No newline at end of file From e035d5105edd395d8f99153339aaafa9d4d50d34 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 17:39:53 +0800 Subject: [PATCH 07/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4tag=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=9E=84=E5=BB=BA=E7=9A=84=E6=AD=A3=E5=88=99=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.sh | 15 ++++++++++----- ios/build.sh | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/android/build.sh b/android/build.sh index f444cb1e..e002bba7 100755 --- a/android/build.sh +++ b/android/build.sh @@ -8,7 +8,7 @@ export ENV_BUILD_WORKSPACE=${CI_PROJECT_DIR} echo "GITLAB_WORKSPACE: ${CI_PROJECT_DIR}" cd ${CI_PROJECT_DIR}/android echo "ENV_BUILD_TAG:${ENV_BUILD_TAG},ENV_BUILD_BRANCH:${ENV_BUILD_BRANCH}" -regex='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' +regex='^(sky_)?v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then echo "===build canary_release: ${NEXT_VERSION}" export ENV_BUILD_TAG=${NEXT_VERSION} @@ -16,10 +16,15 @@ if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then bundle exec fastlane release_apk flavor:sky --verbose elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" - bundle exec fastlane release_apk flavor:xhj --verbose - bundle exec fastlane release_apk flavor:sky --verbose - bundle exec fastlane release_bundle flavor:xhj_bundle --verbose - bundle exec fastlane release_bundle flavor:sky --verbose + if [[ "${ENV_BUILD_TAG}" =~ ^sky_ ]]; then + bundle exec fastlane release_apk flavor:sky --verbose + bundle exec fastlane release_bundle flavor:sky --verbose + else + bundle exec fastlane release_apk flavor:xhj --verbose + bundle exec fastlane release_apk flavor:sky --verbose + bundle exec fastlane release_bundle flavor:xhj_bundle --verbose + bundle exec fastlane release_bundle flavor:sky --verbose + fi elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" bundle exec fastlane beta flavor:xhj env:dev --verbose diff --git a/ios/build.sh b/ios/build.sh index b492d623..dbcc67d2 100755 --- a/ios/build.sh +++ b/ios/build.sh @@ -9,7 +9,7 @@ echo "GITLAB_WORKSPACE: ${CI_PROJECT_DIR}" cd ${CI_PROJECT_DIR}/ios #bundle exec pod install echo "ENV_BUILD_TAG:${ENV_BUILD_TAG},ENV_BUILD_BRANCH:${ENV_BUILD_BRANCH}" -regex='^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' +regex='^(sky_)?v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' # ==== 调试输出,确认环境和依赖 ==== echo "=== FASTLANE/GEM/ENV DEBUG ===" @@ -29,8 +29,12 @@ if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then bundle exec fastlane release_ipa flavor:sky --verbose elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" - bundle exec fastlane release_ipa flavor:xhj --verbose - bundle exec fastlane release_ipa flavor:sky --verbose + if [[ "${ENV_BUILD_TAG}" =~ ^sky_ ]]; then + bundle exec fastlane release_ipa flavor:sky --verbose + else + bundle exec fastlane release_ipa flavor:xhj --verbose + bundle exec fastlane release_ipa flavor:sky --verbose + fi elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" bundle exec fastlane beta flavor:xhj env:Dev --verbose From a44be677c5fa14e7dd028c522490122b432b756e Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 17:52:48 +0800 Subject: [PATCH 08/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4source=E6=BA=90?= =?UTF-8?q?=E8=AE=A9bundle=5Finstall=5Fretry=E8=84=9A=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/Gemfile | 2 +- ios/Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/Gemfile b/android/Gemfile index 79087196..5f5b8322 100644 --- a/android/Gemfile +++ b/android/Gemfile @@ -1,4 +1,4 @@ -source "https://mirrors.aliyun.com/rubygems/" +source "https://rubygems.org" gem "fastlane" gem 'nkf', '0.2.0' diff --git a/ios/Gemfile b/ios/Gemfile index 8a7082c8..cb7538c4 100644 --- a/ios/Gemfile +++ b/ios/Gemfile @@ -1,4 +1,4 @@ -source "https://gems.ruby-china.com" +source "https://rubygems.org" gem "fastlane" gem 'cocoapods', '1.14.3' From bed58065b0b060d5b38f4eef88b667a30bb921cf Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 18:01:08 +0800 Subject: [PATCH 09/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4tag=E6=98=B5?= =?UTF-8?q?=E7=A7=B0=E5=88=A4=E6=96=AD=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/fastlane/Fastfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 3591770d..702fd5aa 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -132,7 +132,12 @@ platform :ios do print_log "build flavor: #{flavor}" build_number = Time.now.strftime("%Y%m%d%H%M") print_log "Build Commits #{build_number}" - build_version = $current_tag.match(/^v(\d+\.\d+\.\d+)/).captures[0] + m = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/) + if m + build_version = m.captures.last + else + UI.user_error!("Tag格式不正确,无法提取版本号: #{$current_tag}") + end print_log "build_version #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] From 5ddfbe46d1208efe98f59ca19d0d834d024cb48c Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 18:18:10 +0800 Subject: [PATCH 10/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=87=BA=E7=8E=B0C?= =?UTF-8?q?ould=20not=20find=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E5=BC=8F=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 4 +- scripts/bundle_install_and_auto_add.sh | 79 ++++++++++++++++++++++++++ scripts/bundle_missing_gem_auto_add.sh | 49 ++++++++++++++++ 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 scripts/bundle_install_and_auto_add.sh create mode 100644 scripts/bundle_missing_gem_auto_add.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e07d557..cfe01e10 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -76,7 +76,7 @@ variables: - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bash scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android + - bash scripts/bundle_install_and_auto_add.sh android/Gemfile vendor/bundle_android "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 script: # 输出调试信息,便于后续排查环境问题 @@ -107,7 +107,7 @@ variables: - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bash scripts/bundle_install_retry.sh ios/Gemfile vendor/bundle_ios + - bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 script: # 输出调试信息,便于后续排查环境问题 diff --git a/scripts/bundle_install_and_auto_add.sh b/scripts/bundle_install_and_auto_add.sh new file mode 100644 index 00000000..5a1a8449 --- /dev/null +++ b/scripts/bundle_install_and_auto_add.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# 用法: bash scripts/bundle_install_and_auto_add.sh +# 例如: bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" + +GEMFILE_PATH="$1" +BUNDLE_PATH="$2" +MAIN_CMD="$3" + +if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ] || [ -z "$MAIN_CMD" ]; then + echo "用法: $0 " + exit 1 +fi + +max_auto_add=3 +add_count=0 +success=0 + +# 1. 检查并自动补全Gemfile缺失依赖 +while [ $add_count -lt $max_auto_add ]; do + echo "[INFO] 第$((add_count+1))次尝试运行主命令: $MAIN_CMD (仅捕获缺失gem)" + $MAIN_CMD > bundle_missing_gem.log 2>&1 && success=1 && break + missing_gem=$(grep -o "Could not find [^ ]*" bundle_missing_gem.log | awk '{print $4}' | head -n1) + if [ -n "$missing_gem" ]; then + if ! grep -q "gem '$missing_gem'" "$GEMFILE_PATH"; then + echo "gem '$missing_gem'" >> "$GEMFILE_PATH" + echo "[AUTO] Gemfile已自动补全: $missing_gem" + else + echo "[WARN] Gemfile已包含 $missing_gem,但依然缺失,可能是平台或缓存问题" + fi + else + echo "[INFO] 未检测到缺失gem,或主命令已成功。" + break + fi + add_count=$((add_count+1)) + sleep 2 + echo "[WARN] 第$add_count 次自动补全后重试..." +done + +if [ $success -eq 1 ]; then + echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" + exit 0 +fi + +# 2. 统一执行镜像切换和重试的bundle install +try_count=0 +max_try=3 +success=0 +bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ +while [ $try_count -lt $max_try ]; do + echo "[INFO] 第$((try_count+1))次尝试使用阿里云镜像 bundle install..." + bundle config set --local path "$BUNDLE_PATH" + bundle install --gemfile "$GEMFILE_PATH" + if [ $? -eq 0 ]; then + echo "[SUCCESS] 使用阿里云镜像 bundle install 成功" + success=1 + break + fi + try_count=$((try_count+1)) + sleep 2 + echo "[WARN] 阿里云镜像 bundle install 第$try_count 次失败,准备重试..." +done + +if [ $success -eq 0 ]; then + echo "[ERROR] 阿里云镜像 bundle install 失败$max_try次,切换为官方源重试..." + bundle config mirror.https://rubygems.org https://rubygems.org + bundle config set --local path "$BUNDLE_PATH" + bundle install --gemfile "$GEMFILE_PATH" + if [ $? -eq 0 ]; then + echo "[SUCCESS] 官方源 bundle install 成功" + else + echo "[FATAL] 官方源 bundle install 依然失败,请检查网络或Gemfile配置。" + exit 2 + fi +fi + +# 3. 最后再执行一次主命令校验 +$MAIN_CMD || { echo "[FATAL] 主命令依然失败,请人工检查Gemfile和依赖环境。"; exit 3; } +echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" +exit 0 \ No newline at end of file diff --git a/scripts/bundle_missing_gem_auto_add.sh b/scripts/bundle_missing_gem_auto_add.sh new file mode 100644 index 00000000..fdc5cc64 --- /dev/null +++ b/scripts/bundle_missing_gem_auto_add.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# 用法: bash scripts/bundle_missing_gem_auto_add.sh +# 例如: bash scripts/bundle_missing_gem_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" + +GEMFILE_PATH="$1" +BUNDLE_PATH="$2" +MAIN_CMD="$3" + +if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ] || [ -z "$MAIN_CMD" ]; then + echo "用法: $0 " + exit 1 +fi + +max_try=3 +try_count=0 +success=0 + +bundle check --path "$BUNDLE_PATH" || bundle install --gemfile "$GEMFILE_PATH" --path "$BUNDLE_PATH" + +while [ $try_count -lt $max_try ]; do + echo "[INFO] 第$((try_count+1))次尝试运行主命令: $MAIN_CMD" + $MAIN_CMD > bundle_missing_gem.log 2>&1 && success=1 && break + # 捕获缺失gem + missing_gem=$(grep -o "Could not find [^ ]*" bundle_missing_gem.log | awk '{print $4}' | head -n1) + if [ -n "$missing_gem" ]; then + if ! grep -q "gem '$missing_gem'" "$GEMFILE_PATH"; then + echo "gem '$missing_gem'" >> "$GEMFILE_PATH" + echo "[AUTO] Gemfile已自动补全: $missing_gem" + else + echo "[WARN] Gemfile已包含 $missing_gem,但依然缺失,可能是平台或缓存问题" + fi + bundle install --gemfile "$GEMFILE_PATH" --path "$BUNDLE_PATH" + else + echo "[FATAL] 未检测到缺失gem,需人工介入。日志如下:" + cat bundle_missing_gem.log + exit 2 + fi + try_count=$((try_count+1)) + sleep 2 + echo "[WARN] 第$try_count 次自动补全后重试..." +done + +if [ $success -eq 1 ]; then + echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" + exit 0 +else + echo "[FATAL] 自动补全$max_try次后依然失败,请人工检查Gemfile和依赖环境。" + exit 3 +fi \ No newline at end of file From 219e0e794f1e133943a2361279ffa0d5e90db6de Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 18:24:58 +0800 Subject: [PATCH 11/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E5=87=BA=E7=8E=B0C?= =?UTF-8?q?ould=20not=20find=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=98=BE?= =?UTF-8?q?=E5=BC=8F=E6=8C=87=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 8 +++-- scripts/bundle_install_retry.sh | 46 ------------------------ scripts/bundle_missing_gem_auto_add.sh | 49 -------------------------- 3 files changed, 6 insertions(+), 97 deletions(-) delete mode 100644 scripts/bundle_install_retry.sh delete mode 100644 scripts/bundle_missing_gem_auto_add.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cfe01e10..32cf0991 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,7 +64,9 @@ variables: .setup_fastlane_android: extends: .build_rule before_script: - - rm -rf ~/.gem ~/.bundle vendor/bundle_android # 强烈建议每次清理,防止并发/缓存污染 + - rm -rf ~/.gem ~/.bundle vendor/bundle_android + - export GEM_HOME="$PWD/vendor/bundle_android" + - export GEM_PATH="$PWD/vendor/bundle_android" - export PATH="$HOME/.rbenv/bin:$PATH" - eval "$(rbenv init -)" - rbenv global 2.7.8 @@ -95,7 +97,9 @@ variables: .setup_fastlane_ios: extends: .build_rule before_script: - - rm -rf ~/.gem ~/.bundle vendor/bundle_ios # 强烈建议每次清理,防止并发/缓存污染 + - rm -rf ~/.gem ~/.bundle vendor/bundle_ios + - export GEM_HOME="$PWD/vendor/bundle_ios" + - export GEM_PATH="$PWD/vendor/bundle_ios" - export PATH="$HOME/.rbenv/bin:$PATH" - eval "$(rbenv init -)" - rbenv global 2.7.8 diff --git a/scripts/bundle_install_retry.sh b/scripts/bundle_install_retry.sh deleted file mode 100644 index 2678b221..00000000 --- a/scripts/bundle_install_retry.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# 用法: ./scripts/bundle_install_retry.sh -# 例如: ./scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android - -GEMFILE_PATH="$1" -BUNDLE_PATH="$2" - -if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ]; then - echo "用法: $0 " - exit 1 -fi - -try_count=0 -max_try=3 -success=0 - -# 先用阿里云镜像 -bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ -while [ $try_count -lt $max_try ]; do - echo "[INFO] 第$((try_count+1))次尝试使用阿里云镜像 bundle install..." - bundle config set --local path "$BUNDLE_PATH" - bundle install --gemfile "$GEMFILE_PATH" - if [ $? -eq 0 ]; then - echo "[SUCCESS] 使用阿里云镜像 bundle install 成功" - success=1 - break - fi - try_count=$((try_count+1)) - sleep 2 - echo "[WARN] 阿里云镜像 bundle install 第$try_count 次失败,准备重试..." -done - -if [ $success -eq 0 ]; then - echo "[ERROR] 阿里云镜像 bundle install 失败$max_try次,切换为官方源重试..." - bundle config mirror.https://rubygems.org https://rubygems.org - bundle config set --local path "$BUNDLE_PATH" - bundle install --gemfile "$GEMFILE_PATH" - if [ $? -eq 0 ]; then - echo "[SUCCESS] 官方源 bundle install 成功" - exit 0 - else - echo "[FATAL] 官方源 bundle install 依然失败,请检查网络或Gemfile配置。" - exit 2 - fi -fi -exit 0 \ No newline at end of file diff --git a/scripts/bundle_missing_gem_auto_add.sh b/scripts/bundle_missing_gem_auto_add.sh deleted file mode 100644 index fdc5cc64..00000000 --- a/scripts/bundle_missing_gem_auto_add.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# 用法: bash scripts/bundle_missing_gem_auto_add.sh -# 例如: bash scripts/bundle_missing_gem_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - -GEMFILE_PATH="$1" -BUNDLE_PATH="$2" -MAIN_CMD="$3" - -if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ] || [ -z "$MAIN_CMD" ]; then - echo "用法: $0 " - exit 1 -fi - -max_try=3 -try_count=0 -success=0 - -bundle check --path "$BUNDLE_PATH" || bundle install --gemfile "$GEMFILE_PATH" --path "$BUNDLE_PATH" - -while [ $try_count -lt $max_try ]; do - echo "[INFO] 第$((try_count+1))次尝试运行主命令: $MAIN_CMD" - $MAIN_CMD > bundle_missing_gem.log 2>&1 && success=1 && break - # 捕获缺失gem - missing_gem=$(grep -o "Could not find [^ ]*" bundle_missing_gem.log | awk '{print $4}' | head -n1) - if [ -n "$missing_gem" ]; then - if ! grep -q "gem '$missing_gem'" "$GEMFILE_PATH"; then - echo "gem '$missing_gem'" >> "$GEMFILE_PATH" - echo "[AUTO] Gemfile已自动补全: $missing_gem" - else - echo "[WARN] Gemfile已包含 $missing_gem,但依然缺失,可能是平台或缓存问题" - fi - bundle install --gemfile "$GEMFILE_PATH" --path "$BUNDLE_PATH" - else - echo "[FATAL] 未检测到缺失gem,需人工介入。日志如下:" - cat bundle_missing_gem.log - exit 2 - fi - try_count=$((try_count+1)) - sleep 2 - echo "[WARN] 第$try_count 次自动补全后重试..." -done - -if [ $success -eq 1 ]; then - echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" - exit 0 -else - echo "[FATAL] 自动补全$max_try次后依然失败,请人工检查Gemfile和依赖环境。" - exit 3 -fi \ No newline at end of file From c1c4a4a675407040ddd7874ac4dc5faead76b1d9 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 16 May 2025 18:46:45 +0800 Subject: [PATCH 12/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E4=B8=8D=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEtag=E6=98=B5=E7=A7=B0=E8=BF=9B=E8=A1=8C=E5=8C=BA?= =?UTF-8?q?=E5=88=86=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.sh | 14 +++++--------- ios/build.sh | 10 ++++------ 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/android/build.sh b/android/build.sh index e002bba7..04f83062 100755 --- a/android/build.sh +++ b/android/build.sh @@ -16,15 +16,11 @@ if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then bundle exec fastlane release_apk flavor:sky --verbose elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" - if [[ "${ENV_BUILD_TAG}" =~ ^sky_ ]]; then - bundle exec fastlane release_apk flavor:sky --verbose - bundle exec fastlane release_bundle flavor:sky --verbose - else - bundle exec fastlane release_apk flavor:xhj --verbose - bundle exec fastlane release_apk flavor:sky --verbose - bundle exec fastlane release_bundle flavor:xhj_bundle --verbose - bundle exec fastlane release_bundle flavor:sky --verbose - fi + bundle exec fastlane release_apk flavor:xhj --verbose + bundle exec fastlane release_apk flavor:sky --verbose + bundle exec fastlane release_bundle flavor:xhj_bundle --verbose + bundle exec fastlane release_bundle flavor:sky --verbose + ls -l build/app/outputs/flutter-apk/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" bundle exec fastlane beta flavor:xhj env:dev --verbose diff --git a/ios/build.sh b/ios/build.sh index dbcc67d2..af047e71 100755 --- a/ios/build.sh +++ b/ios/build.sh @@ -29,12 +29,10 @@ if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then bundle exec fastlane release_ipa flavor:sky --verbose elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" - if [[ "${ENV_BUILD_TAG}" =~ ^sky_ ]]; then - bundle exec fastlane release_ipa flavor:sky --verbose - else - bundle exec fastlane release_ipa flavor:xhj --verbose - bundle exec fastlane release_ipa flavor:sky --verbose - fi + # 无论tag前缀,均构建xhj和sky的ipa + bundle exec fastlane release_ipa flavor:xhj --verbose + bundle exec fastlane release_ipa flavor:sky --verbose + ls -l build/app/outputs/flutter-ipa/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" bundle exec fastlane beta flavor:xhj env:Dev --verbose From f42659c8ac08e5468be01ece226f6ddbb5186753 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 09:28:28 +0800 Subject: [PATCH 13/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 ++++-- android/Gemfile | 2 +- android/build.sh | 24 ++++++++++++------------ ios/Gemfile | 2 +- ios/build.sh | 16 ++++++++-------- scripts/bundle_install_and_auto_add.sh | 7 +++++++ 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32cf0991..e0452619 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,7 +73,8 @@ variables: - export PATH="$HOME/.rbenv/shims:$PATH" - which ruby # 输出当前使用的ruby路径,便于调试 - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ # 如在国外可移除此行 + - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 + - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li @@ -106,7 +107,8 @@ variables: - export PATH="$HOME/.rbenv/shims:$PATH" - which ruby # 输出当前使用的ruby路径,便于调试 - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/ # 如在国外可移除此行 + - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 + - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - bundle config mirror.https://rubygems.org https://gems.ruby-china.com - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li diff --git a/android/Gemfile b/android/Gemfile index 5f5b8322..3de6080f 100644 --- a/android/Gemfile +++ b/android/Gemfile @@ -1,4 +1,4 @@ -source "https://rubygems.org" +source "https://gems.ruby-china.com" gem "fastlane" gem 'nkf', '0.2.0' diff --git a/android/build.sh b/android/build.sh index 04f83062..c6dd6d91 100755 --- a/android/build.sh +++ b/android/build.sh @@ -12,26 +12,26 @@ regex='^(sky_)?v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$' if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then echo "===build canary_release: ${NEXT_VERSION}" export ENV_BUILD_TAG=${NEXT_VERSION} - bundle exec fastlane release_apk flavor:xhj --verbose - bundle exec fastlane release_apk flavor:sky --verbose + bundle exec fastlane release_apk flavor:xhj --verbose || { echo "[FATAL] fastlane release_apk xhj 失败"; exit 10; } + bundle exec fastlane release_apk flavor:sky --verbose || { echo "[FATAL] fastlane release_apk sky 失败"; exit 11; } elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" - bundle exec fastlane release_apk flavor:xhj --verbose - bundle exec fastlane release_apk flavor:sky --verbose - bundle exec fastlane release_bundle flavor:xhj_bundle --verbose - bundle exec fastlane release_bundle flavor:sky --verbose + bundle exec fastlane release_apk flavor:xhj --verbose || { echo "[FATAL] fastlane release_apk xhj 失败"; exit 10; } + bundle exec fastlane release_apk flavor:sky --verbose || { echo "[FATAL] fastlane release_apk sky 失败"; exit 11; } + bundle exec fastlane release_bundle flavor:xhj_bundle --verbose || { echo "[FATAL] fastlane release_bundle xhj_bundle 失败"; exit 12; } + bundle exec fastlane release_bundle flavor:sky --verbose || { echo "[FATAL] fastlane release_bundle sky 失败"; exit 13; } ls -l build/app/outputs/flutter-apk/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" - bundle exec fastlane beta flavor:xhj env:dev --verbose - bundle exec fastlane beta flavor:sky env:dev --verbose + bundle exec fastlane beta flavor:xhj env:dev --verbose || { echo "[FATAL] fastlane beta xhj dev 失败"; exit 20; } + bundle exec fastlane beta flavor:sky env:dev --verbose || { echo "[FATAL] fastlane beta sky dev 失败"; exit 21; } elif [[ "${ENV_BUILD_BRANCH}" == "release" ]] || [[ "${ENV_BUILD_BRANCH}" == "feat_devops" ]] ; then echo "===build pre===${NEXT_VERSION}" - bundle exec fastlane beta flavor:xhj env:pre --verbose - bundle exec fastlane beta flavor:sky env:pre --verbose + bundle exec fastlane beta flavor:xhj env:pre --verbose || { echo "[FATAL] fastlane beta xhj pre 失败"; exit 30; } + bundle exec fastlane beta flavor:sky env:pre --verbose || { echo "[FATAL] fastlane beta sky pre 失败"; exit 31; } elif [[ "${ENV_BUILD_BRANCH}" == "release_sky" ]]; then echo "===build release_sky===${NEXT_VERSION}" - bundle exec fastlane release_apk flavor:sky --verbose - bundle exec fastlane release_bundle flavor:sky --verbose + bundle exec fastlane release_apk flavor:sky --verbose || { echo "[FATAL] fastlane release_apk sky 失败"; exit 40; } + bundle exec fastlane release_bundle flavor:sky --verbose || { echo "[FATAL] fastlane release_bundle sky 失败"; exit 41; } fi exit 0 \ No newline at end of file diff --git a/ios/Gemfile b/ios/Gemfile index cb7538c4..8a7082c8 100644 --- a/ios/Gemfile +++ b/ios/Gemfile @@ -1,4 +1,4 @@ -source "https://rubygems.org" +source "https://gems.ruby-china.com" gem "fastlane" gem 'cocoapods', '1.14.3' diff --git a/ios/build.sh b/ios/build.sh index af047e71..e7235771 100755 --- a/ios/build.sh +++ b/ios/build.sh @@ -25,21 +25,21 @@ gem list | grep digest-crc if [[ "${ENV_BUILD_BRANCH}" == "canary_release" ]]; then echo "===build canary_release: ${NEXT_VERSION}" export ENV_BUILD_TAG=${NEXT_VERSION} - bundle exec fastlane release_ipa flavor:xhj --verbose - bundle exec fastlane release_ipa flavor:sky --verbose + bundle exec fastlane release_ipa flavor:xhj --verbose || { echo "[FATAL] fastlane release_ipa xhj 失败"; exit 10; } + bundle exec fastlane release_ipa flavor:sky --verbose || { echo "[FATAL] fastlane release_ipa sky 失败"; exit 11; } elif [[ $ENV_BUILD_TAG =~ $regex ]]; then echo "===build release===$ENV_BUILD_TAG" # 无论tag前缀,均构建xhj和sky的ipa - bundle exec fastlane release_ipa flavor:xhj --verbose - bundle exec fastlane release_ipa flavor:sky --verbose + bundle exec fastlane release_ipa flavor:xhj --verbose || { echo "[FATAL] fastlane release_ipa xhj 失败"; exit 10; } + bundle exec fastlane release_ipa flavor:sky --verbose || { echo "[FATAL] fastlane release_ipa sky 失败"; exit 11; } ls -l build/app/outputs/flutter-ipa/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" - bundle exec fastlane beta flavor:xhj env:Dev --verbose - bundle exec fastlane beta flavor:sky env:Dev --verbose + bundle exec fastlane beta flavor:xhj env:Dev --verbose || { echo "[FATAL] fastlane beta xhj Dev 失败"; exit 20; } + bundle exec fastlane beta flavor:sky env:Dev --verbose || { echo "[FATAL] fastlane beta sky Dev 失败"; exit 21; } elif [[ "${ENV_BUILD_BRANCH}" == "release" ]] || [[ "${ENV_BUILD_BRANCH}" == "feat_devops" ]] ; then echo "===build pre===${NEXT_VERSION}" - bundle exec fastlane beta flavor:xhj env:Pre --verbose - bundle exec fastlane beta flavor:sky env:Pre --verbose + bundle exec fastlane beta flavor:xhj env:Pre --verbose || { echo "[FATAL] fastlane beta xhj Pre 失败"; exit 30; } + bundle exec fastlane beta flavor:sky env:Pre --verbose || { echo "[FATAL] fastlane beta sky Pre 失败"; exit 31; } fi exit 0 \ No newline at end of file diff --git a/scripts/bundle_install_and_auto_add.sh b/scripts/bundle_install_and_auto_add.sh index 5a1a8449..61fce330 100644 --- a/scripts/bundle_install_and_auto_add.sh +++ b/scripts/bundle_install_and_auto_add.sh @@ -11,6 +11,9 @@ if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ] || [ -z "$MAIN_CMD" ]; then exit 1 fi +# 保证rubygems.org官方源始终存在(开头) +gem sources --add https://rubygems.org || true + max_auto_add=3 add_count=0 success=0 @@ -38,6 +41,8 @@ done if [ $success -eq 1 ]; then echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" + # 再次保证rubygems.org官方源始终存在(结尾) + gem sources --add https://rubygems.org || true exit 0 fi @@ -75,5 +80,7 @@ fi # 3. 最后再执行一次主命令校验 $MAIN_CMD || { echo "[FATAL] 主命令依然失败,请人工检查Gemfile和依赖环境。"; exit 3; } +# 再次保证rubygems.org官方源始终存在(结尾) +gem sources --add https://rubygems.org || true echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" exit 0 \ No newline at end of file From 46bec40eb700cfce4f27141875e50c44adea01f5 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 10:17:43 +0800 Subject: [PATCH 14/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/fastlane/Fastfile | 93 +++++++++++++++++++++++++++++---------- ios/fastlane/Fastfile | 62 +++++++++++++++++--------- 2 files changed, 111 insertions(+), 44 deletions(-) diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 2c66fff4..c8fe4f09 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -44,22 +44,29 @@ platform :android do print_header '🏁 Before All' print_log $current_branch print_log $current_tag - print_log $path_file_preview_apk_default - print_log $path_file_release_apk_default - print_log $path_file_preview_apk_copy - print_log $path_file_release_apk_copy Dir.chdir "../.." do sh('pwd') end + # RubyGems/bundle环境相关日志 + sh('which ruby') + sh('ruby -v') + sh('which gem') + sh('gem -v') + sh('gem sources -l') + sh('which bundle') + sh('bundle -v') + sh('bundle config') + sh('env | grep GEM || true') + sh('env | grep BUNDLE || true') + sh('env | grep CI_ || true') end desc "Submit a new Beta Build to Pgy Beta" lane :beta do |options| - flavor = options[:flavor] env = options[:env] - UI.user_error!("flavor is required") unless flavor + flavor = 'sky' UI.user_error!("env is required") unless env - print_log "build #{flavor} on #{env}" + print_log "build sky on #{env}" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" build_version = $next_version @@ -69,11 +76,25 @@ platform :android do print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do - sh("flutter","pub","get") - sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}_#{env}", "-t", "lib/main_#{flavor}_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + sh("flutter","pub","get") end - old_file_path = File.join($path_apk_output_dir, "app-#{flavor}_#{env}-release.apk") - new_file_path = File.join($path_apk_output_dir, "starlock-#{flavor}-preview-#{build_version}.apk") + Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "sky_#{env}", "-t", "lib/main_sky_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + end + old_file_path = File.join($path_apk_output_dir, "app-sky_#{env}-release.apk") + new_file_path = File.join($path_apk_output_dir, "starlock-sky-preview-#{build_version}.apk") + print_log "old_file_path: #{old_file_path}" + print_log "new_file_path: #{new_file_path}" File.rename(old_file_path, new_file_path) logs = changelog_from_git_commits( pretty: '- %s (%cn)', @@ -85,9 +106,8 @@ platform :android do desc "Build & upload a new version to Gitlab Release" lane :release_apk do |options| - flavor = options[:flavor] - UI.user_error!("flavor is required") unless flavor - print_log "build flavor for: #{flavor}" + flavor = 'sky' + print_log "build flavor for: sky" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" build_version = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/).captures.last @@ -97,19 +117,32 @@ platform :android do print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') sh("flutter","pub","get") - sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - old_apk_file_path = File.join($path_apk_output_dir, "app-#{flavor}-release.apk") - new_apk_file_path = File.join($path_apk_output_dir, "starlock-#{flavor}-release-"+$current_tag+".apk") + Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + end + old_apk_file_path = File.join($path_apk_output_dir, "app-sky-release.apk") + new_apk_file_path = File.join($path_apk_output_dir, "starlock-sky-release-"+$current_tag+".apk") + print_log "old_apk_file_path: #{old_apk_file_path}" + print_log "new_apk_file_path: #{new_apk_file_path}" File.rename(old_apk_file_path, new_apk_file_path) end desc "Build & upload a new version to Gitlab Release" lane :release_bundle do |options| - flavor = options[:flavor] - UI.user_error!("flavor is required") unless flavor - print_log "build flavor for: #{flavor}" + flavor = 'sky' + print_log "build flavor for: sky" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" build_version = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/).captures.last @@ -119,11 +152,25 @@ platform :android do print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"cn") Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') sh("flutter","pub","get") - sh("flutter", "build", "appbundle", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - old_bundle_file_path = File.join($path_bundle_output_dir , "/#{flavor}Release/app-#{flavor}-release.aab") - new_bundle_file_path = File.join($path_bundle_output_dir , "/#{flavor}Release/starlock-#{flavor}-release-"+$current_tag+".aab") + Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + sh("flutter", "build", "appbundle", "--no-tree-shake-icons", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('ls -lh build/app/outputs/flutter-apk/ || true') + sh('ls -lh build/app/outputs/bundle/ || true') + end + old_bundle_file_path = File.join($path_bundle_output_dir , "/skyRelease/app-sky-release.aab") + new_bundle_file_path = File.join($path_bundle_output_dir , "/skyRelease/starlock-sky-release-"+$current_tag+".aab") + print_log "old_bundle_file_path: #{old_bundle_file_path}" + print_log "new_bundle_file_path: #{new_bundle_file_path}" File.rename(old_bundle_file_path, new_bundle_file_path) sh('cp',new_bundle_file_path,$path_apk_output_dir) end diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index 702fd5aa..dc7bc668 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -68,38 +68,55 @@ platform :ios do Dir.chdir "../.." do sh('pwd') end + # RubyGems/bundle环境相关日志 + sh('which ruby') + sh('ruby -v') + sh('which gem') + sh('gem -v') + sh('gem sources -l') + sh('which bundle') + sh('bundle -v') + sh('bundle config') + sh('env | grep GEM || true') + sh('env | grep BUNDLE || true') + sh('env | grep CI_ || true') end desc "Build & Deliver to Pgy" lane :beta do |options| - flavor = options[:flavor] env = options[:env] - UI.user_error!("flavor is required") unless flavor + flavor = 'sky' UI.user_error!("env is required") unless env - print_log "build #{flavor} on #{env}" + print_log "build sky on #{env}" build_number = Time.now.strftime("%Y%m%d%H%M") print_log "Build Commits #{build_number}" - build_version = $next_version # Time.now.strftime("%Y%m%d%H%M%S") + build_version = $next_version print_log "build_version #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-ipa/ || true') sh("flutter","pub","get") end Dir.chdir ".." do sh("bundle", "exec" ,"pod", "install") end Dir.chdir "../.." do - sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-ipa/ || true') + sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "sky", "-t", "lib/main_sky_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('ls -lh build/app/outputs/flutter-ipa/ || true') end - #set_bundle_short_version('./Runner/Info.plist', $current_branch) - gym_scheme_preview="#{flavor}" - print_log "gym_scheme_preview #{gym_scheme_preview}" - gym_configuration = "#{env}-release-#{flavor}" + gym_scheme_preview="sky" + print_log "gym_scheme_preview sky" + gym_configuration = "#{env}-release-sky" print_log "gym_configuration #{gym_configuration}" - ipa_default_filename = "starlock-#{flavor}-preview-#{build_version}.ipa" + ipa_default_filename = "starlock-sky-preview-#{build_version}.ipa" print_log "ipa_default_filename #{ipa_default_filename}" gym( scheme: gym_scheme_preview, @@ -110,8 +127,6 @@ platform :ios do export_method: "ad-hoc", export_options: { provisioningProfiles: { - "com.xhjcn.lock.dev" => "Adhoc_com.xhjcn.lock.dev.mobileprovision", - "com.xhjcn.lock.pre" => "Adhoc_com.xhjcn.lock.pre.mobileprovision", "com.skychip.lock.dev" => "Adhoc_com.skychip.lock.dev.mobileprovision", "com.skychip.lock.pre" => "Adhoc_com.skychip.lock.pre.mobileprovision", } @@ -127,9 +142,8 @@ platform :ios do desc "Build & Deliver to App Store Connect" lane :release_ipa do |options| - flavor = options[:flavor] - UI.user_error!("flavor is required") unless flavor - print_log "build flavor: #{flavor}" + flavor = 'sky' + print_log "build flavor: sky" build_number = Time.now.strftime("%Y%m%d%H%M") print_log "Build Commits #{build_number}" m = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/) @@ -144,19 +158,26 @@ platform :ios do print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-ipa/ || true') sh("flutter","pub","get") end Dir.chdir ".." do sh("bundle", "exec" ,"pod", "install") end Dir.chdir "../.." do - sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('pwd') + sh('ls -lh') + sh('ls -lh build/app/outputs/flutter-ipa/ || true') + sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") + sh('ls -lh build/app/outputs/flutter-ipa/ || true') end - gym_scheme_release="#{flavor}" - print_log "gym_scheme_release #{gym_scheme_release}" - gym_configuration = "Release-#{flavor}" + gym_scheme_release="sky" + print_log "gym_scheme_release sky" + gym_configuration = "Release-sky" print_log "gym_configuration #{gym_configuration}" - ipa_default_filename = "starlock-#{flavor}-release-"+$current_tag+".ipa" + ipa_default_filename = "starlock-sky-release-"+$current_tag+".ipa" print_log "ipa_default_filename #{ipa_default_filename}" gym( scheme: gym_scheme_release, @@ -167,7 +188,6 @@ platform :ios do export_method: "app-store", export_options: { provisioningProfiles: { - "com.xhjcn.lock" => "Appstore_com.xhjcn.lock.mobileprovision", "com.skychip.lock" => "Appstore_com.skychip.lock.mobileprovision", } } From 804cdba152d9c77d480d000a2998c908a8136ca8 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 10:42:19 +0800 Subject: [PATCH 15/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 2 ++ scripts/bundle_install_and_auto_add.sh | 39 ++++++-------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e0452619..f6716abe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -81,6 +81,7 @@ variables: - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh android/Gemfile vendor/bundle_android "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 + - echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc script: # 输出调试信息,便于后续排查环境问题 - echo "=== DEBUG INFO (android) ===" @@ -115,6 +116,7 @@ variables: - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 + - echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc script: # 输出调试信息,便于后续排查环境问题 - echo "=== DEBUG INFO (ios) ===" diff --git a/scripts/bundle_install_and_auto_add.sh b/scripts/bundle_install_and_auto_add.sh index 61fce330..84fd6d2d 100644 --- a/scripts/bundle_install_and_auto_add.sh +++ b/scripts/bundle_install_and_auto_add.sh @@ -46,36 +46,15 @@ if [ $success -eq 1 ]; then exit 0 fi -# 2. 统一执行镜像切换和重试的bundle install -try_count=0 -max_try=3 -success=0 -bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ -while [ $try_count -lt $max_try ]; do - echo "[INFO] 第$((try_count+1))次尝试使用阿里云镜像 bundle install..." - bundle config set --local path "$BUNDLE_PATH" - bundle install --gemfile "$GEMFILE_PATH" - if [ $? -eq 0 ]; then - echo "[SUCCESS] 使用阿里云镜像 bundle install 成功" - success=1 - break - fi - try_count=$((try_count+1)) - sleep 2 - echo "[WARN] 阿里云镜像 bundle install 第$try_count 次失败,准备重试..." -done - -if [ $success -eq 0 ]; then - echo "[ERROR] 阿里云镜像 bundle install 失败$max_try次,切换为官方源重试..." - bundle config mirror.https://rubygems.org https://rubygems.org - bundle config set --local path "$BUNDLE_PATH" - bundle install --gemfile "$GEMFILE_PATH" - if [ $? -eq 0 ]; then - echo "[SUCCESS] 官方源 bundle install 成功" - else - echo "[FATAL] 官方源 bundle install 依然失败,请检查网络或Gemfile配置。" - exit 2 - fi +# 2. 只用 rubygems.org 官方源进行 bundle install +bundle config mirror.https://rubygems.org https://rubygems.org +bundle config set --local path "$BUNDLE_PATH" +bundle install --gemfile "$GEMFILE_PATH" +if [ $? -eq 0 ]; then + echo "[SUCCESS] 官方源 bundle install 成功" +else + echo "[FATAL] 官方源 bundle install 失败,请检查网络或Gemfile配置。" + exit 2 fi # 3. 最后再执行一次主命令校验 From 1ee2ca5a54cf6b4fbc282c182e8c39f338493f4f Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 11:22:56 +0800 Subject: [PATCH 16/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f6716abe..147f7607 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -75,13 +75,13 @@ variables: - ruby -v # 输出当前ruby版本,便于调试 - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 - gem sources --add https://rubygems.org || true # 保证官方源始终存在 + - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh android/Gemfile vendor/bundle_android "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 - - echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc script: # 输出调试信息,便于后续排查环境问题 - echo "=== DEBUG INFO (android) ===" @@ -110,13 +110,13 @@ variables: - ruby -v # 输出当前ruby版本,便于调试 - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - - bundle config mirror.https://rubygems.org https://gems.ruby-china.com + - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' + - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - bundle -v || gem install bundler --source https://gems.ruby-china.com/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - gem pristine --all || true # 修复所有未编译的gem扩展 - - echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc script: # 输出调试信息,便于后续排查环境问题 - echo "=== DEBUG INFO (ios) ===" From aa6f01ad5ca88edccdff0a65b3ab145be28a7c61 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 11:42:23 +0800 Subject: [PATCH 17/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 8 ++------ android/Gemfile | 2 +- ios/Gemfile | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 147f7607..69000a2c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,11 +73,9 @@ variables: - export PATH="$HOME/.rbenv/shims:$PATH" - which ruby # 输出当前使用的ruby路径,便于调试 - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' - - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - - bundle -v || gem install bundler --source https://gems.ruby-china.com/ + - bundle -v || gem install bundler --source https://rubygems.org/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh android/Gemfile vendor/bundle_android "bundle exec fastlane -v" @@ -108,11 +106,9 @@ variables: - export PATH="$HOME/.rbenv/shims:$PATH" - which ruby # 输出当前使用的ruby路径,便于调试 - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://gems.ruby-china.com/ # 如在国外可移除此行 - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' - - bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/ - - bundle -v || gem install bundler --source https://gems.ruby-china.com/ + - bundle -v || gem install bundler --source https://rubygems.org/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" diff --git a/android/Gemfile b/android/Gemfile index 3de6080f..5f5b8322 100644 --- a/android/Gemfile +++ b/android/Gemfile @@ -1,4 +1,4 @@ -source "https://gems.ruby-china.com" +source "https://rubygems.org" gem "fastlane" gem 'nkf', '0.2.0' diff --git a/ios/Gemfile b/ios/Gemfile index 8a7082c8..cb7538c4 100644 --- a/ios/Gemfile +++ b/ios/Gemfile @@ -1,4 +1,4 @@ -source "https://gems.ruby-china.com" +source "https://rubygems.org" gem "fastlane" gem 'cocoapods', '1.14.3' From 7dde0cdf8ec7346a5ae34f27cc3d268a054097ea Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 14:00:46 +0800 Subject: [PATCH 18/23] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0android=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/build.sh | 4 ++++ android/fastlane/Fastfile | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/android/build.sh b/android/build.sh index c6dd6d91..31d08255 100755 --- a/android/build.sh +++ b/android/build.sh @@ -20,6 +20,10 @@ elif [[ $ENV_BUILD_TAG =~ $regex ]]; then bundle exec fastlane release_apk flavor:sky --verbose || { echo "[FATAL] fastlane release_apk sky 失败"; exit 11; } bundle exec fastlane release_bundle flavor:xhj_bundle --verbose || { echo "[FATAL] fastlane release_bundle xhj_bundle 失败"; exit 12; } bundle exec fastlane release_bundle flavor:sky --verbose || { echo "[FATAL] fastlane release_bundle sky 失败"; exit 13; } + if [ ! -d build/app/outputs/flutter-apk/ ]; then + echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成,构建失败!" + exit 99 + fi ls -l build/app/outputs/flutter-apk/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index c8fe4f09..00e3b286 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -95,6 +95,9 @@ platform :android do new_file_path = File.join($path_apk_output_dir, "starlock-sky-preview-#{build_version}.apk") print_log "old_file_path: #{old_file_path}" print_log "new_file_path: #{new_file_path}" + unless File.exist?(old_file_path) + UI.user_error!("❌ 产物 #{old_file_path} 未生成,构建失败!") + end File.rename(old_file_path, new_file_path) logs = changelog_from_git_commits( pretty: '- %s (%cn)', @@ -136,6 +139,9 @@ platform :android do new_apk_file_path = File.join($path_apk_output_dir, "starlock-sky-release-"+$current_tag+".apk") print_log "old_apk_file_path: #{old_apk_file_path}" print_log "new_apk_file_path: #{new_apk_file_path}" + unless File.exist?(old_apk_file_path) + UI.user_error!("❌ 产物 #{old_apk_file_path} 未生成,构建失败!") + end File.rename(old_apk_file_path, new_apk_file_path) end @@ -171,7 +177,13 @@ platform :android do new_bundle_file_path = File.join($path_bundle_output_dir , "/skyRelease/starlock-sky-release-"+$current_tag+".aab") print_log "old_bundle_file_path: #{old_bundle_file_path}" print_log "new_bundle_file_path: #{new_bundle_file_path}" + unless File.exist?(old_bundle_file_path) + UI.user_error!("❌ 产物 #{old_bundle_file_path} 未生成,构建失败!") + end File.rename(old_bundle_file_path, new_bundle_file_path) + unless File.exist?(new_bundle_file_path) + UI.user_error!("❌ 产物 #{new_bundle_file_path} 未生成,构建失败!") + end sh('cp',new_bundle_file_path,$path_apk_output_dir) end From 03c24b3c977f5e46ff405390dba82ea13f65d9df Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 14:44:46 +0800 Subject: [PATCH 19/23] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0android=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=97=A5=E5=BF=97=EF=BC=8C=E9=81=BF=E5=85=8D=E5=B9=B6?= =?UTF-8?q?=E5=8F=91=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 4 ++++ android/build.sh | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 69000a2c..c2bffcb6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -177,6 +177,10 @@ build_android: build_ios: stage: build-artifacts extends: .setup_fastlane_ios + needs: + - build_android + dependencies: + - build_android script: - echo "=== DEBUG INFO (ios) ===" - which ruby diff --git a/android/build.sh b/android/build.sh index 31d08255..10618af0 100755 --- a/android/build.sh +++ b/android/build.sh @@ -20,10 +20,17 @@ elif [[ $ENV_BUILD_TAG =~ $regex ]]; then bundle exec fastlane release_apk flavor:sky --verbose || { echo "[FATAL] fastlane release_apk sky 失败"; exit 11; } bundle exec fastlane release_bundle flavor:xhj_bundle --verbose || { echo "[FATAL] fastlane release_bundle xhj_bundle 失败"; exit 12; } bundle exec fastlane release_bundle flavor:sky --verbose || { echo "[FATAL] fastlane release_bundle sky 失败"; exit 13; } + echo "=== fastlane lane 结束,检查产物目录(前) ===" + ls -lh build/app/outputs/flutter-apk/ || true + ls -lh build/app/outputs/bundle/ || true if [ ! -d build/app/outputs/flutter-apk/ ]; then echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成,构建失败!" + echo "=== 产物目录消失时,build/app/outputs/ 内容如下 ===" + ls -lh build/app/outputs/ || true + ls -lh build/app/outputs/bundle/ || true exit 99 fi + echo "=== 产物目录检查通过,最终内容如下 ===" ls -l build/app/outputs/flutter-apk/ elif [[ "${ENV_BUILD_BRANCH}" == "develop" ]]; then echo "===build dev===${NEXT_VERSION}" From 9c4cea522466b5b57ba3193d80e86479285c71d9 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 15:12:13 +0800 Subject: [PATCH 20/23] =?UTF-8?q?fix:=E7=A7=BB=E9=99=A4=E9=AB=98=E5=BE=B7?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E7=A7=BB=E9=99=A4=E9=94=81=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=AD=E7=9A=84=E4=BD=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicInformation_page.dart | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index 58c5a9bb..20c36487 100755 --- a/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -158,23 +158,23 @@ class _BasicInformationPageState extends State { allHeight: 70.h, isHaveLine: true), )), - Obx(() => CommonItem( - leftTitel: '位置信息'.tr, - // rightTitle: state.lockBasicInfo.value.address ?? "-", - allHeight: 80.h, - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: SizedBox( - width: 300.w, - child: Text(state.lockBasicInfo.value.address ?? '无'.tr, - maxLines: 2, - overflow: TextOverflow.ellipsis, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 22.sp, - color: AppColors.darkGrayTextColor)), - ), - )), + // Obx(() => CommonItem( + // leftTitel: '位置信息'.tr, + // // rightTitle: state.lockBasicInfo.value.address ?? "-", + // allHeight: 80.h, + // isHaveLine: false, + // isHaveRightWidget: true, + // rightWidget: SizedBox( + // width: 300.w, + // child: Text(state.lockBasicInfo.value.address ?? '无'.tr, + // maxLines: 2, + // overflow: TextOverflow.ellipsis, + // textAlign: TextAlign.end, + // style: TextStyle( + // fontSize: 22.sp, + // color: AppColors.darkGrayTextColor)), + // ), + // )), /* 2024-01-12 会议确定去掉“微信二维码” by DaisyWu CommonItem( leftTitel: From de3722292e4efa841baa08b21e939850c345b3ff Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 15:12:36 +0800 Subject: [PATCH 21/23] =?UTF-8?q?fix:=E5=8F=96=E6=B6=88=E6=88=AA=E5=9B=BE?= =?UTF-8?q?=E6=97=B6=E5=BF=85=E9=A1=BB=E6=8E=A5=E5=90=AC=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../imageTransmission/image_transmission_page.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/talk/starChart/views/imageTransmission/image_transmission_page.dart b/lib/talk/starChart/views/imageTransmission/image_transmission_page.dart index 3340151c..60b023bd 100644 --- a/lib/talk/starChart/views/imageTransmission/image_transmission_page.dart +++ b/lib/talk/starChart/views/imageTransmission/image_transmission_page.dart @@ -61,7 +61,7 @@ class _ImageTransmissionPageState extends State barTitle: '图传'.tr, haveBack: true, backgroundColor: AppColors.mainColor, - backAction: (){ + backAction: () { logic.udpHangUpAction(); }, ), @@ -183,10 +183,7 @@ class _ImageTransmissionPageState extends State icon: Icons.camera_alt, color: Colors.blue, onTap: () async { - if (state.talkStatus.value == - TalkStatus.answeredSuccessfully) { - await logic.captureAndSavePng(); - } + await logic.captureAndSavePng(); }, ), ], @@ -200,7 +197,10 @@ class _ImageTransmissionPageState extends State outerColor: Colors.amber.withOpacity(0.15), sliderButtonIcon: Icon(Icons.lock, color: Colors.white, size: 40.w), text: '滑动解锁', - textStyle: TextStyle(fontSize: 26.sp, color: Colors.black54, fontWeight: FontWeight.bold), + textStyle: TextStyle( + fontSize: 26.sp, + color: Colors.black54, + fontWeight: FontWeight.bold), onSubmit: () { // TODO: 实现滑动解锁逻辑 logic.remoteOpenLock(); From 47877596940a5ce75fc20c3faa402f2d20d79261 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 15:40:12 +0800 Subject: [PATCH 22/23] =?UTF-8?q?fix:=E8=B0=83=E6=95=B4ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c2bffcb6..2b0df87a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -90,6 +90,8 @@ variables: - echo $PATH - env - bash android/build.sh + - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi cache: paths: - app_new.version @@ -123,6 +125,8 @@ variables: - echo $PATH - env - bash ios/build.sh + - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi cache: paths: - app_new.version @@ -170,6 +174,8 @@ build_android: - echo $PATH - env - bash android/build.sh + - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi artifacts: paths: - build/app/outputs/flutter-apk/ @@ -190,6 +196,8 @@ build_ios: - echo $PATH - env - bash ios/build.sh + - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi artifacts: paths: - build/app/outputs/flutter-ipa @@ -212,6 +220,10 @@ create-release: - bash release_description_generator.sh - export RELEASE_DESCRIPTION="$(cat changelog.md)" - echo "${RELEASE_DESCRIPTION}" + - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi + - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" + - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi script: - export StarLock_VERSION=${CI_COMMIT_TAG#*-} - echo "Uploading StarLock-${StarLock_VERSION} packages to From 48603c7daa531e1a68d6cbedbf7a676aff82b058 Mon Sep 17 00:00:00 2001 From: liyi Date: Sat, 17 May 2025 16:32:39 +0800 Subject: [PATCH 23/23] =?UTF-8?q?fix:=E6=81=A2=E5=A4=8D=E5=8E=9F=E6=9C=89c?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 91 ++------------------- android/Gemfile | 1 - android/fastlane/Fastfile | 109 ++++++------------------- ios/Gemfile | 1 - ios/fastlane/Fastfile | 69 +++++----------- scripts/bundle_install_and_auto_add.sh | 65 --------------- tag_generator.sh | 19 ++--- 7 files changed, 58 insertions(+), 297 deletions(-) delete mode 100644 scripts/bundle_install_and_auto_add.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2b0df87a..64896dab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,10 +18,9 @@ variables: rules: - if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_BRANCH == "release" - - if: $CI_COMMIT_BRANCH == "release_sky" - if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/ - if: $CI_COMMIT_BRANCH == "canary_release" - - if: $CI_COMMIT_TAG =~ /^(sky_)?v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/ + - if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z]+\.[0-9]+)?$/ .notify_rule: tags: @@ -30,7 +29,6 @@ variables: rules: - if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_BRANCH == "release" - - if: $CI_COMMIT_BRANCH == "release_sky" - if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/ .generate_tag_rule: @@ -39,7 +37,6 @@ variables: - flutter rules: - if: $CI_COMMIT_BRANCH == "master" - - if: $CI_COMMIT_BRANCH == "master_sky" .generate_next_version_rule: tags: @@ -48,7 +45,6 @@ variables: rules: - if: $CI_COMMIT_BRANCH == "develop" - if: $CI_COMMIT_BRANCH == "release" - - if: $CI_COMMIT_BRANCH == "release_sky" - if: $CI_COMMIT_BRANCH == "canary_release" - if: $CI_COMMIT_BRANCH =~ /feat_[a-zA-Z]+/ @@ -64,34 +60,10 @@ variables: .setup_fastlane_android: extends: .build_rule before_script: - - rm -rf ~/.gem ~/.bundle vendor/bundle_android - - export GEM_HOME="$PWD/vendor/bundle_android" - - export GEM_PATH="$PWD/vendor/bundle_android" - - export PATH="$HOME/.rbenv/bin:$PATH" - - eval "$(rbenv init -)" - - rbenv global 2.7.8 - - export PATH="$HOME/.rbenv/shims:$PATH" - - which ruby # 输出当前使用的ruby路径,便于调试 - - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' - - bundle -v || gem install bundler --source https://rubygems.org/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bash scripts/bundle_install_and_auto_add.sh android/Gemfile vendor/bundle_android "bundle exec fastlane -v" - - gem pristine --all || true # 修复所有未编译的gem扩展 - script: - # 输出调试信息,便于后续排查环境问题 - - echo "=== DEBUG INFO (android) ===" - - which ruby - - ruby -v - - which gem - - gem -v - - echo $PATH - - env - - bash android/build.sh - - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi + # - flutter pub get + - bundle install --gemfile android/Gemfile --quiet cache: paths: - app_new.version @@ -99,34 +71,10 @@ variables: .setup_fastlane_ios: extends: .build_rule before_script: - - rm -rf ~/.gem ~/.bundle vendor/bundle_ios - - export GEM_HOME="$PWD/vendor/bundle_ios" - - export GEM_PATH="$PWD/vendor/bundle_ios" - - export PATH="$HOME/.rbenv/bin:$PATH" - - eval "$(rbenv init -)" - - rbenv global 2.7.8 - - export PATH="$HOME/.rbenv/shims:$PATH" - - which ruby # 输出当前使用的ruby路径,便于调试 - - ruby -v # 输出当前ruby版本,便于调试 - - gem sources --add https://rubygems.org || true # 保证官方源始终存在 - - 'echo -e "---\n:backtrace: false\n:bulk_threshold: 1000\n:sources:\n- https://rubygems.org\n:update_sources: true\n:verbose: true" > ~/.gemrc' - - bundle -v || gem install bundler --source https://rubygems.org/ - ls -li - export NEXT_VERSION="$(cat app_new.version)" - - bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - - gem pristine --all || true # 修复所有未编译的gem扩展 - script: - # 输出调试信息,便于后续排查环境问题 - - echo "=== DEBUG INFO (ios) ===" - - which ruby - - ruby -v - - which gem - - gem -v - - echo $PATH - - env - - bash ios/build.sh - - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi + # - flutter pub get + - bundle install --gemfile ios/Gemfile --quiet cache: paths: - app_new.version @@ -165,17 +113,7 @@ generate_next_version: build_android: stage: build-artifacts extends: .setup_fastlane_android - script: - - echo "=== DEBUG INFO (android) ===" - - which ruby - - ruby -v - - which gem - - gem -v - - echo $PATH - - env - - bash android/build.sh - - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi + script: bash android/build.sh artifacts: paths: - build/app/outputs/flutter-apk/ @@ -183,21 +121,8 @@ build_android: build_ios: stage: build-artifacts extends: .setup_fastlane_ios - needs: - - build_android - dependencies: - - build_android script: - - echo "=== DEBUG INFO (ios) ===" - - which ruby - - ruby -v - - which gem - - gem -v - - echo $PATH - - env - bash ios/build.sh - - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi artifacts: paths: - build/app/outputs/flutter-ipa @@ -220,10 +145,6 @@ create-release: - bash release_description_generator.sh - export RELEASE_DESCRIPTION="$(cat changelog.md)" - echo "${RELEASE_DESCRIPTION}" - - echo "=== [产物检查] build/app/outputs/flutter-apk/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-apk/ ]; then ls -lh build/app/outputs/flutter-apk/; else echo "❌ 产物目录 build/app/outputs/flutter-apk/ 未生成!"; fi - - echo "=== [产物检查] build/app/outputs/flutter-ipa/ 目录内容如下 ===" - - if [ -d build/app/outputs/flutter-ipa/ ]; then ls -lh build/app/outputs/flutter-ipa/; else echo "❌ 产物目录 build/app/outputs/flutter-ipa/ 未生成!"; fi script: - export StarLock_VERSION=${CI_COMMIT_TAG#*-} - echo "Uploading StarLock-${StarLock_VERSION} packages to diff --git a/android/Gemfile b/android/Gemfile index 5f5b8322..cdd3a6b3 100644 --- a/android/Gemfile +++ b/android/Gemfile @@ -1,7 +1,6 @@ source "https://rubygems.org" gem "fastlane" -gem 'nkf', '0.2.0' plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/android/fastlane/Fastfile b/android/fastlane/Fastfile index 00e3b286..a99f62f0 100644 --- a/android/fastlane/Fastfile +++ b/android/fastlane/Fastfile @@ -44,29 +44,22 @@ platform :android do print_header '🏁 Before All' print_log $current_branch print_log $current_tag + print_log $path_file_preview_apk_default + print_log $path_file_release_apk_default + print_log $path_file_preview_apk_copy + print_log $path_file_release_apk_copy Dir.chdir "../.." do sh('pwd') end - # RubyGems/bundle环境相关日志 - sh('which ruby') - sh('ruby -v') - sh('which gem') - sh('gem -v') - sh('gem sources -l') - sh('which bundle') - sh('bundle -v') - sh('bundle config') - sh('env | grep GEM || true') - sh('env | grep BUNDLE || true') - sh('env | grep CI_ || true') end desc "Submit a new Beta Build to Pgy Beta" lane :beta do |options| + flavor = options[:flavor] env = options[:env] - flavor = 'sky' + UI.user_error!("flavor is required") unless flavor UI.user_error!("env is required") unless env - print_log "build sky on #{env}" + print_log "build #{flavor} on #{env}" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" build_version = $next_version @@ -76,28 +69,11 @@ platform :android do print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - sh("flutter","pub","get") - end - Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "sky_#{env}", "-t", "lib/main_sky_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - end - old_file_path = File.join($path_apk_output_dir, "app-sky_#{env}-release.apk") - new_file_path = File.join($path_apk_output_dir, "starlock-sky-preview-#{build_version}.apk") - print_log "old_file_path: #{old_file_path}" - print_log "new_file_path: #{new_file_path}" - unless File.exist?(old_file_path) - UI.user_error!("❌ 产物 #{old_file_path} 未生成,构建失败!") + sh("flutter","pub","get") + sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}_#{env}", "-t", "lib/main_#{flavor}_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end + old_file_path = File.join($path_apk_output_dir, "app-#{flavor}_#{env}-release.apk") + new_file_path = File.join($path_apk_output_dir, "starlock-#{flavor}-preview-#{build_version}.apk") File.rename(old_file_path, new_file_path) logs = changelog_from_git_commits( pretty: '- %s (%cn)', @@ -109,81 +85,46 @@ platform :android do desc "Build & upload a new version to Gitlab Release" lane :release_apk do |options| - flavor = 'sky' - print_log "build flavor for: sky" + flavor = options[:flavor] + UI.user_error!("flavor is required") unless flavor + print_log "build flavor for: #{flavor}" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" - build_version = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/).captures.last + build_version = $current_tag.match(/^v(\d+\.\d+\.\d+)/).captures[0] print_log "buildVersion #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') sh("flutter","pub","get") + sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - end - old_apk_file_path = File.join($path_apk_output_dir, "app-sky-release.apk") - new_apk_file_path = File.join($path_apk_output_dir, "starlock-sky-release-"+$current_tag+".apk") - print_log "old_apk_file_path: #{old_apk_file_path}" - print_log "new_apk_file_path: #{new_apk_file_path}" - unless File.exist?(old_apk_file_path) - UI.user_error!("❌ 产物 #{old_apk_file_path} 未生成,构建失败!") - end + old_apk_file_path = File.join($path_apk_output_dir, "app-#{flavor}-release.apk") + new_apk_file_path = File.join($path_apk_output_dir, "starlock-#{flavor}-release-"+$current_tag+".apk") File.rename(old_apk_file_path, new_apk_file_path) end desc "Build & upload a new version to Gitlab Release" lane :release_bundle do |options| - flavor = 'sky' - print_log "build flavor for: sky" + flavor = options[:flavor] + UI.user_error!("flavor is required") unless flavor + print_log "build flavor for: #{flavor}" build_number = Time.now.strftime("%Y%m%d%H") print_log "BuildNo #{build_number}" - build_version = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/).captures.last + build_version = $current_tag.match(/^v(\d+\.\d+\.\d+)/).captures[0] print_log "buildVersion #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"cn") Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') sh("flutter","pub","get") + sh("flutter", "build", "appbundle", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - sh("flutter", "build", "appbundle", "--no-tree-shake-icons", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") - sh('ls -lh build/app/outputs/flutter-apk/ || true') - sh('ls -lh build/app/outputs/bundle/ || true') - end - old_bundle_file_path = File.join($path_bundle_output_dir , "/skyRelease/app-sky-release.aab") - new_bundle_file_path = File.join($path_bundle_output_dir , "/skyRelease/starlock-sky-release-"+$current_tag+".aab") - print_log "old_bundle_file_path: #{old_bundle_file_path}" - print_log "new_bundle_file_path: #{new_bundle_file_path}" - unless File.exist?(old_bundle_file_path) - UI.user_error!("❌ 产物 #{old_bundle_file_path} 未生成,构建失败!") - end + old_bundle_file_path = File.join($path_bundle_output_dir , "/#{flavor}Release/app-#{flavor}-release.aab") + new_bundle_file_path = File.join($path_bundle_output_dir , "/#{flavor}Release/starlock-#{flavor}-release-"+$current_tag+".aab") File.rename(old_bundle_file_path, new_bundle_file_path) - unless File.exist?(new_bundle_file_path) - UI.user_error!("❌ 产物 #{new_bundle_file_path} 未生成,构建失败!") - end sh('cp',new_bundle_file_path,$path_apk_output_dir) end diff --git a/ios/Gemfile b/ios/Gemfile index cb7538c4..21cb5dfc 100644 --- a/ios/Gemfile +++ b/ios/Gemfile @@ -5,4 +5,3 @@ gem 'cocoapods', '1.14.3' gem 'public_suffix', '~> 4.0' plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) -gem 'nkf', '0.2.0' diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index dc7bc668..3591770d 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -68,55 +68,38 @@ platform :ios do Dir.chdir "../.." do sh('pwd') end - # RubyGems/bundle环境相关日志 - sh('which ruby') - sh('ruby -v') - sh('which gem') - sh('gem -v') - sh('gem sources -l') - sh('which bundle') - sh('bundle -v') - sh('bundle config') - sh('env | grep GEM || true') - sh('env | grep BUNDLE || true') - sh('env | grep CI_ || true') end desc "Build & Deliver to Pgy" lane :beta do |options| + flavor = options[:flavor] env = options[:env] - flavor = 'sky' + UI.user_error!("flavor is required") unless flavor UI.user_error!("env is required") unless env - print_log "build sky on #{env}" + print_log "build #{flavor} on #{env}" build_number = Time.now.strftime("%Y%m%d%H%M") print_log "Build Commits #{build_number}" - build_version = $next_version + build_version = $next_version # Time.now.strftime("%Y%m%d%H%M%S") print_log "build_version #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-ipa/ || true') sh("flutter","pub","get") end Dir.chdir ".." do sh("bundle", "exec" ,"pod", "install") end Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-ipa/ || true') - sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "sky", "-t", "lib/main_sky_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") - sh('ls -lh build/app/outputs/flutter-ipa/ || true') + sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_#{env}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - gym_scheme_preview="sky" - print_log "gym_scheme_preview sky" - gym_configuration = "#{env}-release-sky" + #set_bundle_short_version('./Runner/Info.plist', $current_branch) + gym_scheme_preview="#{flavor}" + print_log "gym_scheme_preview #{gym_scheme_preview}" + gym_configuration = "#{env}-release-#{flavor}" print_log "gym_configuration #{gym_configuration}" - ipa_default_filename = "starlock-sky-preview-#{build_version}.ipa" + ipa_default_filename = "starlock-#{flavor}-preview-#{build_version}.ipa" print_log "ipa_default_filename #{ipa_default_filename}" gym( scheme: gym_scheme_preview, @@ -127,6 +110,8 @@ platform :ios do export_method: "ad-hoc", export_options: { provisioningProfiles: { + "com.xhjcn.lock.dev" => "Adhoc_com.xhjcn.lock.dev.mobileprovision", + "com.xhjcn.lock.pre" => "Adhoc_com.xhjcn.lock.pre.mobileprovision", "com.skychip.lock.dev" => "Adhoc_com.skychip.lock.dev.mobileprovision", "com.skychip.lock.pre" => "Adhoc_com.skychip.lock.pre.mobileprovision", } @@ -142,42 +127,31 @@ platform :ios do desc "Build & Deliver to App Store Connect" lane :release_ipa do |options| - flavor = 'sky' - print_log "build flavor: sky" + flavor = options[:flavor] + UI.user_error!("flavor is required") unless flavor + print_log "build flavor: #{flavor}" build_number = Time.now.strftime("%Y%m%d%H%M") print_log "Build Commits #{build_number}" - m = $current_tag.match(/^(sky_)?v(\d+\.\d+\.\d+)/) - if m - build_version = m.captures.last - else - UI.user_error!("Tag格式不正确,无法提取版本号: #{$current_tag}") - end + build_version = $current_tag.match(/^v(\d+\.\d+\.\d+)/).captures[0] print_log "build_version #{build_version}" commit_hash = last_git_commit short_hash = commit_hash[:abbreviated_commit_hash] print_log "last_git_commit_short_hash #{short_hash}" remove_zone_pre_build(zone:"com") Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-ipa/ || true') sh("flutter","pub","get") end Dir.chdir ".." do sh("bundle", "exec" ,"pod", "install") end Dir.chdir "../.." do - sh('pwd') - sh('ls -lh') - sh('ls -lh build/app/outputs/flutter-ipa/ || true') - sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "sky", "-t", "lib/main_sky_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") - sh('ls -lh build/app/outputs/flutter-ipa/ || true') + sh("flutter", "build", "ios", "--no-tree-shake-icons", "--no-codesign", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}_lite.dart", "--build-number=#{build_number}", "--build-name=#{build_version}") end - gym_scheme_release="sky" - print_log "gym_scheme_release sky" - gym_configuration = "Release-sky" + gym_scheme_release="#{flavor}" + print_log "gym_scheme_release #{gym_scheme_release}" + gym_configuration = "Release-#{flavor}" print_log "gym_configuration #{gym_configuration}" - ipa_default_filename = "starlock-sky-release-"+$current_tag+".ipa" + ipa_default_filename = "starlock-#{flavor}-release-"+$current_tag+".ipa" print_log "ipa_default_filename #{ipa_default_filename}" gym( scheme: gym_scheme_release, @@ -188,6 +162,7 @@ platform :ios do export_method: "app-store", export_options: { provisioningProfiles: { + "com.xhjcn.lock" => "Appstore_com.xhjcn.lock.mobileprovision", "com.skychip.lock" => "Appstore_com.skychip.lock.mobileprovision", } } diff --git a/scripts/bundle_install_and_auto_add.sh b/scripts/bundle_install_and_auto_add.sh deleted file mode 100644 index 84fd6d2d..00000000 --- a/scripts/bundle_install_and_auto_add.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# 用法: bash scripts/bundle_install_and_auto_add.sh -# 例如: bash scripts/bundle_install_and_auto_add.sh ios/Gemfile vendor/bundle_ios "bundle exec fastlane -v" - -GEMFILE_PATH="$1" -BUNDLE_PATH="$2" -MAIN_CMD="$3" - -if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ] || [ -z "$MAIN_CMD" ]; then - echo "用法: $0 " - exit 1 -fi - -# 保证rubygems.org官方源始终存在(开头) -gem sources --add https://rubygems.org || true - -max_auto_add=3 -add_count=0 -success=0 - -# 1. 检查并自动补全Gemfile缺失依赖 -while [ $add_count -lt $max_auto_add ]; do - echo "[INFO] 第$((add_count+1))次尝试运行主命令: $MAIN_CMD (仅捕获缺失gem)" - $MAIN_CMD > bundle_missing_gem.log 2>&1 && success=1 && break - missing_gem=$(grep -o "Could not find [^ ]*" bundle_missing_gem.log | awk '{print $4}' | head -n1) - if [ -n "$missing_gem" ]; then - if ! grep -q "gem '$missing_gem'" "$GEMFILE_PATH"; then - echo "gem '$missing_gem'" >> "$GEMFILE_PATH" - echo "[AUTO] Gemfile已自动补全: $missing_gem" - else - echo "[WARN] Gemfile已包含 $missing_gem,但依然缺失,可能是平台或缓存问题" - fi - else - echo "[INFO] 未检测到缺失gem,或主命令已成功。" - break - fi - add_count=$((add_count+1)) - sleep 2 - echo "[WARN] 第$add_count 次自动补全后重试..." -done - -if [ $success -eq 1 ]; then - echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" - # 再次保证rubygems.org官方源始终存在(结尾) - gem sources --add https://rubygems.org || true - exit 0 -fi - -# 2. 只用 rubygems.org 官方源进行 bundle install -bundle config mirror.https://rubygems.org https://rubygems.org -bundle config set --local path "$BUNDLE_PATH" -bundle install --gemfile "$GEMFILE_PATH" -if [ $? -eq 0 ]; then - echo "[SUCCESS] 官方源 bundle install 成功" -else - echo "[FATAL] 官方源 bundle install 失败,请检查网络或Gemfile配置。" - exit 2 -fi - -# 3. 最后再执行一次主命令校验 -$MAIN_CMD || { echo "[FATAL] 主命令依然失败,请人工检查Gemfile和依赖环境。"; exit 3; } -# 再次保证rubygems.org官方源始终存在(结尾) -gem sources --add https://rubygems.org || true -echo "[SUCCESS] 所有依赖已补全,主命令执行成功。" -exit 0 \ No newline at end of file diff --git a/tag_generator.sh b/tag_generator.sh index 35529ba2..27e39182 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -15,17 +15,15 @@ if [ "$tags_length" -lt 1 ]; then next_tag="v1.0.0" else newest_tag=$(echo "$tags" | head -n 1) - # 去除已有的sky_前缀,防止重复 - base_tag=${newest_tag#sky_} - IFS='.' read -r major minor patch <<< "$base_tag" + IFS='.' read -r major minor patch <<< "$newest_tag" major="${major#v}" compare_json="" if [[ "$1" == "generate_tag" ]];then - echo "generate_tag:$newest_tag-to-master_sky\n" - compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_tag&to=master_sky") + echo "generate_tag:$newest_tag-to-master\n" + compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=$newest_tag&to=master") elif [[ "$1" == "generate_version" ]]; then - echo "generate_version:master_sky-to-$CI_COMMIT_BRANCH\n" - compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=master_sky&to=$CI_COMMIT_BRANCH") + echo "generate_version:master-to-$CI_COMMIT_BRANCH\n" + compare_json=$(curl -s --header "PRIVATE-TOKEN: $TOKEN" "$URL/projects/$PROJECT_ID/repository/compare?from=master&to=$CI_COMMIT_BRANCH") fi echo "compare_json:$compare_json\n" new_patch=$patch @@ -47,13 +45,6 @@ else done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}') next_tag="v$major.$new_minor.$new_patch" fi - -# 生成新tag名时,若在master_sky分支,加前缀sky_ -branch_name="$CI_COMMIT_BRANCH" -if [[ "$branch_name" == "master_sky" ]]; then - next_tag="sky_${next_tag}" -fi - echo "New Tag:$newest_tag;New version: $next_tag;command: $1" if [[ "$1" == "generate_tag" ]];then if [ "$next_tag" == "$newest_tag" ]; then