Fastfile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. 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. xcversion(version: "~> 15.0")
  71. FileUtils.rm_rf '../build'
  72. frameworks = {}
  73. ["macosx",
  74. "iphoneos",
  75. "iphonesimulator",
  76. "appletvos",
  77. "appletvsimulator",
  78. "watchos",
  79. "watchsimulator",
  80. "xros",
  81. "xrsimulator"
  82. ].each do |sdk|
  83. archive_path = "build/Kingfisher-#{sdk}.xcarchive"
  84. xcodebuild(
  85. archive: true,
  86. archive_path: archive_path,
  87. scheme: "Kingfisher",
  88. sdk: sdk,
  89. build_settings: {
  90. "BUILD_LIBRARY_FOR_DISTRIBUTION" => "YES",
  91. "SKIP_INSTALL" => "NO"
  92. }
  93. )
  94. dSYM_path = "#{Dir.pwd}/../#{archive_path}/dSYMs/Kingfisher.framework.dSYM"
  95. frameworks["#{archive_path}/Products/Library/Frameworks/Kingfisher.framework"] = { dsyms: dSYM_path }
  96. end
  97. create_xcframework(
  98. frameworks_with_dsyms: frameworks,
  99. output: "build/#{target_version}/Kingfisher.xcframework"
  100. )
  101. Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: Wei Wang (A4YJ9MRZ66)' ../build/#{target_version}/Kingfisher.xcframework")
  102. zip(
  103. path: "build/#{target_version}",
  104. output_path: "build/#{target_version}.zip"
  105. )
  106. end
  107. after_all do |lane|
  108. end
  109. error do |lane, exception|
  110. end
  111. end