Fastfile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 8", swift_version: "5.0")
  8. test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "5.0")
  9. test(destination: "platform=macOS", swift_version: "4.2")
  10. test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "4.2")
  11. test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "4.2")
  12. test(destination: "platform=macOS", swift_version: "4.0")
  13. test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "4.0")
  14. test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "4.0")
  15. end
  16. lane :test do |options|
  17. _test(options)
  18. end
  19. private_lane :_test do |options|
  20. scan(
  21. scheme: "Kingfisher",
  22. clean: true,
  23. xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
  24. destination: options[:destination]
  25. )
  26. end
  27. lane :test_ci do
  28. test(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
  29. end
  30. desc "Lint"
  31. lane :lint do
  32. carthage(command: "build", no_skip_current: true)
  33. pod_lib_lint
  34. end
  35. desc "Release new version"
  36. lane :release do |options|
  37. target_version = options[:version]
  38. raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
  39. ensure_git_branch
  40. ensure_git_status_clean
  41. tests
  42. lint
  43. sync_build_number_to_git
  44. increment_version_number(version_number: target_version)
  45. version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
  46. log = extract_current_change_log(version: target_version)
  47. release_log = update_change_log(log: log)
  48. doc(version: target_version)
  49. git_commit_all(message: "Bump version to #{target_version}")
  50. Actions.sh("git tag -s #{target_version} -m ''")
  51. push_to_git_remote
  52. xcframework
  53. set_github_release(
  54. repository_name: "onevcat/Kingfisher",
  55. api_token: ENV['GITHUB_TOKEN'],
  56. name: release_log[:title],
  57. tag_name: target_version,
  58. description: release_log[:text],
  59. upload_assets: ["build/Kingfisher-#{target_version}.zip"]
  60. )
  61. pod_push
  62. end
  63. lane :podpush do
  64. pod_push
  65. end
  66. lane :doc do |options|
  67. target_version = options[:version]
  68. Actions.sh("cd .. && jazzy \
  69. --clean \
  70. -x USE_SWIFT_RESPONSE_FILE=NO \
  71. --author \"Wei Wang\" \
  72. --author_url https://onevcat.com \
  73. --github_url https://github.com/onevcat/Kingfisher \
  74. --github-file-prefix https://github.com/onevcat/Kingfisher/tree/#{target_version} \
  75. --module-version #{target_version} \
  76. --module Kingfisher \
  77. --root-url http://onevcat.github.io/Kingfisher/ \
  78. --output docs/ \
  79. --theme fullwidth")
  80. end
  81. lane :xcframework do |options|
  82. target_version = "Kingfisher-#{options[:version]}"
  83. supporting_root = "../build/#{target_version}/Supporting Files"
  84. xcversion(version: "~> 11.0")
  85. FileUtils.rm_rf '../build'
  86. frameworks = []
  87. ["macosx",
  88. "iphoneos",
  89. "iphonesimulator",
  90. "appletvos",
  91. "appletvsimulator",
  92. "watchos",
  93. "watchsimulator"
  94. ].each do |sdk|
  95. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  96. xcodebuild(
  97. archive: true,
  98. archive_path: archive_path,
  99. scheme: "Kingfisher",
  100. sdk: sdk,
  101. build_settings: {
  102. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  103. "SKIP_INSTALL" => "NO"
  104. }
  105. )
  106. frameworks.push("#{archive_path}/Products/Library/Frameworks/Kingfisher.framework")
  107. dSYM_path = "../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  108. FileUtils.mkdir_p("#{supporting_root}/#{sdk}/dSYMs/")
  109. FileUtils.cp_r(dSYM_path, "#{supporting_root}/#{sdk}/dSYMs/Kingfisher.framework.dSYM")
  110. bitcode_symbol_map_path = "../#{archive_path}/BCSymbolMaps/"
  111. if Dir.exist?(bitcode_symbol_map_path)
  112. FileUtils.mkdir_p("#{supporting_root}/#{sdk}/BCSymbolMaps/")
  113. FileUtils.cp_r(bitcode_symbol_map_path, "#{supporting_root}/#{sdk}")
  114. end
  115. end
  116. # `xcodebuild` action in fastlane does not support `-create-xcframework` arg yet.
  117. # Change it back to use fastlane action later when it is prepared.
  118. framework_args = frameworks.map { |framework_path| "-framework '#{framework_path}'"}
  119. args = "-create-xcframework #{framework_args.join(" ")} -output 'build/#{target_version}/Kingfisher.xcframework'"
  120. Dir.chdir("..") do
  121. Action.sh "xcodebuild #{args}"
  122. end
  123. zip(
  124. path: "build/#{target_version}",
  125. output_path: "build/#{target_version}.zip"
  126. )
  127. end
  128. after_all do |lane|
  129. end
  130. error do |lane, exception|
  131. end
  132. end