fastlane-plugin-wpmreleasetoolkit 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb +8 -3
  3. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +8 -2
  4. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +11 -4
  5. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +10 -4
  6. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb +90 -0
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb +89 -0
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +2 -0
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +1 -1
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +8 -2
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +10 -5
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +10 -4
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_download_strings_files_from_glotpress.rb +113 -0
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_generate_strings_file_from_code.rb +115 -0
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +5 -5
  16. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +6 -7
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_strings_files.rb +75 -0
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +0 -20
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +8 -0
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +3 -0
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +48 -8
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/interactive_prompt_reminder.rb +93 -0
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +3 -2
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_helper.rb +108 -173
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb +207 -0
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +3 -3
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb +1 -4
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
  29. metadata +26 -39
  30. data/bin/drawText +0 -20
  31. data/ext/drawText/drawText/Assets/style.css +0 -1
  32. data/ext/drawText/drawText/CoreTextStack.swift +0 -113
  33. data/ext/drawText/drawText/Helpers/CommandLineHelpers.swift +0 -36
  34. data/ext/drawText/drawText/Helpers/Extensions.swift +0 -27
  35. data/ext/drawText/drawText/Helpers/FileSystemHelper.swift +0 -24
  36. data/ext/drawText/drawText/Stylesheet.swift +0 -48
  37. data/ext/drawText/drawText/TextImage.swift +0 -100
  38. data/ext/drawText/drawText/main.swift +0 -61
  39. data/ext/drawText/drawText Tests/DigitParsingTests.swift +0 -21
  40. data/ext/drawText/drawText Tests/ExtensionsTests.swift +0 -5
  41. data/ext/drawText/drawText Tests/Info.plist +0 -22
  42. data/ext/drawText/drawText Tests/StylesheetTests.swift +0 -31
  43. data/ext/drawText/drawText Tests/Test Cases/default-stylesheet.txt +0 -10
  44. data/ext/drawText/drawText Tests/Test Cases/external-styles-sample.css +0 -3
  45. data/ext/drawText/drawText Tests/Test Cases/external-styles-test.txt +0 -13
  46. data/ext/drawText/drawText Tests/Test Cases/large-text-block.txt +0 -1
  47. data/ext/drawText/drawText Tests/Test Cases/regular-text-block.txt +0 -2
  48. data/ext/drawText/drawText Tests/Test Cases/rtl-text-block.txt +0 -2
  49. data/ext/drawText/drawText Tests/Test Cases/text-size-adjustment-test.txt +0 -10
  50. data/ext/drawText/drawText Tests/TextImageTests.swift +0 -99
  51. data/ext/drawText/drawText Tests/drawText_Tests.swift +0 -14
  52. data/ext/drawText/drawText.xcodeproj/project.pbxproj +0 -508
  53. data/ext/drawText/drawText.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  54. data/ext/drawText/drawText.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  55. data/ext/drawText/drawText.xcodeproj/xcshareddata/xcschemes/drawText Tests.xcscheme +0 -57
  56. data/ext/drawText/drawText.xcodeproj/xcshareddata/xcschemes/drawText.xcscheme +0 -109
  57. data/ext/drawText/extconf.rb +0 -36
  58. data/ext/drawText/makefile.example +0 -8
  59. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_merge_translators_strings.rb +0 -106
  60. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_metadata.rb +0 -52
  61. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_merge_translators_strings.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebad531acd982b1354116d3f924974a8376da07fc7014646c19d40097fb0ca6e
4
- data.tar.gz: 6594d0af0ddd193cb12007d7cc145c11c519129e3df226091b1fae6f608f8c3a
3
+ metadata.gz: d2f92b2b90c9f077ad4ea0ae25c5c84f0345ca2fb5e186d1c0cdfab70ea40770
4
+ data.tar.gz: 0c919f8e9ca2af18c3488898efe2fe48f4ca5a3a4c0464991e000681cc6c9546
5
5
  SHA512:
