Fastfile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 14", 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 8 (41mm)", 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: "~> 15.0")
  76. FileUtils.rm_rf '../build'
  77. frameworks = {}
  78. ["macosx",
  79. "iphoneos",
  80. "iphonesimulator",
  81. "appletvos",
  82. "appletvsimulator",
  83. "watchos",
  84. "watchsimulator",
  85. "xros",
  86. "xrsimulator"
  87. ].each do |sdk|
  88. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  89. xcodebuild(
  90. archive: true,
  91. archive_path: archive_path,
  92. scheme: "Kingfisher",
  93. sdk: sdk,
  94. build_settings: {
  95. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  96. "SKIP_INSTALL" => "NO"
  97. }
  98. )
  99. dSYM_path = "#{Dir.pwd}/../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  100. frameworks["#{archive_path}/Products/Library/Frameworks/Kingfisher.framework"] = { dsyms: dSYM_path }
  101. end
  102. create_xcframework(
  103. frameworks_with_dsyms: frameworks,
  104. output: "build/#{target_version}/Kingfisher.xcframework"
  105. )
  106. zip(
  107. path: "build/#{target_version}",
  108. output_path: "build/#{target_version}.zip"
  109. )
  110. end
  111. after_all do |lane|
  112. end
  113. error do |lane, exception|
  114. end
  115. end