fastlane 2.130.0 → 2.135.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +64 -64
  3. data/cert/lib/cert/module.rb +2 -0
  4. data/cert/lib/cert/options.rb +6 -0
  5. data/cert/lib/cert/runner.rb +17 -11
  6. data/fastlane/lib/fastlane/action.rb +1 -1
  7. data/fastlane/lib/fastlane/actions/actions_helper.rb +1 -1
  8. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +11 -3
  9. data/fastlane/lib/fastlane/actions/carthage.rb +7 -0
  10. data/fastlane/lib/fastlane/actions/cocoapods.rb +24 -2
  11. data/fastlane/lib/fastlane/actions/copy_artifacts.rb +1 -1
  12. data/fastlane/lib/fastlane/actions/deploygate.rb +1 -1
  13. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
  14. data/fastlane/lib/fastlane/actions/docs/sync_code_signing.md +26 -5
  15. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +26 -2
  16. data/fastlane/lib/fastlane/actions/download_dsyms.rb +34 -6
  17. data/fastlane/lib/fastlane/actions/download_from_play_store.rb +1 -1
  18. data/fastlane/lib/fastlane/actions/ensure_env_vars.rb +58 -0
  19. data/fastlane/lib/fastlane/actions/get_version_number.rb +12 -3
  20. data/fastlane/lib/fastlane/actions/gradle.rb +11 -1
  21. data/fastlane/lib/fastlane/actions/onesignal.rb +59 -29
  22. data/fastlane/lib/fastlane/actions/pod_push.rb +10 -1
  23. data/fastlane/lib/fastlane/actions/register_devices.rb +1 -1
  24. data/fastlane/lib/fastlane/actions/resign.rb +2 -2
  25. data/fastlane/lib/fastlane/actions/sonar.rb +16 -0
  26. data/fastlane/lib/fastlane/actions/testfairy.rb +1 -1
  27. data/fastlane/lib/fastlane/actions/update_fastlane.rb +9 -49
  28. data/fastlane/lib/fastlane/actions/update_keychain_access_groups.rb +94 -0
  29. data/fastlane/lib/fastlane/environment_printer.rb +9 -3
  30. data/fastlane/lib/fastlane/fast_file.rb +10 -4
  31. data/fastlane/lib/fastlane/helper/crashlytics_helper.rb +1 -1
  32. data/fastlane/lib/fastlane/lane_manager.rb +1 -1
  33. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +12 -2
  34. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +1 -0
  35. data/fastlane/lib/fastlane/runner.rb +2 -2
  36. data/fastlane/lib/fastlane/setup/setup_android.rb +1 -1
  37. data/fastlane/lib/fastlane/swift_fastlane_api_generator.rb +10 -3
  38. data/fastlane/lib/fastlane/swift_fastlane_function.rb +72 -3
  39. data/fastlane/lib/fastlane/swift_runner_upgrader.rb +4 -0
  40. data/fastlane/lib/fastlane/version.rb +1 -1
  41. data/fastlane/swift/Actions.swift +4 -0
  42. data/fastlane/swift/Deliverfile.swift +1 -1
  43. data/fastlane/swift/DeliverfileProtocol.swift +121 -1
  44. data/fastlane/swift/Fastlane.swift +3932 -18
  45. data/fastlane/swift/Gymfile.swift +1 -1
  46. data/fastlane/swift/GymfileProtocol.swift +81 -1
  47. data/fastlane/swift/Matchfile.swift +1 -1
  48. data/fastlane/swift/MatchfileProtocol.swift +65 -1
  49. data/fastlane/swift/Plugins.swift +4 -0
  50. data/fastlane/swift/Precheckfile.swift +1 -1
  51. data/fastlane/swift/PrecheckfileProtocol.swift +15 -2
  52. data/fastlane/swift/Scanfile.swift +1 -1
  53. data/fastlane/swift/ScanfileProtocol.swift +109 -1
  54. data/fastlane/swift/Screengrabfile.swift +1 -1
  55. data/fastlane/swift/ScreengrabfileProtocol.swift +39 -2
  56. data/fastlane/swift/Snapshotfile.swift +1 -1
  57. data/fastlane/swift/SnapshotfileProtocol.swift +71 -1
  58. data/fastlane_core/lib/fastlane_core/configuration/commander_generator.rb +3 -3
  59. data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +1 -1
  60. data/fastlane_core/lib/fastlane_core/device_manager.rb +1 -1
  61. data/fastlane_core/lib/fastlane_core/helper.rb +1 -1
  62. data/fastlane_core/lib/fastlane_core/itunes_transporter.rb +1 -3
  63. data/fastlane_core/lib/fastlane_core/swag.rb +1 -1
  64. data/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb +1 -1
  65. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +3 -2
  66. data/frameit/lib/frameit/screenshot.rb +4 -0
  67. data/{pilot/lib/pilot/.manager.rb.swp → gym/lib/gym/.module.rb.swp} +0 -0
  68. data/gym/lib/gym/runner.rb +33 -5
  69. data/match/lib/match/generator.rb +1 -0
  70. data/match/lib/match/importer.rb +2 -2
  71. data/match/lib/match/module.rb +2 -0
  72. data/match/lib/match/nuke.rb +5 -5
  73. data/match/lib/match/options.rb +17 -0
  74. data/match/lib/match/runner.rb +10 -6
  75. data/match/lib/match/storage/git_storage.rb +8 -2
  76. data/match/lib/match/storage/google_cloud_storage.rb +85 -33
  77. data/produce/lib/produce/service.rb +7 -1
  78. data/scan/lib/scan/error_handler.rb +9 -4
  79. data/scan/lib/scan/runner.rb +1 -1
  80. data/sigh/lib/assets/resign.sh +2 -2
  81. data/sigh/lib/sigh/runner.rb +13 -5
  82. data/snapshot/lib/snapshot/options.rb +5 -0
  83. data/snapshot/lib/snapshot/reports_generator.rb +3 -0
  84. data/snapshot/lib/snapshot/simulator_launchers/launcher_configuration.rb +2 -0
  85. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb +2 -2
  86. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +16 -1
  87. data/spaceship/lib/spaceship/client.rb +2 -2
  88. data/spaceship/lib/spaceship/connect_api/models/app.rb +6 -6
  89. data/spaceship/lib/spaceship/connect_api/models/build.rb +3 -3
  90. data/spaceship/lib/spaceship/connect_api/models/build_delivery.rb +1 -1
  91. data/spaceship/lib/spaceship/connect_api/models/bundle_id.rb +1 -1
  92. data/spaceship/lib/spaceship/connect_api/models/certificate.rb +1 -1
  93. data/spaceship/lib/spaceship/connect_api/models/device.rb +1 -1
  94. data/spaceship/lib/spaceship/connect_api/models/profile.rb +1 -1
  95. data/spaceship/lib/spaceship/portal/provisioning_profile.rb +1 -1
  96. data/spaceship/lib/spaceship/tunes/app_version.rb +4 -0
  97. data/spaceship/lib/spaceship/tunes/application.rb +4 -0
  98. data/spaceship/lib/spaceship/tunes/iap_family_details.rb +10 -2
  99. data/spaceship/lib/spaceship/tunes/tunes_client.rb +25 -0
  100. data/supply/lib/supply.rb +23 -0
  101. data/{fastlane/lib/fastlane/actions/.update_project_provisioning.rb.swp → supply/lib/supply/.client.rb.swp} +0 -0
  102. data/supply/lib/supply/.options.rb.swp +0 -0
  103. data/supply/lib/supply/.uploader.rb.swp +0 -0
  104. data/supply/lib/supply/client.rb +101 -55
  105. data/supply/lib/supply/options.rb +49 -14
  106. data/supply/lib/supply/release_listing.rb +18 -0
  107. data/supply/lib/supply/setup.rb +42 -34
  108. data/supply/lib/supply/uploader.rb +168 -93
  109. metadata +54 -53
  110. data/fastlane/lib/fastlane/actions/.hockey.rb.swp +0 -0
  111. data/fastlane/lib/fastlane/actions/.slack.rb.swp +0 -0
  112. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.xcworkspace/xcuserdata/josh.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  113. data/spaceship/lib/spaceship/connect_api/.DS_Store +0 -0
