feat: android fastlane
This commit is contained in:
parent
e002599725
commit
f710f9d11e
@ -15,24 +15,98 @@
|
|||||||
|
|
||||||
default_platform(:android)
|
default_platform(:android)
|
||||||
|
|
||||||
|
$env_key_project_root = 'ENV_BUILD_WORKSPACE'
|
||||||
|
$env_current_branch = 'ENV_BUILD_BRANCH'
|
||||||
|
$env_current_tag = 'ENV_BUILD_TAG'
|
||||||
|
|
||||||
|
$path_dir_build = File.join(ENV[$env_key_project_root],'')
|
||||||
|
$current_branch = ENV[$env_current_branch]
|
||||||
|
$current_tag = ENV[$env_current_tag]
|
||||||
|
|
||||||
|
$path_apk_output_dir = File.join($path_dir_build, 'build/app/outputs/flutter-apk')
|
||||||
|
|
||||||
|
|
||||||
|
def print_header header
|
||||||
|
UI.message "~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
UI.message '📍 ' + header.to_s
|
||||||
|
UI.message "~~~~~~~~~~~~~~~~~~~~~~"
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_log(content)
|
||||||
|
UI.message '📠 ' + content.to_s
|
||||||
|
end
|
||||||
|
|
||||||
platform :android do
|
platform :android do
|
||||||
desc "Runs all the tests"
|
before_all do
|
||||||
lane :test do
|
print_header '🏁 Before All'
|
||||||
gradle(task: "test")
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Submit a new Beta Build to Crashlytics Beta"
|
desc "Submit a new Beta Build to Pgy Beta"
|
||||||
lane :beta do
|
lane :beta do |options|
|
||||||
gradle(task: "clean assembleRelease")
|
flavor = options[:flavor]
|
||||||
crashlytics
|
env = options[:env]
|
||||||
|
UI.user_error!("flavor is required") unless flavor
|
||||||
# sh "your_script.sh"
|
UI.user_error!("env is required") unless env
|
||||||
# You can also use other beta testing services here
|
print_log "build #{flavor} on #{env}"
|
||||||
|
build_number = Time.now.strftime("%Y%m%d%H")
|
||||||
|
print_log "BuildNo #{build_number}"
|
||||||
|
build_version = '1.0.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}"
|
||||||
|
Dir.chdir "../.." do
|
||||||
|
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
|
||||||
|
logs = changelog_from_git_commits(
|
||||||
|
pretty: '- %s (%cn)',
|
||||||
|
commits_count: 5,
|
||||||
|
merge_commit_filtering: 'exclude_merges'
|
||||||
|
)
|
||||||
|
upload_file_to_pgy(directory:$path_apk_output_dir,file_extension:".apk",logs:logs)
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Deploy a new version to the Google Play"
|
desc "Build & upload a new version to Gitlab Release"
|
||||||
lane :deploy do
|
lane :release do |options|
|
||||||
gradle(task: "clean assembleRelease")
|
flavor = options[:flavor]
|
||||||
upload_to_play_store
|
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(/^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}"
|
||||||
|
Dir.chdir "../.." do
|
||||||
|
# sh("sed", "-i", "s/1.0.0+1/#{appSdkVersion}/g", "pubspec.yaml")
|
||||||
|
# sh("sed", "-i", "s/upload_source_maps: true/upload_source_maps: false/g", "pubspec.yaml")
|
||||||
|
sh("flutter", "build", "apk", "--no-tree-shake-icons", "--release", "--flavor", "#{flavor}", "-t", "lib/main_#{flavor}.dart", "--build-number=#{build_number}", "--build-name=#{build_version}")
|
||||||
|
#sh('cp',$path_file_release_apk_default,$path_file_release_apk_copy)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lane :upload_file_to_pgy do |options|
|
||||||
|
directory = options[:directory]
|
||||||
|
file_extension = options[:file_extension]
|
||||||
|
logs = options[:logs]
|
||||||
|
UI.user_error!("Directory path is required") unless directory
|
||||||
|
UI.user_error!("File extension is required") unless file_extension
|
||||||
|
# 使用Dir.glob来查找目录下的所有.apk和.ipa文件
|
||||||
|
Dir.glob("#{directory}/*#{file_extension}").each do |file|
|
||||||
|
# 打印文件名称
|
||||||
|
puts "start upload file: #{file}"
|
||||||
|
pgyer(api_key: ENV['PGY_API_KEY'],apk:file,update_description: logs)
|
||||||
|
File.delete(file)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user