6
- metadata.gz: 81278eaaa129a68388f06f55b125254a5464ba146af61c8f8f4a6dc6905bd4ede2774950ee7b4d045e3e88d202e38b57e093bda8ce3ccae0a712ca346a79e68d
7
- data.tar.gz: fab14969f2a2063c6b0a5ee451dd72220416355b93c66b55e9c80656f247de8bbba8e67f4b455f46d6636950139a57e0a86d6cbbbee6065d52113757d3d8e233
6
+ metadata.gz: f0c0797c28da54495d995d856edb238631b70bf0126ae1516638a75e300717dd51a7f97f6fedd5cc3f9e7eef4e9cf328043c9fffcd34233a057338da8055307d
7
+ data.tar.gz: 17c8536dc94ab2ea0f3b394d3d9768c248683ba78fa4558d7c10ed1cc7fe81fc0aebd1390691282db601297b6f48e67af2dbd546daa3b0a13d16ffacd8c34f4c
@@ -36,12 +36,17 @@ module Fastlane
36
36
  FastlaneCore::ConfigItem.new(key: :app_strings_path,
37
37
  description: 'The path of the main strings file',
38
38
  optional: false,
39
- is_string: true),
39
+ type: String),
40
+ # The name of this parameter is a bit misleading due to legacy. In practice it's expected to be an Array of Hashes, each describing a library to merge.
41
+ # See `Fastlane::Helper::Android::LocalizeHelper.merge_lib`'s YARD doc for more details on the keys expected for each Hash.
40
42
  FastlaneCore::ConfigItem.new(key: :libs_strings_path,
41
43
  env_name: 'LOCALIZE_LIBS_STRINGS_PATH',
42
- description: 'The list of libs to merge',
44
+ description: 'The list of libs to merge. ' \
45
+ + 'Each item in the provided array must be a Hash with the keys `:library` (The library display name),' \
46
+ + '`:strings_path` (The path to the `strings.xml` file of the library) and ' \
47
+ + '`:exclusions` (Array of string keys to exclude from merging)',
43
48
  optional: false,
44
- is_string: false),
49
+ type: Array),
45
50
  ]
46
51
  end
47
52
 
@@ -8,8 +8,9 @@ module Fastlane
8
8
  require_relative '../../helper/android/android_version_helper'
9
9
  require_relative '../../helper/android/android_git_helper'
10
10
 
11
- # Checkout develop and update
12
- Fastlane::Helper::GitHelper.checkout_and_pull('develop')
11
+ # Checkout default branch and update
12
+ default_branch = params[:default_branch]
13
+ Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)
13
14
 
14
15
  # Check versions
15
16
  release_version = Fastlane::Helper::Android::VersionHelper.get_release_version
@@ -80,6 +81,11 @@ module Fastlane
80
81
  description: 'Skips confirmation',
81
82
  is_string: false, # true: verifies the input is a string, false: every kind of value
82
83
  default_value: false), # the default value if the user didn't provide one
84
+ FastlaneCore::ConfigItem.new(key: :default_branch,
85
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
86
+ description: 'Default branch of the repository',
87
+ type: String,
88
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
83
89
  ]
84
90
  end
85
91
 
@@ -8,7 +8,8 @@ module Fastlane
8
8
  require_relative '../../helper/android/android_version_helper'
9
9
  require_relative '../../helper/android/android_git_helper'
10
10
 
11
- other_action.ensure_git_branch(branch: 'develop')
11
+ default_branch = params[:default_branch]
12
+ other_action.ensure_git_branch(branch: default_branch)
12
13
 
13
14
  # Create new configuration
14
15
  new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release
@@ -28,9 +29,9 @@ module Fastlane
28
29
  UI.message("New version: #{new_short_version}")
29
30
  UI.message("Release branch: #{new_release_branch}")
30
31
 
31
- # Update local develop and branch
32
+ # Update local default branch and create branch from it
32
33
  UI.message 'Creating new branch...'
