Fastfile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. fastlane_version '2.82.0'
  2. require './helpers/VLC.rb'
  3. require './helpers/version.rb'
  4. #### Release ####
  5. desc 'Release a new version of VLC to the App Store'
  6. desc ''
  7. desc 'This action requires the following parameters:'
  8. desc '- platform (iOS or tvOS)'
  9. desc ''
  10. desc 'This action does the following:'
  11. desc '- Ensure a clean git status'
  12. desc '- Clear derived data'
  13. desc '- Set the version, bump the build number and commit the change'
  14. desc '- Apply the privateConstants which include the credentials'
  15. desc '- Install cocoapods dependencies'
  16. desc '- Build and sign the app'
  17. desc '- Update the changelog from the NEWS file'
  18. desc '- Push the version bump'
  19. lane :release do |options|
  20. platform = get_platform options
  21. version = get_version options
  22. ensure_git_status_clean
  23. clear_derived_data
  24. set_version_bump_build_and_commit(platform: platform, version: version)
  25. git_apply_private_constants
  26. cocoapods(repo_update: true)
  27. gym(scheme: "VLC-#{platform}")
  28. pilot(app_platform: platform == 'tvOS' ? 'appletvos' : 'ios')
  29. update_changelog(platform: platform, version: version)
  30. push_to_git_remote
  31. end
  32. desc 'Check style and conventions'
  33. lane :lint do
  34. rubocop
  35. swiftlint(executable: 'Pods/SwiftLint/swiftlint', strict: true)
  36. end
  37. lane :ci do
  38. lint
  39. xcode_select '/Applications/Xcode.app'
  40. # Ideally we have iOS 9 support here but this is not yet added
  41. # https://discuss.circleci.com/t/please-add-simulators-for-ios-9-10-to-xcode-9-image/16530
  42. xcodebuild(
  43. workspace: 'VLC.xcworkspace',
  44. scheme: 'VLC-iOS',
  45. configuration: 'Debug',
  46. clean: true,
  47. build: true,
  48. destination: 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1'
  49. )
  50. xcodebuild(
  51. workspace: 'VLC.xcworkspace',
  52. scheme: 'VLC-tvOS',
  53. configuration: 'Debug',
  54. clean: true,
  55. build: true,
  56. destination: 'platform=tvOS Simulator,name=Apple TV,OS=12.2'
  57. )
  58. test
  59. end
  60. desc 'Take screenshots'
  61. lane :screenshots do
  62. capture_screenshots(stop_after_first_error: true)
  63. frameit(white: true, path: './fastlane/screenshots')
  64. end
  65. #### Tests ####
  66. desc 'Run Tests'
  67. lane :test do
  68. cocoapods(repo_update: true)
  69. scan(scheme: 'VLC-iOS')
  70. end
  71. #### Private ####
  72. desc 'Bump and commit app version and build number'
  73. private_lane :set_version_bump_build_and_commit do |options|
  74. if options[:platform] == 'tvOS'
  75. increment_build_number_in_plist(VLC.info_plist_path[:tvOS])
  76. set_version_number_in_plist(VLC.info_plist_path[:tvOS], options[:version])
  77. elsif options[:platform] == 'iOS'
  78. increment_build_number_in_plist(VLC.info_plist_path[:iOS])
  79. set_version_number_in_plist(VLC.info_plist_path[:iOS], options[:version])
  80. end
  81. commit_version_bump(message: 'Version Bump by fastlane', force: true)
  82. end
  83. desc 'Update changelog in iTunes Connect with the content from Docs/NEWS'
  84. private_lane :update_changelog do |options|
  85. platform = options[:platform]
  86. version = options[:version]
  87. regex = /## #{platform} \[#{version}\](.*?)^##/m
  88. if (match = File.read('../Docs/NEWS').match(regex))
  89. changelog = match.captures
  90. set_changelog(app_identifier: 'org.videolan.vlc-ios',
  91. username: '*',
  92. changelog: changelog.first.strip,
  93. team_name: 'VideoLAN',
  94. platform: platform == 'tvOS' ? 'appletvos' : 'ios')
  95. else
  96. puts("⚠️ Changelog not found for: #{platform} [#{version}]")
  97. exit 1
  98. end
  99. end
  100. desc 'Apply privateConstants patch including credentials'
  101. private_lane :git_apply_private_constants do
  102. Dir.chdir('..') do
  103. sh('xcrun git apply 0001-privateConstants.patch')
  104. end
  105. end
  106. desc 'Return the platform received as parameter, or ask for it if missing'
  107. private_lane :get_platform do |options|
  108. platform = options[:platform]
  109. platform = prompt(text: 'Platform [iOS, tvOS]: ') if !platform || platform.empty?
  110. if platform != 'iOS' && platform != 'tvOS'
  111. puts("⚠️ Platform '#{platform}' not supported")
  112. exit 1
  113. end
  114. platform
  115. end
  116. desc 'Return the version received as parameter, or ask for it if missing'
  117. private_lane :get_version do |options|
  118. version = options[:version]
  119. version = ask('Enter a new version number: ') if !version || version.empty?
  120. version
  121. end