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