33
- Fastlane::Helper::GitHelper.create_branch(new_release_branch, from: 'develop')
34
+ Fastlane::Helper::GitHelper.create_branch(new_release_branch, from: default_branch)
34
35
  UI.message 'Done!'
35
36
 
36
37
  UI.message 'Updating app version...'
@@ -52,7 +53,13 @@ module Fastlane
52
53
  end
53
54
 
54
55
  def self.available_options
55
- # Define all options your action supports.
56
+ [
57
+ FastlaneCore::ConfigItem.new(key: :default_branch,
58
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
59
+ description: 'Default branch of the repository',
60
+ type: String,
61
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
62
+ ]
56
63
  end
57
64
 
58
65
  def self.output
@@ -11,8 +11,9 @@ module Fastlane
11
11
  require_relative '../../helper/android/android_version_helper'
12
12
  require_relative '../../helper/android/android_git_helper'
13
13
 
14
- # Checkout develop and update
15
- Fastlane::Helper::GitHelper.checkout_and_pull('develop')
14
+ # Checkout default branch and update
15
+ default_branch = params[:default_branch]
16
+ Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)
16
17
 
17
18
  # Create versions
18
19
  current_version = Fastlane::Helper::Android::VersionHelper.get_release_version
@@ -23,7 +24,7 @@ module Fastlane
23
24
  no_alpha_version_message = "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this app\n"
24
25
  # Ask user confirmation
25
26
  unless params[:skip_confirm]
26
- confirm_message = "Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n"
27
+ confirm_message = "Building a new release branch starting from #{default_branch}.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n"
27
28
  confirm_message += current_alpha_version.nil? ? no_alpha_version_message : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n"
28
29
  confirm_message += "After codefreeze the new version will be: #{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n"
29
30
  confirm_message += current_alpha_version.nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n"
@@ -47,7 +48,7 @@ module Fastlane
47
48
  end
48
49
 
49
50
  def self.details
50
- 'Updates the develop branch, checks the app version and ensure the branch is clean'
51
+ 'Updates the default branch, checks the app version and ensure the branch is clean'
51
52
  end
52
53
 
53
54
  def self.available_options
@@ -58,6 +59,11 @@ module Fastlane
58
59
  description: 'Skips confirmation before codefreeze',
59
60
  is_string: false, # true: verifies the input is a string, false: every kind of value
60
61
  default_value: false), # the default value if the user didn't provide one
62
+ FastlaneCore::ConfigItem.new(key: :default_branch,
63
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
64
+ description: 'Default branch of the repository',
65
+ type: String,
66
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
61
67
  ]
62
68
  end
63
69
 
