fastlane-plugin-wpmreleasetoolkit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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_relative '../../helper/github_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class SetbranchprotectionAction < Action
7
+ def self.run(params)
8
+ repository = params[:repository]
9
+ branch_name = params[:branch]
10
+ branch_prot = {}
11
+
12
+ branch_url = "https://api.github.com/repos/#{repository}/branches/" + branch_name
13
+ branch_prot[:restrictions] = { url: branch_url + '/protection/restrictions', users_url: branch_url + '/protection/restrictions/users', teams_url: branch_url + '/protection/restrictions/teams', users: [], teams: [] }
14
+ branch_prot[:enforce_admins] = nil
15
+ branch_prot[:required_pull_request_reviews] = { url: branch_url + '/protection/required_pull_request_reviews', dismiss_stale_reviews: false, require_code_owner_reviews: false }
16
+ Fastlane::Helper::GithubHelper.github_client().protect_branch(repository, branch_name, branch_prot)
17
+ end
18
+
19
+ def self.description
20
+ "Sets the 'release branch' protection state for the specified branch"
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
+ "Sets the 'release branch' protection state for the specified branch"
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: :branch,
44
+ env_name: 'GHHELPER_BRANCH',
45
+ description: 'The branch to protect',
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,81 @@
1
+ require 'fastlane/action'
2
+ require_relative '../../helper/github_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class SetfrozentagAction < Action
7
+ def self.run(params)
8
+ repository = params[:repository]
9
+ milestone_title = params[:milestone]
10
+ freeze = params[:freeze]
11
+
12
+ milestone = Fastlane::Helper::GithubHelper.get_milestone(repository, milestone_title)
13
+ UI.user_error!("Milestone #{milestone_title} not found.") if milestone.nil?
14
+
15
+ mile_title = milestone[:title]
16
+ puts freeze
17
+ if freeze
18
+ # Check if the state needs changes
19
+ if is_frozen(milestone)
20
+ UI.message("Milestone #{mile_title} is already frozen. Nothing to do")
21
+ return # Already frozen: nothing to do
22
+ end
23
+
24
+ mile_title = mile_title + ' ❄️'
25
+ else
26
+ mile_title = milestone_title
27
+ end
28
+
29
+ UI.message("New milestone: #{mile_title}")
30
+ Fastlane::Helper::GithubHelper.github_client().update_milestone(repository, milestone[:number], title: mile_title)
31
+ end
32
+
33
+ def self.is_frozen(milestone)
34
+ return milestone[:title].include?('❄️') unless milestone.nil?
35
+
36
+ return false
37
+ end
38
+
39
+ def self.description
40
+ 'Sets the frozen tag for the specified milestone'
41
+ end
42
+
43
+ def self.authors
44
+ ['Lorenzo Mattei']
45
+ end
46
+
47
+ def self.return_value
48
+ # If your method provides a return value, you can describe here what it does
49
+ end
50
+
51
+ def self.details
52
+ # Optional:
53
+ 'Sets the frozen tag for the specified milestone'
54
+ end
55
+
56
+ def self.available_options
57
+ [
58
+ FastlaneCore::ConfigItem.new(key: :repository,
59
+ env_name: 'GHHELPER_REPOSITORY',
60
+ description: 'The remote path of the GH repository on which we work',
61
+ optional: false,
62
+ type: String),
63
+ FastlaneCore::ConfigItem.new(key: :milestone,
64
+ env_name: 'GHHELPER_MILESTORE',
65
+ description: 'The GitHub milestone',
66
+ optional: false,
67
+ type: String),
68
+ FastlaneCore::ConfigItem.new(key: :freeze,
69
+ description: 'The GitHub milestone',
70
+ optional: false,
71
+ default_value: true,
72
+ is_string: false),
73
+ ]
74
+ end
75
+
76
+ def self.is_supported?(platform)
77
+ true
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,96 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+ require 'fileutils'
4
+ require 'json'
5
+
6
+ require_relative '../../helper/filesystem_helper'
7
+ require_relative '../../helper/configure_helper'
8
+
9
+ module Fastlane
10
+ module Actions
11
+ class ConfigureAddFilesToCopyAction < Action
12
+ def self.run(params = {})
13
+ continue = true
14
+
15
+ while continue
16
+
17
+ confirmation = 'Do you want to specify a file that should be copied from the secrets repository into your project?'
18
+
19
+ confirmation = 'Do you want to specify additional files that should be copied from the secrets repository into your project?' if Fastlane::Helper::ConfigureHelper.has_files
20
+
21
+ if UI.confirm(confirmation)
22
+ add_file
23
+ else
24
+ continue = false
25
+ end
26
+
27
+ Fastlane::Helper::ConfigureHelper.files_to_copy.each do |file_reference|
28
+ file_reference.update
29
+ end
30
+ end
31
+ end
32
+
33
+ ### Walks the user through adding a file to the project's `/.configure `file.
34
+ ###
35
+ def self.add_file
36
+ invalid_file = true
37
+
38
+ while invalid_file
39
+ UI.header 'Please provide the location of the source file relative to the secrets repository'
40
+ UI.message 'Example: google-services.json'
41
+
42
+ source = UI.input('Source File Path:')
43
+ sourcePath = absolute_secret_store_path(source) # Transform the relative path into an absolute path.
44
+
45
+ # Don't allow the developer to accidentally specify an invalid file, otherwise validation will never succeed.
46
+ if File.file?(sourcePath)
47
+ invalid_file = false
48
+ else
49
+ UI.error "There is no file at #{sourcePath}."
50
+ end
51
+ end
52
+
53
+ UI.header 'Please provide the destination of the file relative to the project root'
54
+ UI.message 'Example: WordPress/google-services.json'
55
+
56
+ destination = UI.input('Destination File Path:') # Leave the destination as a relative path, as no validation is required.
57
+
58
+ encrypt = UI.confirm('Encrypt file?:')
59
+
60
+ Fastlane::Helper::ConfigureHelper.add_file(source: source, destination: destination, encrypt: encrypt)
61
+ end
62
+
63
+ def self.secret_store_dir
64
+ Fastlane::Helper::FilesystemHelper.secret_store_dir
65
+ end
66
+
67
+ def self.absolute_secret_store_path(relative_path)
68
+ Fastlane::Helper::FilesystemHelper.absolute_secret_store_path(relative_path)
69
+ end
70
+
71
+ def self.description
72
+ 'Interactively add files to the `files_to_copy` list in .configure.'
73
+ end
74
+
75
+ def self.authors
76
+ ['Jeremy Massel']
77
+ end
78
+
79
+ def self.return_value
80
+ # If your method provides a return value, you can describe here what it does
81
+ end
82
+
83
+ def self.details
84
+ 'Interactively add files to the `files_to_copy` list in .configure.'
85
+ end
86
+
87
+ def self.available_options
88
+ []
89
+ end
90
+
91
+ def self.is_supported?(platform)
92
+ true
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,139 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+ require 'fileutils'
4
+ require 'diffy'
5
+
6
+ require_relative '../../helper/filesystem_helper'
7
+ require_relative '../../helper/configure_helper'
8
+
9
+ module Fastlane
10
+ module Actions
11
+ class ConfigureApplyAction < Action
12
+ def self.run(params = {})
13
+ # Preflight
14
+ UI.user_error!('Decryption key could not be found') if Fastlane::Helper::ConfigureHelper.encryption_key.nil?
15
+
16
+ # Checkout the right commit hash etc. before applying the configuration
17
+ prepare_repository do
18
+ # Copy/decrypt the files
19
+ files_to_copy.each do |file_reference|
20
+ apply_file(file_reference, params[:force])
21
+ end
22
+ end
23
+ UI.success 'Applied configuration'
24
+ end
25
+
26
+ def self.prepare_repository
27
+ secrets_respository_exists = File.exist?(repository_path)
28
+
29
+ # If the secrets repo doesn't exist, just run the block
30
+ unless secrets_respository_exists
31
+ # Run the provided block, and return
32
+ yield
33
+ return
34
+ end
35
+
36
+ ### Make sure secrets repo is at the proper hash as specified in .configure.
37
+ repo_hash = Fastlane::Helper::ConfigureHelper.repo_commit_hash
38
+ file_hash = Fastlane::Helper::ConfigureHelper.configure_file_commit_hash
39
+
40
+ ### Get the ref to restore the repo to
41
+ original_repo_ref = Fastlane::Helper::ConfigureHelper.repo_branch_name
42
+ original_repo_ref = repo_hash if original_repo_ref.nil?
43
+
44
+ other_action.sh(command: "cd #{repository_path} && git fetch && git checkout #{file_hash}", log: false) unless repo_hash == file_hash
45
+
46
+ # Run the provided block
47
+ yield
48
+
49
+ ### Restore secrets repo to original branch. If it was originally in a
50
+ ### detached HEAD state, we need to use the hash since there's no branch name.
51
+ other_action.sh(command: "cd #{repository_path} && git checkout #{original_repo_ref}", log: false)
52
+ end
53
+
54
+ ### Check with the user whether we should overwrite the file, if it exists
55
+ ###
56
+ def self.apply_file(file_reference, force)
57
+ # If the file doesn't exist or force is true, we don't need to confirm
58
+ if !File.file?(file_reference.destination) || force
59
+ file_reference.apply
60
+ return # Don't continue if we were able to copy the file without conflict
61
+ end
62
+
63
+ unless file_reference.needs_apply?
64
+ return # Nothing to do if the files are identical
65
+ end
66
+
67
+ puts Diffy::Diff.new(file_reference.destination_contents, file_reference.source_contents) if UI.confirm("#{file_reference.destination} has changes that need to be merged. Would you like to see a diff?")
68
+
69
+ if UI.confirm("Would you like to make a backup of #{file_reference.destination}?")
70
+ extension = File.extname(file_reference.destination)
71
+ base = File.basename(Pathname.new(file_reference.destination), extension)
72
+
73
+ date_string = Time.now.strftime('%m-%d-%Y--%H-%M-%S')
74
+
75
+ backup_path = base
76
+ .concat('-') # Handy-dandy separator
77
+ .concat(date_string) # date string to allow multiple backups
78
+ .concat(extension) # and the original file extension
79
+ .concat('.bak') # add the .bak file extension - easier to .gitignore
80
+
81
+ # Create the destination directory if it doesn't exist
82
+ FileUtils.mkdir_p(Pathname.new(file_reference.destination).dirname)
83
+ FileUtils.cp(file_reference.destination, backup_path)
84
+ end
85
+
86
+ if UI.confirm("Would you like to overwrite #{file_reference.destination}?")
87
+ file_reference.apply
88
+ else
89
+ UI.message "Skipping #{file_reference.destination}"
90
+ end
91
+ rescue StandardError => e
92
+ UI.user_error!(e)
93
+ end
94
+
95
+ def self.repository_path
96
+ Fastlane::Helper::FilesystemHelper.secret_store_dir
97
+ end
98
+
99
+ def self.files_to_copy
100
+ Fastlane::Helper::ConfigureHelper.files_to_copy
101
+ end
102
+
103
+ def self.absolute_project_path(relative_path)
104
+ Fastlane::Helper::FilesystemHelper.absolute_project_path(relative_path)
105
+ end
106
+
107
+ def self.absolute_secret_store_path(relative_path)
108
+ Fastlane::Helper::FilesystemHelper.absolute_secret_store_path(relative_path)
109
+ end
110
+
111
+ def self.description
112
+ 'Copy files specified in `.config` from the secrets repository to the project. Specify force:true to avoid confirmation'
113
+ end
114
+
115
+ def self.authors
116
+ ['Jeremy Massel']
117
+ end
118
+
119
+ def self.details
120
+ 'Copy files specified in `.config` from the secrets repository to the project. Specify force:true to avoid confirmation'
121
+ end
122
+
123
+ def self.available_options
124
+ [
125
+ FastlaneCore::ConfigItem.new(key: :force,
126
+ env_name: 'FORCE_OVERWRITE',
127
+ description: 'Overwrite copied files without confirmation',
128
+ optional: true,
129
+ default_value: false,
130
+ is_string: false),
131
+ ]
132
+ end
133
+
134
+ def self.is_supported?(platform)
135
+ true
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,57 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+ require 'fileutils'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class ConfigureDownloadAction < Action
8
+ def self.run(params = {})
9
+ UI.message 'Running Configure Download'
10
+
11
+ # If the `~/.mobile-secrets` repository doesn't exist
12
+ unless File.directory?(secrets_dir)
13
+ UI.user_error!("The local secrets store does not exist. Please clone it to #{secrets_dir} before continuing.")
14
+ else
15
+ update_repository # If the repo already exists, just update it
16
+ end
17
+ end
18
+
19
+ # Ensure the git repository at `~/.mobile-secrets` is up to date.
20
+ # If the secrets repo is in a detached HEAD state, skip the pull,
21
+ # since it will fail.
22
+ def self.update_repository
23
+ secrets_repo_branch = Fastlane::Helper::ConfigureHelper.repo_branch_name
24
+
25
+ sh("cd #{secrets_dir} && git pull") unless secrets_repo_branch.nil?
26
+ end
27
+
28
+ def self.secrets_dir
29
+ Fastlane::Helper::FilesystemHelper.secret_store_dir
30
+ end
31
+
32
+ def self.description
33
+ 'Updates the mobile secrets.'
34
+ end
35
+
36
+ def self.authors
37
+ ['Jeremy Massel']
38
+ end
39
+
40
+ def self.return_value
41
+ # If your method provides a return value, you can describe here what it does
42
+ end
43
+
44
+ def self.details
45
+ 'Pulls down the latest remote changes to the ~/.mobile-secrets repository.'
46
+ end
47
+
48
+ def self.available_options
49
+ []
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ true
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,86 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core/ui/ui'
3
+ require 'fileutils'
4
+ require 'git'
5
+
6
+ require_relative '../../helper/filesystem_helper'
7
+ require_relative '../../helper/configure_helper'
8
+
9
+ module Fastlane
10
+ module Actions
11
+ class ConfigureSetupAction < Action
12
+ def self.run(params = {})
13
+ # Check to see if the local secret storage is set up at ~/.mobile-secrets.
14
+ UI.user_error!('The local secrets store does not exist. Please clone it to ~/.mobile-secrets before continuing.') unless File.directory?(repository_path)
15
+
16
+ # Checks to see if .configure exists. If so, exit – there’s no need to continue as everything is set up.
17
+ if configuration_file_exists
18
+ UI.success 'Configure file exists – exiting.'
19
+ return
20
+ end
21
+
22
+ # The mobile secrets repo must be up to date in order to generate and save the encryption key
23
+ prompt_to_update_to_most_recent_version if Fastlane::Helper::ConfigureHelper.repo_is_behind_remote
24
+
25
+ # Generate an encryption key for the new project, if needed
26
+ Fastlane::Helper::ConfigureHelper.update_project_encryption_key if Fastlane::Helper::ConfigureHelper.project_encryption_key.nil?
27
+
28
+ # Write out the `.configure` file.
29
+ Fastlane::Helper::ConfigureHelper.update_configure_file_from_repository
30
+
31
+ # Walk the user through adding files to copy to the `.configure` file.
32
+ ConfigureAddFilesToCopyAction.run
33
+
34
+ # Copy the files we just walked the user through setting up.
35
+ ConfigureApplyAction.run
36
+
37
+ UI.success 'Created .configure file'
38
+ end
39
+
40
+ def self.prompt_to_update_to_most_recent_version
41
+ if UI.confirm("The current branch is #{Fastlane::Helper::ConfigureHelper.repo_commits_behind_remote} commit(s) behind. It must be updated to complete the setup. Would you like to continue?")
42
+ update_branch
43
+ else
44
+ UI.user_error!('Cannot complete setup when the repo is not up to date.')
45
+ end
46
+ end
47
+
48
+ ### Ensure that the local secrets respository is up to date
49
+ def self.update_branch
50
+ sh("cd '#{Fastlane::Helper::FilesystemHelper.secret_store_dir}' && git pull")
51
+ end
52
+
53
+ def self.configuration_file_exists
54
+ Fastlane::Helper::ConfigureHelper.configuration_path_exists
55
+ end
56
+
57
+ def self.repository_path
58
+ Fastlane::Helper::FilesystemHelper.secret_store_dir
59
+ end
60
+
61
+ def self.description
62
+ 'Set up the .configure file'
63
+ end
64
+
65
+ def self.authors
66
+ ['Jeremy Massel']
67
+ end
68
+
69
+ def self.return_value
70
+ # If your method provides a return value, you can describe here what it does
71
+ end
72
+
73
+ def self.details
74
+ 'Interactively walks the user through setting up the `.configure` file. Assumes the ~/.mobile-secrets directory exists'
75
+ end
76
+
77
+ def self.available_options
78
+ []
79
+ end
80
+
81
+ def self.is_supported?(platform)
82
+ true
83
+ end
84
+ end
85
+ end
86
+ end