Fastfile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. fastlane_version "1.37.0"
  2. default_platform :ios
  3. platform :ios do
  4. desc "Runs all the tests"
  5. lane :tests do
  6. test(destination: "platform=macOS", swift_version: "5.0")
  7. test(destination: "platform=iOS Simulator,name=iPhone 12", swift_version: "5.0")
  8. test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "5.0")
  9. build(destination: "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm", swift_version: "5.0")
  10. end
  11. lane :test_ci do
  12. if ENV["DESTINATION"].include? "watchOS" then
  13. build(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
  14. else
  15. test(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
  16. end
  17. end
  18. lane :test do |options|
  19. scan(
  20. scheme: "Kingfisher",
  21. clean: true,
  22. xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
  23. destination: options[:destination]
  24. )
  25. end
  26. lane :build do |options|
  27. gym(
  28. workspace: "Kingfisher.xcworkspace",
  29. configuration: "Debug",
  30. scheme: "Kingfisher",
  31. xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
  32. destination: options[:destination]
  33. )
  34. end
  35. desc "Lint"
  36. lane :lint do
  37. # carthage(command: "build", no_skip_current: true, platform: "iOS")
  38. pod_lib_lint
  39. spm
  40. end
  41. desc "Release new version"
  42. lane :release do |options|
  43. target_version = options[:version]
  44. raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
  45. ensure_git_branch
  46. ensure_git_status_clean
  47. skip_tests = options[:skip_tests]
  48. tests unless skip_tests
  49. lint
  50. sync_build_number_to_git
  51. increment_version_number(version_number: target_version)
  52. version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
  53. log = extract_current_change_log(version: target_version)
  54. release_log = update_change_log(log: log)
  55. git_commit_all(message: "Bump version to #{target_version}")
  56. Actions.sh("git tag -s #{target_version} -m ''")
  57. push_to_git_remote
  58. xcframework(version: target_version)
  59. set_github_release(
  60. repository_name: "onevcat/Kingfisher",
  61. api_token: ENV['GITHUB_TOKEN'],
  62. name: release_log[:title],
  63. tag_name: target_version,
  64. description: release_log[:text],
  65. upload_assets: ["build/Kingfisher-#{target_version}.zip"]
  66. )
  67. pod_push
  68. end
  69. lane :podpush do
  70. pod_push
  71. end
  72. lane :xcframework do |options|
  73. target_version = "Kingfisher-#{options[:version]}"
  74. supporting_root = "../build/#{target_version}/Supporting Files"
  75. xcversion(version: "~> 12.0")
  76. FileUtils.rm_rf '../build'
  77. frameworks = []
  78. ["macosx",
  79. "iphoneos",
  80. "iphonesimulator",
  81. "appletvos",
  82. "appletvsimulator",
  83. "watchos",
  84. "watchsimulator"
  85. ].each do |sdk|
  86. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  87. xcodebuild(
  88. archive: true,
  89. archive_path: archive_path,
  90. scheme: "Kingfisher",
  91. sdk: sdk,
  92. build_settings: {
  93. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  94. "SKIP_INSTALL" => "NO"
  95. }
  96. )
  97. frameworks.push("#{archive_path}/Products/Library/Frameworks/Kingfisher.framework")
  98. dSYM_path = "../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  99. FileUtils.mkdir_p("#{supporting_root}/#{sdk}/dSYMs/")
  100. FileUtils.cp_r(dSYM_path, "#{supporting_root}/#{sdk}/dSYMs/Kingfisher.framework.dSYM")
  101. bitcode_symbol_map_path = "../#{archive_path}/BCSymbolMaps/"
  102. if Dir.exist?(bitcode_symbol_map_path)
  103. FileUtils.mkdir_p("#{supporting_root}/#{sdk}/BCSymbolMaps/")
  104. FileUtils.cp_r(bitcode_symbol_map_path, "#{supporting_root}/#{sdk}")
  105. end
  106. end
  107. # `xcodebuild` action in fastlane does not support `-create-xcframework` arg yet.
  108. # Change it back to use fastlane action later when it is prepared.
  109. framework_args = frameworks.map { |framework_path| "-framework '#{framework_path}'"}
  110. args = "-create-xcframework #{framework_args.join(" ")} -output 'build/#{target_version}/Kingfisher.xcframework'"
  111. Dir.chdir("..") do
  112. Action.sh "xcodebuild #{args}"
  113. end
  114. zip(
  115. path: "build/#{target_version}",
  116. output_path: "build/#{target_version}.zip"
  117. )
  118. end
  119. after_all do |lane|
  120. end
  121. error do |lane, exception|
  122. end
  123. end