Fastfile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. # Allows warnings temporarily before CocoaPods 1.13.0 (visionOS support) and Xcode 15.0
  38. # pod_lib_lint
  39. pod_lib_lint(allow_warnings: true)
  40. spm
  41. end
  42. desc "Release new version"
  43. lane :release do |options|
  44. target_version = options[:version]
  45. raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
  46. ensure_git_branch
  47. ensure_git_status_clean
  48. skip_tests = options[:skip_tests]
  49. tests unless skip_tests
  50. lint
  51. sync_build_number_to_git
  52. increment_version_number(version_number: target_version)
  53. version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
  54. log = extract_current_change_log(version: target_version)
  55. release_log = update_change_log(log: log)
  56. git_commit_all(message: "Bump version to #{target_version}")
  57. Actions.sh("git tag -s #{target_version} -m ''")
  58. push_to_git_remote
  59. xcframework(version: target_version)
  60. set_github_release(
  61. repository_name: "onevcat/Kingfisher",
  62. api_token: ENV['GITHUB_TOKEN'],
  63. name: release_log[:title],
  64. tag_name: target_version,
  65. description: release_log[:text],
  66. upload_assets: ["build/Kingfisher-#{target_version}.zip"]
  67. )
  68. pod_push(allow_warnings: true)
  69. end
  70. lane :xcframework do |options|
  71. target_version = "Kingfisher-#{options[:version]}"
  72. xcversion(version: "~> 15.0")
  73. FileUtils.rm_rf '../build'
  74. frameworks = {}
  75. ["macosx",
  76. "iphoneos",
  77. "iphonesimulator",
  78. "appletvos",
  79. "appletvsimulator",
  80. "watchos",
  81. "watchsimulator",
  82. "xros",
  83. "xrsimulator"
  84. ].each do |sdk|
  85. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  86. xcodebuild(
  87. archive: true,
  88. archive_path: archive_path,
  89. scheme: "Kingfisher",
  90. sdk: sdk,
  91. build_settings: {
  92. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  93. "SKIP_INSTALL" => "NO"
  94. }
  95. )
  96. dSYM_path = "#{Dir.pwd}/../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  97. frameworks["#{archive_path}/Products/Library/Frameworks/Kingfisher.framework"] = { dsyms: dSYM_path }
  98. end
  99. create_xcframework(
  100. frameworks_with_dsyms: frameworks,
  101. output: "build/#{target_version}/Kingfisher.xcframework"
  102. )
  103. Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: Wei Wang (A4YJ9MRZ66)' ../build/#{target_version}/Kingfisher.xcframework")
  104. zip(
  105. path: "build/#{target_version}",
  106. output_path: "build/#{target_version}.zip"
  107. )
  108. end
  109. after_all do |lane|
  110. end
  111. error do |lane, exception|
  112. end
  113. end