Fastfile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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
  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. xcversion(version: '9.2.0')
  40. xcode_select '/Applications/Xcode.app'
  41. # Ideally we have iOS 9 support here but this is not yet added
  42. # https://discuss.circleci.com/t/please-add-simulators-for-ios-9-10-to-xcode-9-image/16530
  43. xcodebuild(
  44. workspace: 'VLC.xcworkspace',
  45. scheme: 'VLC-iOS',
  46. configuration: 'Debug',
  47. clean: true,
  48. build: true,
  49. destination: 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1'
  50. )
  51. xcodebuild(
  52. workspace: 'VLC.xcworkspace',
  53. scheme: 'VLC-tvOS',
  54. configuration: 'Debug',
  55. clean: true,
  56. build: true,
  57. destination: 'platform=tvOS Simulator,name=Apple TV 1080p,OS=10.2'
  58. )
  59. test
  60. end
  61. #### Tests ####
  62. desc 'Run Tests'
  63. lane :test do
  64. cocoapods(repo_update: true)
  65. scan(scheme: 'VLC-iOS')
  66. end
  67. #### Private ####
  68. desc 'Bump and commit app version and build number'
  69. private_lane :set_version_bump_build_and_commit do |options|
  70. if options[:platform] == 'tvOS'
  71. increment_build_number_in_plist(VLC.info_plist_path[:tvOS])
  72. set_version_number_in_plist(VLC.info_plist_path[:tvOS], options[:version])
  73. elsif options[:platform] == 'iOS'
  74. increment_build_number_in_plist(VLC.info_plist_path[:iOS])
  75. increment_build_number_in_plist(VLC.info_plist_path[:watchKitExtension])
  76. increment_build_number_in_plist(VLC.info_plist_path[:watchOS])
  77. set_version_number_in_plist(VLC.info_plist_path[:iOS], options[:version])
  78. set_version_number_in_plist(VLC.info_plist_path[:watchKitExtension], options[:version])
  79. set_version_number_in_plist(VLC.info_plist_path[:watchOS], 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. # Splits the News by -------- get out the top notes
  87. changelog = File.read('../Docs/NEWS').split('-----------')[1].split('-----------').first
  88. temp_changelog = changelog.split(platform)
  89. temp_changelog = changelog.split('tvOS') if temp_changelog.count <= 1
  90. changelog = temp_changelog[0..-2].join.strip
  91. set_changelog(app_identifier: 'org.videolan.vlc-ios', changelog: changelog, username: '*', team_name: 'VideoLAN')
  92. end
  93. desc 'Apply privateConstants patch including credentials'
  94. private_lane :git_apply_private_constants do
  95. Dir.chdir('..') do
  96. gitapply = `xcrun git apply 0001-privateConstants.patch`
  97. if gitapply != ''
  98. puts("⚠️ There are conflicts. Please resolve the conflicts and update the privateConstants.patch before continuing.\n#{gitapply}")
  99. exit 1
  100. end
  101. end
  102. end
  103. desc 'Return the platform received as parameter, or ask for it if missing'
  104. private_lane :get_platform do |options|
  105. platform = options[:platform]
  106. platform = prompt(text: 'Platform [iOS, tvOS]: ') if !platform || platform.empty?
  107. if platform != 'iOS' && platform != 'tvOS'
  108. puts("⚠️ Platform '#{platform}' not supported")
  109. exit 1
  110. end
  111. platform
  112. end
  113. desc 'Return the version received as parameter, or ask for it if missing'
  114. private_lane :get_version do |options|
  115. version = options[:version]
  116. version = ask('Enter a new version number: ') if !version || version.empty?
  117. version
  118. end