@@ -0,0 +1,90 @@
1
+ module Fastlane
2
+ module Actions
3
+ class BuildkiteTriggerBuildAction < Action
4
+ def self.run(params)
5
+ require 'buildkit'
6
+
7
+ UI.message "Triggering build on branch #{params[:branch]}, commit #{params[:commit]}, using pipeline from #{params[:pipeline_file]}"
8
+
9
+ pipeline_name = {
10
+ PIPELINE: params[:pipeline_file]
11
+ }
12
+
13
+ client = Buildkit.new(token: params[:buildkite_token])
14
+ response = client.create_build(
15
+ params[:buildkite_organization],
16
+ params[:buildkite_pipeline],
17
+ {
18
+ branch: params[:branch],
19
+ commit: params[:commit],
20
+ env: params[:environment].merge(pipeline_name)
21
+ }
22
+ )
23
+
24
+ response.state == 'scheduled' ? UI.message('Done!') : UI.crash!("Failed to start job\nError: [#{response}]")
25
+ end
26
+
27
+ #####################################################
28
+ # @!group Documentation
29
+ #####################################################
30
+
31
+ def self.description
32
+ 'Triggers a job on Buildkite'
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(
38
+ key: :buildkite_token,
39
+ env_name: 'BUILDKITE_TOKEN',
40
+ description: 'Buildkite Personal Access Token',
41
+ type: String,
42
+ sensitive: true
43
+ ),
44
+ FastlaneCore::ConfigItem.new(
45
+ key: :buildkite_organization,
46
+ env_name: 'BUILDKITE_ORGANIZTION',
47
+ description: 'The Buildkite organization that contains your pipeline',
48
+ type: String
49
+ ),
50
+ FastlaneCore::ConfigItem.new(
51
+ key: :buildkite_pipeline,
52
+ env_name: 'BUILDKITE_PIPELINE',
53
+ description: %(The Buildkite pipeline you'd like to build),
54
+ type: String
55
+ ),
56
+ FastlaneCore::ConfigItem.new(
57
+ key: :branch,
58
+ description: 'The branch you want to build',
59
+ type: String
60
+ ),
61
+ FastlaneCore::ConfigItem.new(
62
+ key: :commit,
63
+ description: 'The commit hash you want to build',
64
+ type: String,
65
+ default_value: 'HEAD'
66
+ ),
67
+ FastlaneCore::ConfigItem.new(
68
+ key: :pipeline_file,
69
+ description: 'The name of the pipeline file in the project',
70
+ type: String
71
+ ),
72
+ FastlaneCore::ConfigItem.new(
73
+ key: :environment,
74
+ description: 'Any additional environment variables to provide to the job',
75
+ type: Hash,
76
+ default_value: {}
77
+ ),
78
+ ]
79
+ end
80
+
81
+ def self.authors
82
+ ['Automattic']
83
+ end
84
+
85
+ def self.is_supported?(platform)
86
+ true
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,89 @@
1
+ require 'fastlane/action'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ module SharedValues
6
+ PR_COMMENT_REUSE_IDENTIFIER = :PR_COMMENT_REUSE_IDENTIFIER
7
+ end
8
+
9
+ class CommentOnPrAction < Action
10
+ def self.run(params)
11
+ require_relative '../../helper/github_helper'
12
+
13
+ reuse_identifier = Fastlane::Helper::GithubHelper.comment_on_pr(
14
+ project_slug: params[:project],
15
+ pr_number: params[:pr_number],
16
+ body: params[:body],
17
+ reuse_identifier: params[:reuse_identifier]
18
+ )
19
+
20
+ Actions.lane_context[SharedValues::PR_COMMENT_REUSE_IDENTIFIER] = reuse_identifier
21
+
22
+ reuse_identifier
23
+ end
24
+
25
+ def self.description
26
+ 'Post a comment on a given PR number (optionally updating an existing one)'
27
+ end
28
+
29
+ def self.authors
30
+ ['Automattic']
31
+ end
32
+
33
+ def self.details
34
+ <<~DETAILS
35
+ If used just once, this method makes it nice and easy to post a quick comment to a GitHub PR.
36
+
37
+ Subsequent runs will allow you to update an existing comment as many times as you need to
38
+ (e.g. across multiple CI runs), by using a `:reuse_identifier` to identify the comment to update.
39
+ DETAILS
40
+ end
41
+
42
+ def self.available_options
43
+ [
44
+ FastlaneCore::ConfigItem.new(
45
+ key: :access_token,
46
+ env_name: 'GITHUB_TOKEN',
47
+ description: 'The GitHub token to use for posting the comment',
48
+ type: String
49
+ ),
50
+ FastlaneCore::ConfigItem.new(
51
+ key: :reuse_identifier,
52
+ description: 'If provided, the reuse identifier can identify an existing comment to overwrite',
53
+ type: String,
54
+ default_value: nil
55
+ ),
56
+ FastlaneCore::ConfigItem.new(
57
+ key: :project,
58
+ description: 'The project slug (ex: `wordpress-mobile/wordpress-ios`)',
59
+ type: String
60
+ ),
61
+ FastlaneCore::ConfigItem.new(
62
+ key: :pr_number,
63
+ description: 'The PR number',
64
+ type: Integer
65
+ ),
66
+ FastlaneCore::ConfigItem.new(
67
+ key: :body,
68
+ description: 'The content of the comment',
69
+ type: String
70
+ ),
71
+ ]
72
+ end
73
+
74
+ def self.output
75
+ [
76
+ ['PR_COMMENT_REUSE_IDENTIFIER', 'The `reuse_identifier` for the most recently posted comment'],
77
+ ]
78
+ end
79
+
80
+ def self.return_value
81
+ 'The `reuse_identifier` for the posted comment (useful for updating it later, if needed)'
82
+ end
83
+
84
+ def self.is_supported?(platform)
85
+ true
86
+ end
87
+ end
88
+ end
89
+ end
@@ -11,6 +11,8 @@ module Fastlane
11
11
  version = params[:version]
