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,56 @@
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 CloseMilestoneAction < Action
9
+ def self.run(params)
10
+ repository = params[:repository]
11
+ milestone_title = params[:milestone]
12
+
13
+ milestone = Fastlane::Helper::GithubHelper.get_milestone(repository, milestone_title)
14
+ UI.user_error!("Milestone #{milestone_title} not found.") if milestone.nil?
15
+
16
+ Fastlane::Helper::GithubHelper.github_client().update_milestone(repository, milestone[:number], state: 'closed')
17
+ end
18
+
19
+ def self.description
20
+ 'Closes an existing milestone in the project'
21
+ end
22
+
23
+ def self.authors
24
+ ['Lorenzo Mattei']
25
+ end
26
+
27
+ def self.return_value
28
+ # If your method provides a return value, you can describe here what it does
29
+ end
30
+
31
+ def self.details
32
+ # Optional:
33
+ 'Closes an existing milestone in the project'
34
+ end
35
+
36
+ def self.available_options
37
+ [
38
+ FastlaneCore::ConfigItem.new(key: :repository,
39
+ env_name: 'GHHELPER_REPOSITORY',
40
+ description: 'The remote path of the GH repository on which we work',
41
+ optional: false,
42
+ type: String),
43
+ FastlaneCore::ConfigItem.new(key: :milestone,
44
+ env_name: 'GHHELPER_MILESTONE',
45
+ description: 'The GitHub milestone',
46
+ optional: false,
47
+ type: String),
48
+ ]
49
+ end
50
+
51
+ def self.is_supported?(platform)
52
+ true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,59 @@
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 CreateNewMilestoneAction < Action
9
+ def self.run(params)
10
+ repository = params[:repository]
11
+
12
+ last_stone = Fastlane::Helper::GithubHelper.get_last_milestone(repository)
13
+ UI.message("Last detected milestone: #{last_stone[:title]} due on #{last_stone[:due_on]}.")
14
+ milestone_duedate = last_stone[:due_on]
15
+ newmilestone_duedate = (milestone_duedate.to_datetime.next_day(14).to_time).utc
16
+ newmilestone_number = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(last_stone[:title])
17
+ UI.message("Next milestone: #{newmilestone_number} due on #{newmilestone_duedate}.")
18
+ Fastlane::Helper::GithubHelper.create_milestone(repository, newmilestone_number, newmilestone_duedate, params[:need_appstore_submission])
19
+ end
20
+
21
+ def self.description
22
+ 'Creates a new milestone for the project'
23
+ end
24
+
25
+ def self.authors
26
+ ['Lorenzo Mattei']
27
+ end
28
+
29
+ def self.return_value
30
+ # If your method provides a return value, you can describe here what it does
31
+ end
32
+
33
+ def self.details
34
+ # Optional:
35
+ 'Creates a new milestone for the project'
36
+ end
37
+
38
+ def self.available_options
39
+ [
40
+ FastlaneCore::ConfigItem.new(key: :repository,
41
+ env_name: 'GHHELPER_REPOSITORY',
42
+ description: 'The remote path of the GH repository on which we work',
43
+ optional: false,
44
+ type: String),
45
+ FastlaneCore::ConfigItem.new(key: :need_appstore_submission,
46
+ env_name: 'GHHELPER_NEED_APPSTORE_SUBMISSION',
47
+ description: 'True if the app needs to be submitted',
48
+ optional: true,
49
+ is_string: false,
50
+ default_value: false),
51
+ ]
52
+ end
53
+
54
+ def self.is_supported?(platform)
55
+ true
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,91 @@
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 CreateReleaseAction < Action
9
+ def self.run(params)
10
+ repository = params[:repository]
11
+ version = params[:version]
12
+ assets = params[:release_assets]
13
+ release_notes = params[:release_notes_file_path].nil? ? '' : IO.read(params[:release_notes_file_path])
14
+ prerelease = params[:prerelease]
15
+
16
+ UI.message("Creating draft release #{version} in #{repository}.")
17
+ # Verify assets
18
+ assets.each do |file_path|
19
+ UI.user_error!("Can't find file #{file_path}!") unless File.exist?(file_path)
20
+ end
21
+
22
+ Fastlane::Helper::GithubHelper.create_release(
23
+ repository: repository,
24
+ version: version,
25
+ target: params[:target],
26
+ description: release_notes,
27
+ assets: assets,
28
+ prerelease: prerelease
29
+ )
30
+ UI.message('Done')
31
+ end
32
+
33
+ def self.description
34
+ 'Creates a release and uploads the provided assets'
35
+ end
36
+
37
+ def self.authors
38
+ ['Lorenzo Mattei']
39
+ end
40
+
41
+ def self.return_value
42
+ # If your method provides a return value, you can describe here what it does
43
+ end
44
+
45
+ def self.details
46
+ # Optional:
47
+ 'Creates a release and uploads the provided assets'
48
+ end
49
+
50
+ def self.available_options
51
+ [
52
+ FastlaneCore::ConfigItem.new(key: :repository,
53
+ env_name: 'GHHELPER_REPOSITORY',
54
+ description: 'The slug (`<org>/<repo>`) of the GitHub repository we want to create the release on',
55
+ optional: false,
56
+ type: String),
57
+ FastlaneCore::ConfigItem.new(key: :version,
58
+ env_name: 'GHHELPER_CREATE_RELEASE_VERSION',
59
+ description: 'The version of the release',
60
+ optional: false,
61
+ type: String),
62
+ FastlaneCore::ConfigItem.new(key: :target,
63
+ env_name: 'GHHELPER_TARGET_COMMITISH',
64
+ description: 'The branch name or commit SHA the new tag should point to - if that tag does not exist yet when publishing the release. If omitted, will default to the current HEAD commit at the time of this call',
65
+ optional: true,
66
+ type: String),
67
+ FastlaneCore::ConfigItem.new(key: :release_notes_file_path,
68
+ env_name: 'GHHELPER_CREATE_RELEASE_NOTES',
69
+ description: 'The path to the file that contains the release notes',
70
+ optional: true,
71
+ type: String),
72
+ FastlaneCore::ConfigItem.new(key: :release_assets,
73
+ env_name: 'GHHELPER_CREATE_RELEASE_ASSETS',
74
+ description: 'Assets to upload',
75
+ type: Array,
76
+ optional: false),
77
+ FastlaneCore::ConfigItem.new(key: :prerelease,
78
+ env_name: 'GHHELPER_CREATE_RELEASE_PRERELEASE',
79
+ description: 'True if this is a pre-release',
80
+ optional: true,
81
+ default_value: false,
82
+ is_string: false),
83
+ ]
84
+ end
85
+
86
+ def self.is_supported?(platform)
87
+ true
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,89 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class ExtractReleaseNotesForVersionAction < Action
6
+ def self.run(params)
7
+ version = params[:version]
8
+ release_notes_file_path = params[:release_notes_file_path]
9
+ extracted_notes_file_path = params[:extracted_notes_file_path]
10
+
11
+ extracted_notes_file = File.open(extracted_notes_file_path, 'w') unless extracted_notes_file_path.blank?
12
+
13
+ extract_notes(release_notes_file_path, version) do |line|
14
+ extracted_notes_file.nil? ? puts(line) : extracted_notes_file.write(line)
15
+ end
16
+
17
+ unless extracted_notes_file.nil?
18
+ extracted_notes_file.close()
19
+ check_and_commit_extracted_notes_file(extracted_notes_file_path, version)
20
+ end
21
+ end
22
+
23
+ def self.extract_notes(release_notes_file_path, version)
24
+ state = :discarding
25
+ File.open(release_notes_file_path).each do |line|
26
+ case state
27
+ when :discarding
28
+ state = :evaluating if (line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)) && (line.strip() == version)
29
+ when :evaluating
30
+ state = (line.match(/-/)) ? :extracting : :discarding
31
+ when :extracting
32
+ if line.match(/^(\d+\.)?(\d+\.)?(\*|\d+)$/)
33
+ state = :discarding
34
+ return
35
+ else
36
+ yield(line)
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ def self.check_and_commit_extracted_notes_file(file_path, version)
43
+ Action.sh("git add #{file_path}")
44
+ Action.sh("git diff-index --quiet HEAD || git commit -m \"Update draft release notes for #{version}.\"")
45
+ end
46
+
47
+ def self.description
48
+ 'Extract the release notes for a specific version'
49
+ end
50
+
51
+ def self.authors
52
+ ['Lorenzo Mattei']
53
+ end
54
+
55
+ def self.return_value
56
+ # If your method provides a return value, you can describe here what it does
57
+ end
58
+
59
+ def self.details
60
+ # Optional:
61
+ 'Creates a release and uploads the provided assets'
62
+ end
63
+
64
+ def self.available_options
65
+ [
66
+ FastlaneCore::ConfigItem.new(key: :version,
67
+ env_name: 'GHHELPER_EXTRACT_NOTES_VERSION',
68
+ description: 'The version of the release',
69
+ optional: false,
70
+ is_string: true),
71
+ FastlaneCore::ConfigItem.new(key: :release_notes_file_path,
72
+ env_name: 'GHHELPER_EXTRACT_NOTES_FILE_PATH',
73
+ description: 'The path to the file that contains the release notes',
74
+ optional: false,
75
+ is_string: true),
76
+ FastlaneCore::ConfigItem.new(key: :extracted_notes_file_path,
77
+ env_name: 'GHHELPER_EXTRACT_NOTES_EXTRACTED_FILE_PATH',
78
+ description: 'The path to the file that will contain the extracted release notes',
79
+ optional: true,
80
+ is_string: true),
81
+ ]
82
+ end
83
+
84
+ def self.is_supported?(platform)
85
+ true
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,64 @@
1
+ require 'fastlane/action'
2
+ require_relative '../../helper/github_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GetPrsListAction < Action
7
+ def self.run(params)
8
+ repository = params[:repository]
9
+ report_path = File.expand_path(params[:report_path])
10
+ milestone = params[:milestone]
11
+
12
+ # Get commit list
13
+ pr_list = Fastlane::Helper::GithubHelper.get_prs_for_milestone(repository, milestone)
14
+
15
+ File.open(report_path, 'w') do |file|
16
+ pr_list.each do |data|
17
+ file.puts("##{data[:number]}: #{data[:title]} @#{data[:user][:login]} #{data[:html_url]}")
18
+ end
19
+ end
20
+
21
+ UI.success("Found #{pr_list.count} PRs in #{milestone} – saved to #{report_path}")
22
+ end
23
+
24
+ def self.description
25
+ 'Generate the list of the PRs in the given `repository` for the given `milestone` at the given `report_path`'
26
+ end
27
+
28
+ def self.authors
29
+ ['Lorenzo Mattei']
30
+ end
31
+
32
+ def self.return_value
33
+ # If your method provides a return value, you can describe here what it does
34
+ end
35
+
36
+ def self.details
37
+ # Optional:
38
+ description
39
+ end
40
+
41
+ def self.available_options
42
+ [
43
+ FastlaneCore::ConfigItem.new(key: :repository,
44
+ env_name: 'GHHELPER_REPOSITORY',
45
+ description: 'The repository name, including the organization (e.g. `wordpress-mobile/wordpress-ios`)',
46
+ optional: false,
47
+ type: String),
48
+ FastlaneCore::ConfigItem.new(key: :report_path,
49
+ description: 'The path where the list of PRs should be written to',
50
+ optional: false,
51
+ is_string: true),
52
+ FastlaneCore::ConfigItem.new(key: :milestone,
53
+ description: 'The name of the milestone we want to fetch the list of PRs for (e.g.: `16.9`)',
54
+ optional: false,
55
+ is_string: true),
56
+ ]
57
+ end
58
+
59
+ def self.is_supported?(platform)
60
+ true
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,90 @@
1
+ require 'fastlane/action'
2
+ require_relative '../../helper/metadata_download_helper.rb'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class GpDownloadmetadataAction < Action
7
+ def self.run(params)
8
+ # fastlane will take care of reading in the parameter and fetching the environment variable:
9
+ UI.message "Project URL: #{params[:project_url]}"
10
+ UI.message "Locales: #{params[:locales].inspect}"
11
+ UI.message "Source locale: #{params[:source_locale].nil? ? '-' : params[:source_locale]}"
12
+ UI.message "Path: #{params[:download_path]}"
13
+
14
+ # Check download path
15
+ Dir.mkdir(params[:download_path]) unless File.exist?(params[:download_path])
16
+
17
+ # Download
18
+ downloader = Fastlane::Helper::MetadataDownloader.new(params[:download_path], params[:target_files])
19
+
20
+ params[:locales].each do |loc|
21
+ if loc.is_a?(Array)
22
+ puts "Downloading language: #{loc[1]}"
23
+ complete_url = "#{params[:project_url]}#{loc[0]}/default/export-translations?filters[status]=current&format=json"
24
+ downloader.download(loc[1], complete_url, loc[1] == params[:source_locale])
25
+ end
26
+
27
+ if loc.is_a?(String)
28
+ puts "Downloading language: #{loc}"
29
+ complete_url = "#{params[:project_url]}#{loc}/default/export-translations?filters[status]=current&format=json"
30
+ downloader.download(loc, complete_url, loc == params[:source_locale])
31
+ end
32
+ end
33
+ end
34
+
35
+ #####################################################
36
+ # @!group Documentation
37
+ #####################################################
38
+
39
+ def self.description
40
+ 'Download translated metadata'
41
+ end
42
+
43
+ def self.details
44
+ 'Downloads tranlated metadata from GlotPress and updates local files'
45
+ end
46
+
47
+ def self.available_options
48
+ # Define all options your action supports.
49
+
50
+ # Below a few examples
51
+ [
52
+ FastlaneCore::ConfigItem.new(key: :project_url,
53
+ env_name: 'FL_DOWNLOAD_METADATA_PROJECT_URL', # The name of the environment variable
54
+ description: 'GlotPress project URL'),
55
+ FastlaneCore::ConfigItem.new(key: :target_files,
56
+ env_name: 'FL_DOWNLOAD_METADATA_TARGET_FILES',
57
+ description: 'The hash with the path to the target files and the key to use to extract their content',
58
+ is_string: false),
59
+ FastlaneCore::ConfigItem.new(key: :locales,
60
+ env_name: 'FL_DOWNLOAD_METADATA_LOCALES',
61
+ description: 'The hash with the GLotPress locale and the project locale association',
62
+ is_string: false),
63
+ FastlaneCore::ConfigItem.new(key: :source_locale,
64
+ env_name: 'FL_DOWNLOAD_METADATA_SOURCE_LOCALE',
65
+ description: 'The source locale code',
66
+ optional: true),
67
+ FastlaneCore::ConfigItem.new(key: :download_path,
68
+ env_name: 'FL_DOWNLOAD_METADATA_DOWNLOAD_PATH',
69
+ description: 'The path of the target files',
70
+ is_string: true),
71
+ ]
72
+ end
73
+
74
+ def self.output
75
+ end
76
+
77
+ def self.return_value
78
+ # If your method provides a return value, you can describe here what it does
79
+ end
80
+
81
+ def self.authors
82
+ ['loremattei']
83
+ end
84
+
85
+ def self.is_supported?(platform)
86
+ [:ios, :android].include?(platform)
87
+ end
88
+ end
89
+ end
90
+ end