Fastfile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. git_apply_fake_VolumeSlider
  63. capture_screenshots(stop_after_first_error: true)
  64. frameit(white: true, path: './fastlane/screenshots')
  65. end
  66. desc 'Apply fakeVolumeSlider patch'
  67. private_lane :git_apply_fake_VolumeSlider do
  68. sh('xcrun git apply 0001-fakeVolumeSlider.patch')
  69. end
  70. #### Tests ####
  71. desc 'Run Tests'
  72. lane :test do
  73. cocoapods(repo_update: true)
  74. scan(scheme: 'VLC-iOS-Tests')
  75. scan(scheme: 'VLC-iOS-UITests')
  76. end
  77. #### Private ####
  78. desc 'Bump and commit app version and build number'
  79. private_lane :set_version_bump_build_and_commit do |options|
  80. if options[:platform] == 'tvOS'
  81. increment_build_number_in_plist(VLC.info_plist_path[:tvOS])
  82. set_version_number_in_plist(VLC.info_plist_path[:tvOS], options[:version])
  83. elsif options[:platform] == 'iOS'
  84. increment_build_number_in_plist(VLC.info_plist_path[:iOS])
  85. set_version_number_in_plist(VLC.info_plist_path[:iOS], options[:version])
  86. end
  87. commit_version_bump(message: 'Version Bump by fastlane', force: true)
  88. end
  89. desc 'Update changelog in iTunes Connect with the content from Docs/NEWS'
  90. private_lane :update_changelog do |options|
  91. platform = options[:platform]
  92. version = options[:version]
  93. regex = /## #{platform} \[#{version}\](.*?)^##/m
  94. if (match = File.read('../Docs/NEWS').match(regex))
  95. changelog = match.captures
  96. set_changelog(app_identifier: 'org.videolan.vlc-ios',
  97. username: '*',
  98. changelog: changelog.first.strip,
  99. team_name: 'VideoLAN',
  100. platform: platform == 'tvOS' ? 'appletvos' : 'ios')
  101. else
  102. puts("⚠️ Changelog not found for: #{platform} [#{version}]")
  103. exit 1
  104. end
  105. end
  106. desc 'Apply privateConstants patch including credentials'
  107. private_lane :git_apply_private_constants do
  108. Dir.chdir('..') do
  109. sh('xcrun git apply 0001-privateConstants.patch')
  110. end
  111. end
  112. desc 'Return the platform received as parameter, or ask for it if missing'
  113. private_lane :get_platform do |options|
  114. platform = options[:platform]
  115. platform = prompt(text: 'Platform [iOS, tvOS]: ') if !platform || platform.empty?
  116. if platform != 'iOS' && platform != 'tvOS'
  117. puts("⚠️ Platform '#{platform}' not supported")
  118. exit 1
  119. end
  120. platform
  121. end
  122. desc 'Return the version received as parameter, or ask for it if missing'
  123. private_lane :get_version do |options|
  124. version = options[:version]
  125. version = ask('Enter a new version number: ') if !version || version.empty?
  126. version
  127. end