12
12
  assets = params[:release_assets]
13
13
  release_notes = params[:release_notes_file_path].nil? ? '' : File.read(params[:release_notes_file_path])
14
+ # Replace full URLS to PRs/Issues with shorthand, because GitHub does not render them properly otherwise.
15
+ release_notes.gsub!(%r{https://github.com/([^/]*/[^/]*)/(pulls?|issues?)/([0-9]*)}, '\1#\3')
14
16
  prerelease = params[:prerelease]
15
17
 
16
18
  UI.message("Creating draft release #{version} in #{repository}.")
@@ -58,7 +58,7 @@ module Fastlane
58
58
  is_string: false),
59
59
  FastlaneCore::ConfigItem.new(key: :locales,
60
60
  env_name: 'FL_DOWNLOAD_METADATA_LOCALES',
61
- description: 'The hash with the GLotPress locale and the project locale association',
61
+ description: 'The hash with the GlotPress locale and the project locale association',
62
62
  is_string: false),
63
63
  FastlaneCore::ConfigItem.new(key: :source_locale,
64
64
  env_name: 'FL_DOWNLOAD_METADATA_SOURCE_LOCALE',
@@ -8,8 +8,9 @@ module Fastlane
8
8
  require_relative '../../helper/ios/ios_version_helper'
9
9
  require_relative '../../helper/ios/ios_git_helper'
10
10
 
11
- # Checkout develop and update
12
- Fastlane::Helper::GitHelper.checkout_and_pull('develop')
11
+ # Checkout default branch and update
12
+ default_branch = params[:default_branch]
13
+ Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)
13
14
 
14
15
  # Check versions
15
16
  build_version = Fastlane::Helper::Ios::VersionHelper.get_build_version
@@ -69,6 +70,11 @@ module Fastlane
69
70
  description: 'Skips confirmation',
70
71
  is_string: false, # true: verifies the input is a string, false: every kind of value
71
72
  default_value: false), # the default value if the user didn't provide one
73
+ FastlaneCore::ConfigItem.new(key: :default_branch,
74
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
75
+ description: 'Default branch of the repository',
76
+ type: String,
77
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
72
78
  ]
73
79
  end
74
80
 
@@ -8,16 +8,17 @@ module Fastlane
8
8
  require_relative '../../helper/ios/ios_version_helper'
9
9
  require_relative '../../helper/ios/ios_git_helper'
10
10
 
11
- other_action.ensure_git_branch(branch: 'develop')
11
+ default_branch = params[:default_branch]
12
+ other_action.ensure_git_branch(branch: default_branch)
12
13
 
13
14
  # Create new configuration
14
15
  @new_version = Fastlane::Helper::Ios::VersionHelper.bump_version_release()
15
16
  create_config()
16
17
  show_config()
17
18
 
18
- # Update local develop and branch
19
- Fastlane::Helper::GitHelper.checkout_and_pull('develop')
20
- Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: 'develop')
19
+ # Update local default branch and create branch from it
20
+ Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)
21
+ Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: default_branch)
21
22
  UI.message 'Done!'
22
23
 
23
24
  UI.message 'Updating glotPressKeys...' unless params[:skip_glotpress]
