Fastfile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 14")
  8. test(destination: "platform=tvOS Simulator,name=Apple TV")
  9. build(destination: "platform=watchOS Simulator,name=Apple Watch Series 8 (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. destination: options[:destination]
  23. )
  24. end
  25. lane :build do |options|
  26. gym(
  27. workspace: "Kingfisher.xcworkspace",
  28. configuration: "Debug",
  29. scheme: "Kingfisher",
  30. destination: options[:destination]
  31. )
  32. end
  33. desc "Lint"
  34. lane :lint do
  35. pod_lib_lint
  36. spm
  37. end
  38. desc "Release new version"
  39. lane :release do |options|
  40. target_version = options[:version]
  41. raise "The version is missed. Use `fastlane release version:{version_number}`.`" if target_version.nil?
  42. ensure_git_branch
  43. ensure_git_status_clean
  44. skip_tests = options[:skip_tests]
  45. tests unless skip_tests
  46. lint
  47. sync_build_number_to_git
  48. increment_version_number(version_number: target_version)
  49. version_bump_podspec(path: "Kingfisher.podspec", version_number: target_version)
  50. log = extract_current_change_log(version: target_version)
  51. release_log = update_change_log(log: log)
  52. git_commit_all(message: "Bump version to #{target_version}")
  53. Actions.sh("git tag -s #{target_version} -m ''")
  54. push_to_git_remote
  55. xcframework(version: target_version)
  56. set_github_release(
  57. repository_name: "onevcat/Kingfisher",
  58. api_token: ENV['GITHUB_TOKEN'],
  59. name: release_log[:title],
  60. tag_name: target_version,
  61. description: release_log[:text],
  62. upload_assets: ["build/Kingfisher-#{target_version}.zip"]
  63. )
  64. pod_push
  65. end
  66. lane :xcframework do |options|
  67. target_version = "Kingfisher-#{options[:version]}"
  68. FileUtils.rm_rf '../build'
  69. frameworks = {}
  70. ["macosx",
  71. "iphoneos",
  72. "iphonesimulator",
  73. "appletvos",
  74. "appletvsimulator",
  75. "watchos",
  76. "watchsimulator",
  77. "xros",
  78. "xrsimulator"
  79. ].each do |sdk|
  80. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  81. xcodebuild(
  82. archive: true,
  83. archive_path: archive_path,
  84. scheme: "Kingfisher",
  85. sdk: sdk,
  86. build_settings: {
  87. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  88. "SKIP_INSTALL" => "NO"
  89. }
  90. )
  91. dSYM_path = "#{Dir.pwd}/../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  92. frameworks["#{archive_path}/Products/Library/Frameworks/Kingfisher.framework"] = { dsyms: dSYM_path }
  93. end
  94. create_xcframework(
  95. frameworks_with_dsyms: frameworks,
  96. output: "build/#{target_version}/Kingfisher.xcframework"
  97. )
  98. Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: Wei Wang (A4YJ9MRZ66)' ../build/#{target_version}/Kingfisher.xcframework")
  99. zip(
  100. path: "build/#{target_version}",
  101. output_path: "build/#{target_version}.zip",
  102. symlinks: true
  103. )
  104. end
  105. before_all do |lane|
  106. xcode_version = ENV["XCODE_VERSION"] || "15.3"
  107. xcodes(version: xcode_version, select_for_current_build_only: true)
  108. end
  109. after_all do |lane|
  110. end
  111. error do |lane, exception|
  112. end
  113. end