fastlane-plugin-wpmreleasetoolkit 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +339 -0
  3. data/README.md +38 -0
  4. data/bin/drawText +19 -0
  5. data/ext/drawText/extconf.rb +36 -0
  6. data/lib/fastlane/plugin/wpmreleasetoolkit.rb +16 -0
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/README.md +20 -0
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb +53 -0
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +171 -0
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb +63 -0
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +103 -0
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +83 -0
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_preflight.rb +54 -0
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +69 -0
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +58 -0
  16. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +77 -0
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +89 -0
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +79 -0
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +68 -0
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb +63 -0
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +44 -0
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +79 -0
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +115 -0
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +71 -0
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +44 -0
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +44 -0
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +44 -0
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotifx_prechecks.rb +78 -0
  29. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_merge_translators_strings.rb +106 -0
  30. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +51 -0
  31. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_metadata.rb +52 -0
  32. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb +56 -0
  33. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb +63 -0
  34. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +56 -0
  35. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +59 -0
  36. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +91 -0
  37. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +89 -0
  38. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_list_action.rb +64 -0
  39. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +90 -0
  40. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +170 -0
  41. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +247 -0
  42. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/removebranchprotection_action.rb +57 -0
  43. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb +56 -0
  44. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setfrozentag_action.rb +81 -0
  45. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb +96 -0
  46. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_apply_action.rb +139 -0
  47. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb +57 -0
  48. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_setup_action.rb +86 -0
  49. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb +139 -0
  50. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb +134 -0
  51. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb +77 -0
  52. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb +79 -0
  53. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +92 -0
  54. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +74 -0
  55. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb +78 -0
  56. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +68 -0
  57. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +87 -0
  58. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +114 -0
  59. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +62 -0
  60. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_clear_intermediate_tags.rb +60 -0
  61. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +70 -0
  62. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +63 -0
  63. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb +40 -0
  64. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_final_tag.rb +52 -0
  65. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +64 -0
  66. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +47 -0
  67. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb +60 -0
  68. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_store_app_sizes.rb +121 -0
  69. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotifx_prechecks.rb +78 -0
  70. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +167 -0
  71. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +44 -0
  72. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_translators_strings.rb +93 -0
  73. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +44 -0
  74. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +40 -0
  75. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb +81 -0
  76. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb +56 -0
  77. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +46 -0
  78. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb +152 -0
  79. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +44 -0
  80. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +359 -0
  81. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +475 -0
  82. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb +91 -0
  83. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb +282 -0
  84. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb +51 -0
  85. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb +93 -0
  86. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +224 -0
  87. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +135 -0
  88. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb +74 -0
  89. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +80 -0
  90. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb +208 -0
  91. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +348 -0
  92. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +107 -0
  93. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb +182 -0
  94. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +399 -0
  95. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb +21 -0
  96. data/lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb +40 -0
  97. data/lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb +86 -0
  98. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +5 -0
  99. metadata +449 -0