@@ -64,7 +65,11 @@ module Fastlane
64
65
  description: 'Skips Deliver key update',
65
66
  is_string: false, # true: verifies the input is a string, false: every kind of value
66
67
  default_value: false), # the default value if the user didn't provide one
67
-
68
+ FastlaneCore::ConfigItem.new(key: :default_branch,
69
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
70
+ description: 'Default branch of the repository',
71
+ type: String,
72
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
68
73
  ]
69
74
  end
70
75
 
@@ -8,8 +8,9 @@ module Fastlane
8
8
  require_relative '../../helper/ios/ios_version_helper'
9
9
  require_relative '../../helper/ios/ios_git_helper'
10
10
 
11
- # Checkout develop and update
12
- Fastlane::Helper::GitHelper.checkout_and_pull('develop')
11
+ # Checkout default branch and update
12
+ default_branch = params[:default_branch]
13
+ Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)
13
14
 
14
15
  # Create versions
15
16
  current_version = Fastlane::Helper::Ios::VersionHelper.get_public_version
@@ -17,7 +18,7 @@ module Fastlane
17
18
  next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(current_version)
18
19
 
19
20
  # Ask user confirmation
20
- unless params[:skip_confirm] || UI.confirm("Building a new release branch starting from develop.\nCurrent version is #{current_version} (#{current_build_version}).\nAfter codefreeze the new version will be: #{next_version}.\nDo you want to continue?")
21
+ unless params[:skip_confirm] || UI.confirm("Building a new release branch starting from #{default_branch}.\nCurrent version is #{current_version} (#{current_build_version}).\nAfter codefreeze the new version will be: #{next_version}.\nDo you want to continue?")
21
22
  UI.user_error!('Aborted by user request')
22
23
  end
23
24
 
@@ -37,7 +38,7 @@ module Fastlane
37
38
  end
38
39
 
39
40
  def self.details
40
- 'Updates the develop branch, checks the app version and ensure the branch is clean'
41
+ 'Updates the default branch, checks the app version and ensure the branch is clean'
41
42
  end
42
43
 
43
44
  def self.available_options
@@ -48,6 +49,11 @@ module Fastlane
48
49
  description: 'Skips confirmation before codefreeze',
49
50
  is_string: false, # true: verifies the input is a string, false: every kind of value
50
51
  default_value: false), # the default value if the user didn't provide one
52
+ FastlaneCore::ConfigItem.new(key: :default_branch,
53
+ env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
54
+ description: 'Default branch of the repository',
55
+ type: String,
56
+ default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
51
57
  ]
52
58
  end
53
59
 