@@ -75,7 +75,7 @@ This will also upload app metadata if you previously ran `fastlane supply init`.
75
75
  To gradually roll out a new build use
76
76
 
77
77
  ```no-highlight
78
- fastlane supply --apk path/app.apk --track rollout --rollout 0.5
78
+ fastlane supply --apk path/app.apk --track beta --rollout 0.5
79
79
  ```
80
80
 
81
81
  ### Expansion files (`.obb`)
@@ -110,7 +110,7 @@ This will also upload app metadata if you previously ran `fastlane supply init`.
110
110
  To gradually roll out a new build use
111
111
 
112
112
  ```no-highlight
113
- fastlane supply --aab path/app.aab --track rollout --rollout 0.5
113
+ fastlane supply --aab path/app.aab --track beta --rollout 0.5
114
114
  ```
115
115
 
116
116
  ## Images and Screenshots
@@ -160,3 +160,27 @@ This can be done using the `--track_promote_to` parameter. The `--track_promote_
160
160
  ## Retrieve Track Version Codes
161
161
 
162
162
  Before performing a new APK upload you may want to check existing track version codes, or you may simply want to provide an informational lane that displays the currently promoted version codes for the production track. You can use the `google_play_track_version_codes` action to retrieve existing version codes for a package and track. For more information, see `fastlane action google_play_track_version_codes` help output.
163
+
164
+ ## Migration from AndroidPublisherV2 to AndroidPublisherV3 in _fastlane_ 2.135.0
165
+
166
+ ### New Options
167
+ - `:version_name`
168
+ - Used when uploading with `:apk_path`, `:apk_paths`, `:aab_path`, and `:aab_paths`
169
+ - Can be any string such (example: "October Release" or "Awesome New Feature")
170
+ - Defaults to the version name in app/build.gradle or AndroidManifest.xml
171
+ - `:release_status`
172
+ - Used when uploading with `:apk_path`, `:apk_paths`, `:aab_path`, and `:aab_paths`
173
+ - Can set as "draft" to complete the release at some other time
174
+ - Defaults to "completed"
175
+ - `:version_code`
176
+ - Used for `:update_rollout`, `:track_promote_to`, and uploading of meta data and screenshots
177
+ - `:skip_upload_changelogs`
178
+ - Changelogs were previously included with the `:skip_upload_metadata` but is now its own option
179
+
180
+ ### Deprecated Options
181
+ - `:check_superseded_tracks`
182
+ - Google Play will automatically remove releases that are superseded now
183
+ - `:deactivate_on_promote`
184
+ - Google Play will automatically deactive a release from its previous track on promote
185
+
186
+ :
@@ -26,6 +26,7 @@ module Fastlane
26
26
  platform = params[:platform]
27
27
  output_directory = params[:output_directory]
28
28
  wait_for_dsym_processing = params[:wait_for_dsym_processing]
29
+ wait_timeout = params[:wait_timeout]
29
30
  min_version = Gem::Version.new(params[:min_version]) if params[:min_version]
30
31
 
31
32
  # Set version if it is latest
@@ -45,6 +46,20 @@ module Fastlane
45
46
  version = latest_candidate_build.train_version
46
47
  build_number = latest_candidate_build.build_version
47
48
  end
49
+ elsif version == 'live'
50
+ UI.message("Looking for live version...")
51
+ live_version = app.live_version(platform: platform)
52
+
53
+ UI.user_error!("Could not find live version for your app, please try setting 'latest' or a specific version") if live_version.nil?
54
+
55
+ # No need to search for candidates, because released App Store version should only have one build
56
+ version = live_version.version
57
+ build_number = live_version.build_version
58
+ end
59
+
60
+ # Remove leading zeros from version string (eg. 1.02 -> 1.2)
61
+ if version
62
+ version = version.split(".").map(&:to_i).join(".")
48
63
  end
49
64
 
50
65
  # Make sure output_directory has a slash on the end
@@ -101,8 +116,9 @@ module Fastlane
101
116
  end
102
117
 
103
118
  unless download_url
104
- if !wait_for_dsym_processing || (Time.now - start) > (60 * 5)
105
- UI.error("Could not find any dSYM for #{build.build_version} (#{train.version_string})")
119
+ if !wait_for_dsym_processing || (Time.now - start) > wait_timeout
120
+ # In some cases, AppStoreConnect does not process the dSYMs, thus no error should be thrown.
121
+ UI.message("Could not find any dSYM for #{build.build_version} (#{train.version_string})")
106
122
  else
107
123
  UI.message("Waiting for dSYM file to appear...")
108
124
  sleep(30)
@@ -113,8 +129,12 @@ module Fastlane
113
129
  break
114
130
  end
115
131
 
116
- self.download(download_url, app.bundle_id, train.version_string, build.build_version, output_directory)
117
- break if build_number
132
+ if download_url
133
+ self.download(download_url, app.bundle_id, train.version_string, build.build_version, output_directory)
134
+ break if build_number
135
+ else
136
+ UI.message("No dSYM URL for #{build.build_version} (#{train.version_string})")
137
+ end
118
138
  end
119
139
  end
120
140
 
@@ -226,7 +246,7 @@ module Fastlane
226
246
  FastlaneCore::ConfigItem.new(key: :version,
227
247
  short_option: "-v",
228
248
  env_name: "DOWNLOAD_DSYMS_VERSION",
229
- description: "The app version for dSYMs you wish to download, pass in 'latest' to download only the latest build's dSYMs",
249
+ description: "The app version for dSYMs you wish to download, pass in 'latest' to download only the latest build's dSYMs or 'live' to download only the live version dSYMs",
230
250
  optional: true),
231
251
  FastlaneCore::ConfigItem.new(key: :build_number,
232
252
  short_option: "-b",
@@ -249,7 +269,14 @@ module Fastlane
249
269
  description: "Wait for dSYMs to process",
250
270
  optional: true,
251
271
  default_value: false,
252
- type: Boolean)
272
+ type: Boolean),
273
+ FastlaneCore::ConfigItem.new(key: :wait_timeout,
274
+ short_option: "-t",
275
+ env_name: "DOWNLOAD_DSYMS_WAIT_TIMEOUT",
276
+ description: "Number of seconds to wait for dSYMs to process",
277
+ optional: true,
278
+ default_value: 300,
279
+ type: Integer)
253
280
  ]
254
281
  end
255
282
 
@@ -275,6 +302,7 @@ module Fastlane
275
302
  [
276
303
  'download_dsyms',
277
304
  'download_dsyms(version: "1.0.0", build_number: "345")',
305
+ 'download_dsyms(version: "live")',
278
306
  'download_dsyms(min_version: "1.2.3")'
279
307
  ]
280
308
  end
@@ -29,7 +29,7 @@ module Fastlane
29
29
  options = Supply::Options.available_options.clone
30
30
 
31
31
  # remove all the unnecessary (for this action) options
32
- options_to_keep = [:package_name, :metadata_path, :json_key, :json_key_data, :root_url, :timeout, :key, :issuer]
32
+ options_to_keep = [:package_name, :version_name, :track, :metadata_path, :json_key, :json_key_data, :root_url, :timeout, :key, :issuer]
33
33
  options.delete_if { |option| options_to_keep.include?(option.key) == false }
34
34
  end
35
35
 
@@ -0,0 +1,58 @@
1
+ module Fastlane
2
+ module Actions
3
+ class EnsureEnvVarsAction < Action
4
+ def self.run(params)
5
+ variables = params[:env_vars]
6
+
7
+ variables.each do |variable|
8
+ next unless ENV[variable].to_s.strip.empty?
9
+
10
+ UI.user_error!("Missing environment variable '#{variable}'")
11
+ end
12
+
13
+ is_one = variables.length == 1
14
+
15
+ UI.success("Environment variable#{is_one ? '' : 's'} '#{variables.join('\', \'')}' #{is_one ? 'is' : 'are'} set!")
16
+ end
17
+
18
+ def self.description
19
+ 'Raises an exception if the specified env vars are not set'
20
+ end
21
+
22
+ def self.details
23
+ 'This action will check if some environment variables are set.'
24
+ end
25
+
26
+ def self.available_options
27
+ [
28
+ FastlaneCore::ConfigItem.new(key: :env_vars,
29
+ description: 'The environment variables names that should be checked',
30
+ type: Array,
31
+ verify_block: proc do |value|
32
+ UI.user_error!('Specify at least one environment variable name') if value.empty?
33
+ end)
34
+ ]
35
+ end
36
+
37
+ def self.authors
38
+ ['revolter']
39
+ end
40
+
41
+ def self.example_code
42
+ [
43
+ 'ensure_env_vars(
44
+ env_vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
45
+ )'
46
+ ]
47
+ end
48
+
49
+ def self.category
50
+ :misc
51
+ end
52
+
53
+ def self.is_supported?(platform)
54
+ true
55
+ end
56
+ end
57
+ end
58
+ end
@@ -18,9 +18,18 @@ module Fastlane
18
18
  plist_file = get_plist!(folder, target, configuration)
19
19
  version_number = get_version_number_from_plist!(plist_file)
20
20
 
21
- # Get from build settings if needed (ex: $(MARKETING_VERSION) is default in Xcode 11)
21
+ # Get from build settings (or project settings) if needed (ex: $(MARKETING_VERSION) is default in Xcode 11)
22
22
  if version_number =~ /\$\(([\w\-]+)\)/
23
- version_number = get_version_number_from_build_settings!(target, $1, configuration)
23
+ version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
24
+
25
+ # ${MARKETING_VERSION} also works
26
+ elsif version_number =~ /\$\{([\w\-]+)\}/
27
+ version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
28
+ end
29
+
30
+ # Error out if version_number is not set
31
+ if version_number.nil?
32
+ UI.user_error!("Unable to find Xcode build setting: #{$1}")
24
33
  end
25
34
 
26
35
  # Store the number in the shared hash
@@ -78,7 +87,7 @@ module Fastlane
78
87
  end
79
88
  end
80
89
 
81
- UI.user_error!("Unable to find Xcode build setting: #{variable}")
90
+ return nil
82
91
  end
83
92
 
84
93
  def self.get_plist!(folder, target, configuration = nil)
@@ -8,6 +8,8 @@ module Fastlane
8
8
  GRADLE_ALL_APK_OUTPUT_PATHS = :GRADLE_ALL_APK_OUTPUT_PATHS
9
9
  GRADLE_AAB_OUTPUT_PATH = :GRADLE_AAB_OUTPUT_PATH
10
10
  GRADLE_ALL_AAB_OUTPUT_PATHS = :GRADLE_ALL_AAB_OUTPUT_PATHS
11
+ GRADLE_OUTPUT_JSON_OUTPUT_PATH = :GRADLE_OUTPUT_JSON_OUTPUT_PATH
12
+ GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS = :GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS
11
13
  GRADLE_FLAVOR = :GRADLE_FLAVOR
12
14
  GRADLE_BUILD_TYPE = :GRADLE_BUILD_TYPE
13
15
  end
@@ -60,6 +62,7 @@ module Fastlane
60
62
 
61
63
  apk_search_path = File.join(project_dir, '**', 'build', 'outputs', 'apk', '**', '*.apk')
62
64
  aab_search_path = File.join(project_dir, '**', 'build', 'outputs', 'bundle', '**', '*.aab')
65
+ output_json_search_path = File.join(project_dir, '**', 'build', 'outputs', 'apk', '**', 'output.json')
63
66
 
64
67
  # Our apk/aab is now built, but there might actually be multiple ones that were built if a flavor was not specified in a multi-flavor project (e.g. `assembleRelease`)
65
68
  # However, we're not interested in unaligned apk's...
@@ -67,18 +70,23 @@ module Fastlane
67
70
  new_apks = new_apks.map { |path| File.expand_path(path) }
68
71
  new_aabs = Dir[aab_search_path]
69
72
  new_aabs = new_aabs.map { |path| File.expand_path(path) }
73
+ new_output_jsons = Dir[output_json_search_path]
74
+ new_output_jsons = new_output_jsons.map { |path| File.expand_path(path) }
70
75
 
71
76
  # We expose all of these new apks and aabs
72
77
  Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS] = new_apks
73
78
  Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS] = new_aabs
79
+ Actions.lane_context[SharedValues::GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS] = new_output_jsons
74
80
 
75
81
  # We also take the most recent apk and aab to return as SharedValues::GRADLE_APK_OUTPUT_PATH and SharedValues::GRADLE_AAB_OUTPUT_PATH
76
82
  # This is the one that will be relevant for most projects that just build a single build variant (flavor + build type combo).
77
83
  # In multi build variants this value is undefined
78
84
  last_apk_path = new_apks.sort_by(&File.method(:mtime)).last
79
85
  last_aab_path = new_aabs.sort_by(&File.method(:mtime)).last
86
+ last_output_json_path = new_output_jsons.sort_by(&File.method(:mtime)).last
80
87
  Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH] = File.expand_path(last_apk_path) if last_apk_path
81
88
  Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH] = File.expand_path(last_aab_path) if last_aab_path
89
+ Actions.lane_context[SharedValues::GRADLE_OUTPUT_JSON_OUTPUT_PATH] = File.expand_path(last_output_json_path) if last_output_json_path
82
90
 
83
91
  # Give a helpful message in case there were no new apks or aabs. Remember we're only running this code when assembling, in which case we certainly expect there to be an apk or aab
84
92
  UI.message('Couldn\'t find any new signed apk files...') if new_apks.empty? && new_aabs.empty?
@@ -165,7 +173,9 @@ module Fastlane
165
173
  ['GRADLE_FLAVOR', 'The flavor, e.g. `MyFlavor`'],
166
174
  ['GRADLE_BUILD_TYPE', 'The build type, e.g. `Release`'],
167
175
  ['GRADLE_AAB_OUTPUT_PATH', 'The path to the most recent Android app bundle'],
168
- ['GRADLE_ALL_AAB_OUTPUT_PATHS', 'The paths to the most recent Android app bundles']
176
+ ['GRADLE_ALL_AAB_OUTPUT_PATHS', 'The paths to the most recent Android app bundles'],
177
+ ['GRADLE_OUTPUT_JSON_OUTPUT_PATH', 'The path to the most recent output.json file'],
178
+ ['GRADLE_ALL_OUTPUT_JSON_OUTPUT_PATHS', 'The path to the newly generated output.json files']
169
179
  ]
170
180
  end
171
181
 
@@ -11,15 +11,26 @@ module Fastlane
11
11
  require 'uri'
12
12
  require 'base64'
13
13
 
14
- UI.message("Parameter App name: #{params[:app_name]}")
14
+ app_id = params[:app_id].to_s.strip
15
15
  auth_token = params[:auth_token]
16
- app_name = params[:app_name]
16
+ app_name = params[:app_name].to_s
17
17
  apns_p12_password = params[:apns_p12_password]
18
18
  android_token = params[:android_token]
19
19
  android_gcm_sender_id = params[:android_gcm_sender_id]
20
20
 
21
+ has_app_id = !app_id.empty?
22
+ has_app_name = !app_name.empty?
23
+
24
+ is_update = has_app_id
25
+
26
+ UI.user_error!('Please specify the `app_id` or the `app_name` parameters!') if !has_app_id && !has_app_name
27
+
28
+ UI.message("Parameter App ID: #{app_id}") if has_app_id
29
+ UI.message("Parameter App name: #{app_name}") if has_app_name
30
+
21
31
  payload = {}
22
- payload['name'] = app_name
32
+
33
+ payload['name'] = app_name if has_app_name
23
34
 
24
35
  unless params[:apns_p12].nil?
25
36
  data = File.read(params[:apns_p12])
@@ -33,61 +44,70 @@ module Fastlane
33
44
  payload["gcm_key"] = android_token unless android_token.nil?
34
45
  payload["android_gcm_sender_id"] = android_gcm_sender_id unless android_gcm_sender_id.nil?
35
46
 
36
- # here's the actual lifting - POST to OneSignal
47
+ # here's the actual lifting - POST or PUT to OneSignal
37
48
 
38
49
  json_headers = { 'Content-Type' => 'application/json', 'Authorization' => "Basic #{auth_token}" }
39
- uri = URI.parse('https://onesignal.com/api/v1/apps')
50
+ url = +'https://onesignal.com/api/v1/apps'
51
+ url << '/' + app_id if is_update
52
+ uri = URI.parse(url)
40
53
  http = Net::HTTP.new(uri.host, uri.port)
41
54
  http.use_ssl = true
42
- response = http.post(uri.path, payload.to_json, json_headers)
55
+
56
+ if is_update
57
+ response = http.put(uri.path, payload.to_json, json_headers)
58
+ else
59
+ response = http.post(uri.path, payload.to_json, json_headers)
60
+ end
61
+
43
62
  response_body = JSON.parse(response.body)
44
63
 
45
64
  Actions.lane_context[SharedValues::ONE_SIGNAL_APP_ID] = response_body["id"]
46
65
  Actions.lane_context[SharedValues::ONE_SIGNAL_APP_AUTH_KEY] = response_body["basic_auth_key"]
47
66
 
48
- check_response_code(response)
67
+ check_response_code(response, is_update)
49
68
  end
50
69
 
51
- def self.check_response_code(response)
70
+ def self.check_response_code(response, is_update)
52
71
  case response.code.to_i
53
72
  when 200, 204
54
- puts("Successfully created new OneSignal app".green)
73
+ UI.success("Successfully #{is_update ? 'updated' : 'created new'} OneSignal app")
55
74
  else
56
75
  UI.user_error!("Unexpected #{response.code} with response: #{response.body}")
57
76
  end
58
77
  end
59
78
 
60
79
  def self.description
61
- "Create a new [OneSignal](https://onesignal.com/) application"
80
+ "Create or update a new [OneSignal](https://onesignal.com/) application"
62
81
  end
63
82
 
64
83
  def self.details
65
- "You can use this action to automatically create a OneSignal application. You can also upload a `.p12` with password, a GCM key, or both."
84
+ "You can use this action to automatically create or update a OneSignal application. You can also upload a `.p12` with password, a GCM key, or both."
66
85
  end
67
86
 
68
87
  def self.available_options
69
88
  [
70
- FastlaneCore::ConfigItem.new(key: :auth_token,
71
- env_name: "ONE_SIGNAL_AUTH_KEY",
72
- sensitive: true,
73
- description: "OneSignal Authorization Key",
74
- verify_block: proc do |value|
75
- unless value.to_s.length > 0
76
- UI.error("Please add 'ENV[\"ONE_SIGNAL_AUTH_KEY\"] = \"your token\"' to your Fastfile's `before_all` section.")
77
- UI.user_error!("No ONE_SIGNAL_AUTH_KEY given.")
78
- end
79
- end),
89
+ FastlaneCore::ConfigItem.new(key: :app_id,
90
+ env_name: "ONE_SIGNAL_APP_ID",
91
+ sensitive: true,
92
+ description: "OneSignal App ID. Setting this updates an existing app",
93
+ optional: true),
80
94
 
81
- FastlaneCore::ConfigItem.new(key: :app_name,
82
- env_name: "ONE_SIGNAL_APP_NAME",
83
- description: "OneSignal App Name",
95
+ FastlaneCore::ConfigItem.new(key: :auth_token,
96
+ env_name: "ONE_SIGNAL_AUTH_KEY",
97
+ sensitive: true,
98
+ description: "OneSignal Authorization Key",
84
99
  verify_block: proc do |value|
85
- unless value.to_s.length > 0
86
- UI.error("Please add 'ENV[\"ONE_SIGNAL_APP_NAME\"] = \"Your app name\"' to your Fastfile's `before_all` section.")
87
- UI.user_error!("No ONE_SIGNAL_APP_NAME given.")
100
+ if value.to_s.empty?
101
+ UI.error("Please add 'ENV[\"ONE_SIGNAL_AUTH_KEY\"] = \"your token\"' to your Fastfile's `before_all` section.")
102
+ UI.user_error!("No ONE_SIGNAL_AUTH_KEY given.")
88
103
  end
89
104
  end),
90
105
 
106
+ FastlaneCore::ConfigItem.new(key: :app_name,
107
+ env_name: "ONE_SIGNAL_APP_NAME",
108
+ description: "OneSignal App Name. This is required when creating an app (in other words, when `:app_id` is not set, and optional when updating an app",
109
+ optional: true),
110
+
91
111
  FastlaneCore::ConfigItem.new(key: :android_token,
92
112
  env_name: "ANDROID_TOKEN",
93
113
  description: "ANDROID GCM KEY",
@@ -121,8 +141,8 @@ module Fastlane
121
141
 
122
142
  def self.output
123
143
  [
124
- ['ONE_SIGNAL_APP_ID', 'The OneSignal app ID of the newly created app'],
125
- ['ONE_SIGNAL_APP_AUTH_KEY', 'The auth token for the newly created OneSignal app']
144
+ ['ONE_SIGNAL_APP_ID', 'The app ID of the newly created or updated app'],
145
+ ['ONE_SIGNAL_APP_AUTH_KEY', 'The auth token for the newly created or updated app']
126
146
  ]
127
147
  end
128
148
 
@@ -144,6 +164,16 @@ module Fastlane
144
164
  apns_p12: "Path to Apple .p12 file (optional)",
145
165
  apns_p12_password: "Password for .p12 file (optional)",
146
166
  apns_env: "production/sandbox (defaults to production)"
167
+ )',
168
+ 'onesignal(
169
+ app_id: "Your OneSignal App ID",
170
+ auth_token: "Your OneSignal Auth Token",
171
+ app_name: "New Name for OneSignal App",
172
+ android_token: "Your Android GCM key (optional)",
173
+ android_gcm_sender_id: "Your Android GCM Sender ID (optional)",
174
+ apns_p12: "Path to Apple .p12 file (optional)",
175
+ apns_p12_password: "Password for .p12 file (optional)",
176
+ apns_env: "production/sandbox (defaults to production)"
147
177
  )'
148
178
  ]
149
179
  end
@@ -47,6 +47,10 @@ module Fastlane
47
47
  command << "--verbose"
48
48
  end
49
49
 
50
+ if params[:use_modular_headers]
51
+ command << "--use-modular-headers"
52
+ end
53
+
50
54
  result = Actions.sh(command.join(' '))
51
55
  UI.success("Successfully pushed Podspec ⬆️ ")
52
56
  return result
@@ -118,7 +122,12 @@ module Fastlane
118
122
  optional: true,
119
123
  type: Boolean,
120
124
  default_value: false,
121
- env_name: "FL_POD_PUSH_VERBOSE")
125
+ env_name: "FL_POD_PUSH_VERBOSE"),
126
+ FastlaneCore::ConfigItem.new(key: :use_modular_headers,
127
+ description: "Use modular headers option during validation",
128
+ optional: true,
129
+ type: Boolean,
130
+ env_name: "FL_POD_PUSH_USE_MODULAR_HEADERS")
122
131
  ]
123
132
  end
124
133