@@ -0,0 +1,44 @@
1
+ module Fastlane
2
+ module Actions
3
+ class AndroidGetReleaseVersionAction < Action
4
+ def self.run(params)
5
+ require_relative '../../helper/android/android_version_helper.rb'
6
+ Fastlane::Helper::Android::VersionHelper.get_release_version()
7
+ end
8
+
9
+ #####################################################
10
+ # @!group Documentation
11
+ #####################################################
12
+
13
+ def self.description
14
+ 'Gets the public version of the app'
15
+ end
16
+
17
+ def self.details
18
+ 'Gets the public version of the app'
19
+ end
20
+
21
+ def self.available_options
22
+ # Define all options your action supports.
23
+ end
24
+
25
+ def self.output
26
+ # Define the shared values you are going to provide
27
+ end
28
+
29
+ def self.return_value
30
+ # If you method provides a return value, you can describe here what it does
31
+ 'Return the public version of the app'
32
+ end
33
+
34
+ def self.authors
35
+ # So no one will ever forget your contribution to fastlane :) You are awesome btw!
36
+ ['loremattei']
37
+ end
38
+
39
+ def self.is_supported?(platform)
40
+ platform == :android
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,78 @@
1
+ module Fastlane
2
+ module Actions
3
+ class AndroidHotfixPrechecksAction < Action
4
+ def self.run(params)
5
+ UI.message "Skip confirm: #{params[:skip_confirm]}"
6
+ UI.message ''
7
+
8
+ require_relative '../../helper/android/android_version_helper.rb'
9
+ require_relative '../../helper/android/android_git_helper.rb'
10
+
11
+ # Evaluate previous tag
12
+ new_ver = params[:version_name]
13
+ prev_ver = Fastlane::Helper::Android::VersionHelper.calc_prev_hotfix_version_name(new_ver)
14
+
15
+ # Confirm
16
+ message = "Requested Hotfix version: #{new_ver}\n"
17
+ message << "Branching from: #{prev_ver}\n"
18
+
19
+ if !params[:skip_confirm]
20
+ UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?")
21
+ else
22
+ UI.message(message)
23
+ end
24
+
25
+ # Check tags
26
+ UI.crash!("Version #{new_ver} already exists! Abort!") if other_action.git_tag_exists(tag: new_ver)
27
+
28
+ UI.crash!("Version #{prev_ver} is not tagged! Can't branch. Abort!") unless other_action.git_tag_exists(tag: prev_ver)
29
+
30
+ # Check local repo status
31
+ other_action.ensure_git_status_clean()
32
+
33
+ # Return the current version
34
+ prev_ver
35
+ end
36
+
37
+ #####################################################
38
+ # @!group Documentation
39
+ #####################################################
40
+
41
+ def self.description
42
+ 'Runs some prechecks before preparing for a new hotfix'
43
+ end
44
+
45
+ def self.details
46
+ 'Checks out a new branch from a tag and updates tags'
47
+ end
48
+
49
+ def self.available_options
50
+ [
51
+ FastlaneCore::ConfigItem.new(key: :version_name,
52
+ env_name: 'FL_ANDROID_HOTFIX_PRECHECKS_VERSION',
53
+ description: 'The version to work on', # a short description of this parameter
54
+ is_string: true),
55
+ FastlaneCore::ConfigItem.new(key: :skip_confirm,
56
+ env_name: 'FL_ANDROID_HOTFIX_PRECHECKS_SKIPCONFIRM',
57
+ description: 'Skips confirmation',
58
+ is_string: false, # true: verifies the input is a string, false: every kind of value
59
+ default_value: false), # the default value if the user didn't provide one
60
+ ]
61
+ end
62
+
63
+ def self.output
64
+ end
65
+
66
+ def self.return_value
67
+ end
68
+
69
+ def self.authors
70
+ ['loremattei']
71
+ end
72
+
73
+ def self.is_supported?(platform)
74
+ platform == :android
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,106 @@
1
+ require 'fastlane/action'
2
+ require 'date'
3
+ require_relative '../../helper/github_helper'
4
+ require_relative '../../helper/ios/ios_version_helper'
5
+ require_relative '../../helper/android/android_version_helper'
6
+ module Fastlane
7
+ module Actions
8
+ class AndroidMergeTranslatorsStringsAction < Action
9
+ def self.run(params)
10
+ folder_path = File.expand_path(params[:strings_folder])
11
+
12
+ subfolders = Dir.entries(folder_path)
13
+ subfolders.each do |strings_folder|
14
+ merge_folder(File.join(folder_path, strings_folder)) if strings_folder.start_with?('values')
15
+ end
16
+ end
17
+
18
+ def self.merge_folder(strings_folder)
19
+ main_file = File.join(strings_folder, 'strings.xml')
20
+ return unless File.exist?(main_file)
21
+
22
+ UI.message("Merging in: #{strings_folder}")
23
+
24
+ tmp_main_file = main_file + '.tmp'
25
+ FileUtils.cp(main_file, tmp_main_file)
26
+
27
+ join_files = Dir.glob(File.join(strings_folder, 'strings-*.xml'))
28
+ extra_strings = []
29
+ extra_keys = []
30
+ join_files.each do |join_strings|
31
+ my_strings = File.read(join_strings).split("\n")
32
+ my_strings.each do |string|
33
+ if string.include?('<string name')
34
+ string_key = string.strip.split('>').first
35
+ unless extra_keys.include?(string_key)
36
+ extra_strings << string
37
+ extra_keys << string_key
38
+ end
39
+ end
40
+ end
41
+
42
+ File.delete(join_strings)
43
+ end
44
+
45
+ File.open(main_file, 'w') do |f|
46
+ File.open(tmp_main_file).each do |line|
47
+ f.puts(extra_strings) if line.strip == '</resources>'
48
+ f.puts(check_line(line, extra_strings))
49
+ end
50
+ end
51
+
52
+ File.delete(tmp_main_file)
53
+ end
54
+
55
+ def self.check_line(line, extra_strings)
56
+ return line unless line.include?('<string name')
57
+
58
+ test_line = line.strip.split('>').first
59
+ extra_strings.each do |overwrite_string|
60
+ return '' if overwrite_string.strip.split('>').first == test_line
61
+ end
62
+
63
+ return line
64
+ end
65
+
66
+ def self.description
67
+ 'Merge strings for translators'
68
+ end
69
+
70
+ def self.authors
71
+ ['Lorenzo Mattei']
72
+ end
73
+
74
+ def self.return_value
75
+ # If your method provides a return value, you can describe here what it does
76
+ end
77
+
78
+ def self.details
79
+ # Optional:
80
+ 'Merges waiting and fuzzy strings into the main file for translators. This action is deprecated in favor of `android_download_translations`'
81
+ end
82
+
83
+ def self.available_options
84
+ [
85
+ FastlaneCore::ConfigItem.new(key: :strings_folder,
86
+ env_name: 'AMTS_STRING_FOLDER',
87
+ description: 'The folder that contains all the translations',
88
+ optional: false,
89
+ type: String),
90
+ ]
91
+ end
92
+
93
+ def self.is_supported?(platform)
94
+ true
95
+ end
96
+
97
+ def self.category
98
+ :deprecated
99
+ end
100
+
101
+ def self.deprecated_notes
102
+ 'This action is deprecated in favor of `android_download_translations` (using an array for the status_filter parameter)'
103
+ end
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,51 @@
1
+ module Fastlane
2
+ module Actions
3
+ class AndroidTagBuildAction < Action
4
+ def self.run(params)
5
+ require_relative '../../helper/android/android_version_helper.rb'
6
+ require_relative '../../helper/android/android_git_helper.rb'
7
+
8
+ release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version()
9
+ alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version() unless ENV['HAS_ALPHA_VERSION'].nil?
10
+ Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME])
11
+ Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless ENV['HAS_ALPHA_VERSION'].nil? || (params[:tag_alpha] == false)
12
+ end
13
+
14
+ #####################################################
15
+ # @!group Documentation
16
+ #####################################################
17
+
18
+ def self.description
19
+ 'Tags the current build'
20
+ end
21
+
22
+ def self.details
23
+ 'Tags the current build'
24
+ end
25
+
26
+ def self.available_options
27
+ [
28
+ FastlaneCore::ConfigItem.new(key: :tag_alpha,
29
+ env_name: 'FL_ANDROID_TAG_BUILD_ALPHA',
30
+ description: 'True to skip tagging the alpha version',
31
+ is_string: false,
32
+ default_value: true),
33
+ ]
34
+ end
35
+
36
+ def self.output
37
+ end
38
+
39
+ def self.return_value
40
+ end
41
+
42
+ def self.authors
43
+ ['loremattei']
44
+ end
45
+
46
+ def self.is_supported?(platform)
47
+ platform == :android
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ module Fastlane
2
+ module Actions
3
+ module SharedValues
4
+ ANDROID_UPDATE_METADATA_CUSTOM_VALUE = :ANDROID_UPDATE_METADATA_CUSTOM_VALUE
5
+ end
6
+
7
+ class AndroidUpdateMetadataAction < Action
8
+ def self.run(params)
9
+ require_relative '../../helper/android/android_git_helper.rb'
10
+
11
+ Fastlane::Helper::Android::GitHelper.update_metadata(ENV['validate_translations'])
12
+ end
13
+
14
+ #####################################################
15
+ # @!group Documentation
16
+ #####################################################
17
+
18
+ def self.description
19
+ 'Downloads translated metadata from the translation system'
20
+ end
21
+
22
+ def self.details
23
+ 'Downloads translated metadata from the translation system. This action is deprecated in favor of `android_download_translations`'
24
+ end
25
+
26
+ def self.available_options
27
+ end
28
+
29
+ def self.output
30
+ end
31
+
32
+ def self.return_value
33
+ end
34
+
35
+ def self.authors
36
+ ['loremattei']
37
+ end
38
+
39
+ def self.is_supported?(platform)
40
+ platform == :android
41
+ end
42
+
43
+ def self.category
44
+ :deprecated
45
+ end
46
+
47
+ def self.deprecated_notes
48
+ 'This action is deprecated in favor of `android_download_translations`'
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,56 @@
1
+ module Fastlane
2
+ module Actions
3
+ class AndroidUpdateReleaseNotesAction < Action
4
+ def self.run(params)
5
+ UI.message 'Updating the release notes...'
6
+
7
+ require_relative '../../helper/android/android_version_helper.rb'
8
+ require_relative '../../helper/release_notes_helper.rb'
9
+ require_relative '../../helper/git_helper.rb'
10
+
11
+ path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'RELEASE-NOTES.txt')
12
+ next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_short_version(params[:new_version])
13
+
14
+ Fastlane::Helper::ReleaseNotesHelper.add_new_section(path: path, section_title: next_version)
15
+ Fastlane::Helper::GitHelper.commit(message: "Release Notes: add new section for next version (#{next_version})", files: path, push: true)
16
+
17
+ UI.message 'Done.'
18
+ end
19
+
20
+ #####################################################
21
+ # @!group Documentation
22
+ #####################################################
23
+
24
+ def self.description
25
+ 'Updates the release notes file for the next app version'
26
+ end
27
+
28
+ def self.details
29
+ 'Updates the release notes file for the next app version'
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :new_version,
35
+ env_name: 'FL_ANDROID_UPDATE_RELEASE_NOTES_VERSION',
36
+ description: 'The version we are currently freezing; An empty entry for the _next_ version after this one will be added to the release notes',
37
+ is_string: true),
38
+ ]
39
+ end
40
+
41
+ def self.output
42
+ end
43
+
44
+ def self.return_value
45
+ end
46
+
47
+ def self.authors
48
+ ['loremattei']
49
+ end
50
+
51
+ def self.is_supported?(platform)
52
+ platform == :android
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,63 @@
1
+ module Fastlane
2
+ module Actions
3
+ class CircleciTriggerJobAction < Action
4
+ def self.run(params)
5
+ require_relative '../../helper/ci_helper.rb'
6
+
7
+ UI.message "Triggering job #{params[:job_params]} on branch #{params[:branch]}"
8
+
9
+ ci_helper = Fastlane::Helper::CircleCIHelper.new(
10
+ login: params[:circle_ci_token],
11
+ repository: params[:repository],
12
+ organization: params[:organization]
13
+ )
14
+
15
+ res = ci_helper.trigger_job(branch: params[:branch], parameters: params[:job_params])
16
+ res.code == '201' ? UI.message('Done!') : UI.user_error!("Failed to start job\nError: [#{res.code}] #{res.message}")
17
+ end
18
+
19
+ #####################################################
20
+ # @!group Documentation
21
+ #####################################################
22
+
23
+ def self.description
24
+ 'Triggers a job on CircleCI'
25
+ end
26
+
27
+ def self.available_options
28
+ [
29
+ FastlaneCore::ConfigItem.new(key: :circle_ci_token,
30
+ env_name: 'FL_CIRCLECI_TOKEN',
31
+ description: 'CircleCI token',
32
+ type: String),
33
+ FastlaneCore::ConfigItem.new(key: :organization,
34
+ env_name: 'FL_CIRCLECI_ORGANIZATION',
35
+ description: 'The GitHub organization which hosts the repository you want to work on',
36
+ type: String,
37
+ default_value: 'wordpress-mobile'),
38
+ FastlaneCore::ConfigItem.new(key: :repository,
39
+ env_name: 'FL_CIRCLECI_REPOSITORY',
40
+ description: 'The GitHub repository you want to work on',
41
+ type: String),
42
+ FastlaneCore::ConfigItem.new(key: :branch,
43
+ env_name: 'FL_CIRCLECI_BRANCH',
44
+ description: 'The branch on which you want to work on',
45
+ type: String),
46
+ FastlaneCore::ConfigItem.new(key: :job_params,
47
+ env_name: 'FL_CIRCLECI_JOB_PARAMS',
48
+ description: 'Parameters to send to the CircleCI pipeline',
49
+ type: Hash,
50
+ default_value: nil),
51
+ ]
52
+ end
53
+
54
+ def self.authors
55
+ ['loremattei']
56
+ end
57
+
58
+ def self.is_supported?(platform)
59
+ true
60
+ end
61
+ end
62
+ end
63
+ end