@@ -0,0 +1,113 @@
1
+ module Fastlane
2
+ module Actions
3
+ class IosDownloadStringsFilesFromGlotpressAction < Action
4
+ def self.run(params)
5
+ # TODO: Once we introduce the `Locale` POD via #296, check if the param is an array of locales and if so convert it to Hash{glotpress=>lproj}
6
+ locales = params[:locales]
7
+ download_dir = params[:download_dir]
8
+
9
+ UI.user_error!("The parent directory `#{download_dir}` (which contains all the `*.lproj` subdirectories) must already exist") unless Dir.exist?(download_dir)
10
+
11
+ locales.each do |glotpress_locale, lproj_name|
12
+ # Download the export in the proper `.lproj` directory
13
+ lproj_dir = File.join(download_dir, "#{lproj_name}.lproj")
14
+ destination = File.join(lproj_dir, "#{params[:table_basename]}.strings")
15
+ FileUtils.mkdir(lproj_dir) unless Dir.exist?(lproj_dir)
16
+
17
+ Fastlane::Helper::Ios::L10nHelper.download_glotpress_export_file(
18
+ project_url: params[:project_url],
19
+ locale: glotpress_locale,
20
+ filters: params[:filters],
21
+ destination: destination
22
+ )
23
+ # Do a quick check of the downloaded `.strings` file to ensure it looks valid
24
+ validate_strings_file(destination) unless params[:skip_file_validation]
25
+ end
26
+ end
27
+
28
+ # Validate that a `.strings` file downloaded from GlotPress seems valid and does not contain empty translations
29
+ def self.validate_strings_file(destination)
30
+ return unless File.exist?(destination) # If the file failed to download, don't try to validate an non-existing file. We'd already have a separate error for the download failure anyway.
31
+
32
+ translations = Fastlane::Helper::Ios::L10nHelper.read_strings_file_as_hash(path: destination)
33
+ empty_keys = translations.select { |_, value| value.nil? || value.empty? }.keys.sort
34
+ unless empty_keys.empty?
35
+ UI.error(
36
+ "Found empty translations in `#{destination}` for the following keys: #{empty_keys.inspect}.\n" \
37
+ + "This is likely a GlotPress bug, and will lead to copies replaced by empty text in the UI.\n" \
38
+ + 'Please report this to the GlotPress team, and fix the file locally before continuing.'
39
+ )
40
+ end
41
+ rescue StandardError => e
42
+ UI.error("Error while validating the file exported from GlotPress (`#{destination}`) - #{e.message.chomp}")
43
+ end
44
+
45
+ #####################################################
46
+ # @!group Documentation
47
+ #####################################################
48
+
49
+ def self.description
50
+ 'Downloads the `.strings` files from GlotPress for the various locales'
51
+ end
52
+
53
+ def self.details
54
+ <<~DETAILS
55
+ Downloads the `.strings` files from GlotPress for the various locales,
56
+ validates them, and saves them in the relevant `*.lproj` directories for each locale
57
+ DETAILS
58
+ end
59
+
60
+ def self.available_options
61
+ [
62
+ FastlaneCore::ConfigItem.new(key: :project_url,
63
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_PROJECT_URL',
64
+ description: 'URL to the GlotPress project',
65
+ type: String),
66
+ FastlaneCore::ConfigItem.new(key: :locales,
67
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_LOCALES',
68
+ description: 'The map of locales to download, each entry of the Hash corresponding to a { glotpress-locale-code => lproj-folder-basename } pair',
69
+ type: Hash), # TODO: also support an Array of `Locale` POD/struct type when we introduce it later (see #296)
70
+ FastlaneCore::ConfigItem.new(key: :download_dir,
71
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_DOWNLOAD_DIR',
72
+ description: 'The parent directory containing all the `*.lproj` subdirectories in which the downloaded files will be saved',
73
+ type: String),
74
+ FastlaneCore::ConfigItem.new(key: :table_basename,
75
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_TABLE_BASENAME',
76
+ description: 'The basename to save the `.strings` files under',
77
+ type: String,
78
+ optional: true,
79
+ default_value: 'Localizable'),
80
+ FastlaneCore::ConfigItem.new(key: :filters,
81
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_FILTERS',
82
+ description: 'The GlotPress filters to use when requesting the translations export',
83
+ type: Hash,
84
+ optional: true,
85
+ default_value: { status: 'current' }),
86
+ FastlaneCore::ConfigItem.new(key: :skip_file_validation,
87
+ env_name: 'FL_IOS_DOWNLOAD_STRINGS_FILES_FROM_GLOTPRESS_SKIP_FILE_VALIDATION',
88
+ description: 'If true, skips the validation of `.strings` files after download',
89
+ type: Fastlane::Boolean,
90
+ optional: true,
91
+ default_value: false),
92
+ ]
93
+ end
94
+
95
+ def self.return_type
96
+ # Describes what type of data is expected to be returned
97
+ # see RETURN_TYPES in https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/action.rb
98
+ end
99
+
100
+ def self.return_value
101
+ # Textual description of what the return value is
102
+ end
103
+
104
+ def self.authors
105
+ ['Automattic']
106
+ end
107
+
108
+ def self.is_supported?(platform)
109
+ [:ios, :mac].include?(platform)
110
+ end
111
+ end
112
+ end
113
+ end