Fastfile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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")
  7. test(destination: "platform=iOS Simulator,name=iPhone 15")
  8. test(destination: "platform=tvOS Simulator,name=Apple TV")
  9. build(destination: "platform=watchOS Simulator,name=Apple Watch Series 9 (41mm)")
  10. end
  11. lane :test_ci do
  12. if ENV["DESTINATION"].include? "watchOS" then
  13. build(destination: ENV["DESTINATION"])
  14. else
  15. test(destination: ENV["DESTINATION"])
  16. end
  17. end
  18. lane :test do |options|
  19. scan(
  20. scheme: "Kingfisher",
  21. clean: true,
  22. xcargs: "SWIFT_VERSION=5.0",
  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=5.0",
  32. destination: options[:destination]
  33. )
  34. end
  35. desc "Lint"
  36. lane :lint do
  37. pod_lib_lint
  38. spm
  39. end
  40. desc "Release new version"
  41. lane :release do |options|
  42. target_version = options[:version]
  43. raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
  44. ensure_git_branch
  45. ensure_git_status_clean
  46. skip_tests = options[:skip_tests]
  47. tests unless skip_tests
  48. lint
  49. sync_build_number_to_git
  50. increment_version_number(version_number: target_version)
  51. version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
  52. log = extract_current_change_log(version: target_version)
  53. release_log = update_change_log(log: log)
  54. git_commit_all(message: "Bump version to #{target_version}")
  55. Actions.sh("git tag -s #{target_version} -m ''")
  56. push_to_git_remote
  57. xcframework(version: target_version)
  58. set_github_release(
  59. repository_name: "onevcat/Kingfisher",
  60. api_token: ENV['GITHUB_TOKEN'],
  61. name: release_log[:title],
  62. tag_name: target_version,
  63. description: release_log[:text],
  64. upload_assets: ["build/Kingfisher-#{target_version}.zip"]
  65. )
  66. pod_push
  67. end
  68. lane :xcframework do |options|
  69. target_version = "Kingfisher-#{options[:version]}"
  70. swift_version = options[:swift_version] || "5.0"
  71. xcode_version = options[:xcode_version] || "16.0"
  72. xcodes(version: xcode_version, select_for_current_build_only: true)
  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. "SWIFT_VERSION" => swift_version
  95. }
  96. )
  97. dSYM_path = "#{Dir.pwd}/../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  98. frameworks["#{archive_path}/Products/Library/Frameworks/Kingfisher.framework"] = { dsyms: dSYM_path }
  99. end
  100. create_xcframework(
  101. frameworks_with_dsyms: frameworks,
  102. output: "build/#{target_version}/Kingfisher.xcframework"
  103. )
  104. Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: Wei Wang (A4YJ9MRZ66)' ../build/#{target_version}/Kingfisher.xcframework")
  105. zip(
  106. path: "build/#{target_version}",
  107. output_path: "build/#{target_version}.zip",
  108. symlinks: true
  109. )
  110. end
  111. before_all do |lane|
  112. xcode_version = ENV["XCODE_VERSION"] || "16.0"
  113. xcodes(version: xcode_version, select_for_current_build_only: true)
  114. end
  115. after_all do |lane|
  116. end
  117. error do |lane, exception|
  118. end
  119. end