Fastfile 4.24 KB
Newer Older
1 2
fastlane_version '2.82.0'

3 4 5
require './helpers/VLC.rb'
require './helpers/version.rb'

6 7 8 9 10 11 12 13 14
#### Release ####

desc 'Release a new version of VLC to the App Store'
desc ''
desc 'This action requires the following parameters:'
desc '- platform (iOS or tvOS)'
desc ''
desc 'This action does the following:'
desc '- Ensure a clean git status'
15
desc '- Clear derived data'
16
desc '- Set the version, bump the build number and commit the change'
17
desc '- Apply the privateConstants which include the credentials'
18
desc '- Install cocoapods dependencies'
19 20 21 22
desc '- Build and sign the app'
desc '- Update the changelog from the NEWS file'
desc '- Push the version bump'
lane :release do |options|
23 24 25 26 27 28 29 30 31
  platform = get_platform options
  version = get_version options
  ensure_git_status_clean
  clear_derived_data
  set_version_bump_build_and_commit(platform: platform, version: version)
  git_apply_private_constants
  cocoapods(repo_update: true)
  gym(scheme: "VLC-#{platform}")
  pilot(app_platform: platform == 'tvOS' ? 'appletvos' : 'ios')
32
  update_changelog(platform: platform, version: version)
33 34 35 36 37 38 39
  push_to_git_remote
end

desc 'Check style and conventions'
lane :lint do
  rubocop
  swiftlint(executable: 'Pods/SwiftLint/swiftlint', strict: true)
40 41
end

42
lane :ci do
43 44 45 46
  lint
  xcode_select '/Applications/Xcode.app'
  # Ideally we have iOS 9 support here but this is not yet added
  # https://discuss.circleci.com/t/please-add-simulators-for-ios-9-10-to-xcode-9-image/16530
47
  xcodebuild(
48 49 50
    workspace: 'VLC.xcworkspace',
    scheme: 'VLC-iOS',
    configuration: 'Debug',
51 52
    clean: true,
    build: true,
53
    destination: 'platform=iOS Simulator,name=iPhone 6s,OS=10.3.1'
54 55
  )
  xcodebuild(
56 57 58
    workspace: 'VLC.xcworkspace',
    scheme: 'VLC-tvOS',
    configuration: 'Debug',
59 60
    clean: true,
    build: true,
Soomin Lee's avatar
Soomin Lee committed
61
    destination: 'platform=tvOS Simulator,name=Apple TV,OS=11.2'
62
  )
63
  test
64 65
end

66 67 68 69 70 71
desc 'Take screenshots'
lane :screenshots do
  capture_screenshots(stop_after_first_error: true)
  frameit(white: true, path: './fastlane/screenshots')
end

72 73 74 75 76 77 78 79
#### Tests ####

desc 'Run Tests'
lane :test do
  cocoapods(repo_update: true)
  scan(scheme: 'VLC-iOS')
end

80
#### Private ####
81

82
desc 'Bump and commit app version and build number'
83
private_lane :set_version_bump_build_and_commit do |options|
84
  if options[:platform] == 'tvOS'
85 86
    increment_build_number_in_plist(VLC.info_plist_path[:tvOS])
    set_version_number_in_plist(VLC.info_plist_path[:tvOS], options[:version])
87
  elsif options[:platform] == 'iOS'
88 89
    increment_build_number_in_plist(VLC.info_plist_path[:iOS])
    set_version_number_in_plist(VLC.info_plist_path[:iOS], options[:version])
90 91
  end

92
  commit_version_bump(message: 'Version Bump by fastlane', force: true)
93 94
end

95 96
desc 'Update changelog in iTunes Connect with the content from Docs/NEWS'
private_lane :update_changelog do |options|
97
  platform = options[:platform]
98 99 100 101 102 103 104 105 106 107 108 109 110 111
  version = options[:version]

  regex = /## #{platform} \[#{version}\](.*?)^##/m
  if (match = File.read('../Docs/NEWS').match(regex))
    changelog = match.captures
    set_changelog(app_identifier: 'org.videolan.vlc-ios',
                  changelog: changelog,
                  username: '*',
                  team: 'VideoLAN',
                  platform: platform == 'tvOS' ? 'appletvos' : 'ios')
  else
    puts("⚠️  Changelog not found for: #{platform} [#{version}]")
    exit 1
  end
112 113
end

114 115 116 117 118 119 120 121
desc 'Apply privateConstants patch including credentials'
private_lane :git_apply_private_constants do
  Dir.chdir('..') do
    gitapply = `xcrun git apply 0001-privateConstants.patch`
    if gitapply != ''
      puts("⚠️  There are conflicts. Please resolve the conflicts and update the privateConstants.patch before continuing.\n#{gitapply}")
      exit 1
    end
122
  end
123
end
124

125 126 127
desc 'Return the platform received as parameter, or ask for it if missing'
private_lane :get_platform do |options|
  platform = options[:platform]
128
  platform = prompt(text: 'Platform [iOS, tvOS]: ') if !platform || platform.empty?
129 130 131
  if platform != 'iOS' && platform != 'tvOS'
    puts("⚠️  Platform '#{platform}' not supported")
    exit 1
132
  end
133
  platform
134
end
135 136 137 138

desc 'Return the version received as parameter, or ask for it if missing'
private_lane :get_version do |options|
  version = options[:version]
139
  version = ask('Enter a new version number: ') if !version || version.empty?
140 141
  version
end