fix:调整ci

This commit is contained in:
liyi 2025-05-17 10:17:43 +08:00
parent f42659c8ac
commit 46bec40eb7
2 changed files with 111 additions and 44 deletions

View File

@ -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

View File

@ -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",
}
}