fastlane-plugin-wpmreleasetoolkit 2.1.0 → 2.2.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.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb +89 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +2 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_generate_strings_file_from_code.rb +115 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +5 -6
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +48 -8
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a118f64ccb017604c68c8f62c56b91d4bea3ec92f26e2942ec28caf681a811a7
|
4
|
+
data.tar.gz: 4c09125195256749d839aac630c4393fab86f08363304b70b6e3d452c8aae96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '04158059883cdf0a9f19077a616020fe027fc25a574d8e84605ca40d948763a33dd7373dbc526a26bc0e99f3fab4c20b38e2f10799bc2dd9bd953437fe6b7fb5'
|
7
|
+
data.tar.gz: 741ea4ad0ba1b022bd856839d72c4a4847cfc0d5377c350fea687e85b685bca3cb95206e5ae6999f2c1792938966578376e58d8810cd719fc5cbf2e8c866ebcb
|
@@ -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}.")
|
@@ -0,0 +1,115 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class IosGenerateStringsFileFromCodeAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
files = files_matching(paths: params[:paths], exclude: params[:exclude])
|
6
|
+
flags = [('-q' if params[:quiet]), ('-SwiftUI' if params[:swiftui])].compact
|
7
|
+
flags += Array(params[:routines]).flat_map { |routine| ['-s', routine] }
|
8
|
+
cmd = ['genstrings', '-o', params[:output_dir], *flags, *files]
|
9
|
+
out = Actions.sh_control_output(*cmd, print_command: FastlaneCore::Globals.verbose?, print_command_output: true)
|
10
|
+
out = out.scrub.strip.split("\n")
|
11
|
+
errors = out.select { |line| line.include?('genstrings: error: ') }
|
12
|
+
UI.user_error!(errors.join("\n")) unless !params[:fail_on_error] || errors.empty?
|
13
|
+
out
|
14
|
+
end
|
15
|
+
|
16
|
+
# Adds the proper `**/*.{m,swift}` to the list of paths
|
17
|
+
def self.glob_pattern(path)
|
18
|
+
if path.end_with?('**') || path.end_with?('**/')
|
19
|
+
File.join(path, '*.{m,swift}')
|
20
|
+
elsif File.directory?(path) || path.end_with?('/')
|
21
|
+
File.join(path, '**', '*.{m,swift}')
|
22
|
+
else
|
23
|
+
path
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.files_matching(paths:, exclude:)
|
28
|
+
globbed_paths = paths.map { |p| glob_pattern(p) }
|
29
|
+
Dir.glob(globbed_paths).reject do |file|
|
30
|
+
exclude&.any? { |ex| File.fnmatch?(ex, file) }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#####################################################
|
35
|
+
# @!group Documentation
|
36
|
+
#####################################################
|
37
|
+
|
38
|
+
def self.description
|
39
|
+
'Generate the .strings files from your Objective-C and Swift code'
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.details
|
43
|
+
<<~DETAILS
|
44
|
+
Uses `genstrings` to generate the `.strings` files from your Objective-C and Swift code.
|
45
|
+
(especially `Localizable.strings` but it could generate more if the code uses custom tables).
|
46
|
+
|
47
|
+
You can provide a list of paths to scan but also paths to exclude. Both supports glob patterns.
|
48
|
+
You can also optionally provide a list of custom "routines" (aka macros or functions) that
|
49
|
+
`genstrings` should parse in addition to the usual `NSLocalizedString`. (see `-s` option of `genstrings`).
|
50
|
+
|
51
|
+
Tip: support for custom routines is useful if some of your targets define a helper function e.g.
|
52
|
+
`PodLocalizedString` to wrap calls to `Bundle.localizedString(forKey: key, value: value, table: nil)`,
|
53
|
+
just like the build-in `NSLocalizedString` does, but providing a custom bundle to look up the strings from.
|
54
|
+
DETAILS
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.available_options
|
58
|
+
[
|
59
|
+
FastlaneCore::ConfigItem.new(key: :paths,
|
60
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_PATHS',
|
61
|
+
description: 'Array of paths to scan for `.m` and `.swift` files. The entries can also contain glob patterns',
|
62
|
+
type: Array,
|
63
|
+
default_value: ['.']),
|
64
|
+
FastlaneCore::ConfigItem.new(key: :exclude,
|
65
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_EXCLUDE',
|
66
|
+
description: 'Array of paths or glob patterns to exclude from scanning',
|
67
|
+
type: Array,
|
68
|
+
default_value: []),
|
69
|
+
FastlaneCore::ConfigItem.new(key: :routines,
|
70
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_ROUTINES',
|
71
|
+
description: 'Base name of the alternate methods to be parsed in addition to the standard `NSLocalizedString()` one. See the `-s` option in `man genstrings`',
|
72
|
+
type: Array,
|
73
|
+
default_value: []),
|
74
|
+
FastlaneCore::ConfigItem.new(key: :quiet,
|
75
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_QUIET',
|
76
|
+
description: 'In quiet mode, `genstrings` will log warnings about duplicate values, but not about duplicate comments',
|
77
|
+
is_string: false, # Boolean
|
78
|
+
default_value: true),
|
79
|
+
FastlaneCore::ConfigItem.new(key: :swiftui,
|
80
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_SWIFTUI',
|
81
|
+
description: "Should we include SwiftUI's `Text()` when parsing code with `genstrings`",
|
82
|
+
is_string: false, # Boolean
|
83
|
+
default_value: false),
|
84
|
+
FastlaneCore::ConfigItem.new(key: :output_dir,
|
85
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_OUTPUT_DIR',
|
86
|
+
description: 'The path to the directory where the generated `.strings` files should be created',
|
87
|
+
type: String),
|
88
|
+
FastlaneCore::ConfigItem.new(key: :fail_on_error,
|
89
|
+
env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_FAIL_ON_ERROR',
|
90
|
+
description: 'If true, will fail with user_error! if `genstrings` printed any error while parsing',
|
91
|
+
is_string: false, # Boolean
|
92
|
+
default_value: true),
|
93
|
+
]
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.return_type
|
97
|
+
# Describes what type of data is expected to be returned
|
98
|
+
# see RETURN_TYPES in https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/action.rb
|
99
|
+
:array_of_strings
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.return_value
|
103
|
+
'List of warning lines generated by genstrings on stdout'
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.authors
|
107
|
+
['Automattic']
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.is_supported?(platform)
|
111
|
+
[:ios, :mac].include?(platform)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -20,16 +20,15 @@ module Fastlane
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.details
|
23
|
-
'Gathers the string to localise'
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.available_options
|
23
|
+
'Gathers the string to localise. Deprecated in favor of the new `ios_generate_strings_file_from_code`'
|
27
24
|
end
|
28
25
|
|
29
|
-
def self.
|
26
|
+
def self.category
|
27
|
+
:deprecated
|
30
28
|
end
|
31
29
|
|
32
|
-
def self.
|
30
|
+
def self.deprecated_notes
|
31
|
+
'This action is deprecated in favor of `ios_generate_strings_file_from_code`'
|
33
32
|
end
|
34
33
|
|
35
34
|
def self.authors
|
@@ -1,23 +1,37 @@
|
|
1
1
|
require 'fastlane_core/ui/ui'
|
2
2
|
require 'octokit'
|
3
3
|
require 'open-uri'
|
4
|
+
require 'securerandom'
|
4
5
|
|
5
6
|
module Fastlane
|
6
7
|
UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
|
7
8
|
|
8
9
|
module Helper
|
9
10
|
class GithubHelper
|
11
|
+
def self.github_token!
|
12
|
+
token = [
|
13
|
+
'GHHELPER_ACCESS', # For historical reasons / backward compatibility
|
14
|
+
'GITHUB_TOKEN', # Used by the `gh` CLI tool
|
15
|
+
].map { |key| ENV[key] }
|
16
|
+
.compact
|
17
|
+
.first
|
18
|
+
|
19
|
+
token || UI.user_error!('Please provide a GitHub authentication token via the `GITHUB_TOKEN` environment variable')
|
20
|
+
end
|
21
|
+
|
10
22
|
def self.github_client
|
11
|
-
client
|
23
|
+
@@client ||= begin
|
24
|
+
client = Octokit::Client.new(access_token: github_token!)
|
12
25
|
|
13
|
-
|
14
|
-
|
15
|
-
|
26
|
+
# Fetch the current user
|
27
|
+
user = client.user
|
28
|
+
UI.message("Logged in as: #{user.name}")
|
16
29
|
|
17
|
-
|
18
|
-
|
30
|
+
# Auto-paginate to ensure we're not missing data
|
31
|
+
client.auto_paginate = true
|
19
32
|
|
20
|
-
|
33
|
+
client
|
34
|
+
end
|
21
35
|
end
|
22
36
|
|
23
37
|
def self.get_milestone(repository, release)
|
@@ -117,8 +131,11 @@ module Fastlane
|
|
117
131
|
file_name = File.basename(file_path)
|
118
132
|
download_path = File.join(download_folder, file_name)
|
119
133
|
|
134
|
+
download_url = github_client.contents(repository,
|
135
|
+
path: file_path,
|
136
|
+
ref: tag).download_url
|
120
137
|
begin
|
121
|
-
uri = URI.parse(
|
138
|
+
uri = URI.parse(download_url)
|
122
139
|
uri.open do |remote_file|
|
123
140
|
File.write(download_path, remote_file.read)
|
124
141
|
end
|
@@ -128,6 +145,29 @@ module Fastlane
|
|
128
145
|
|
129
146
|
download_path
|
130
147
|
end
|
148
|
+
|
149
|
+
# Creates (or updates an existing) GitHub PR Comment
|
150
|
+
def self.comment_on_pr(project_slug:, pr_number:, body:, reuse_identifier: SecureRandom.uuid)
|
151
|
+
client = github_client
|
152
|
+
comments = client.issue_comments(project_slug, pr_number)
|
153
|
+
|
154
|
+
reuse_marker = "<!-- REUSE_ID: #{reuse_identifier} -->"
|
155
|
+
|
156
|
+
existing_comment = comments.find do |comment|
|
157
|
+
# Only match comments posted by the owner of the GitHub Token, and with the given reuse ID
|
158
|
+
comment.user.id == client.user.id and comment.body.include?(reuse_marker)
|
159
|
+
end
|
160
|
+
|
161
|
+
comment_body = reuse_marker + body
|
162
|
+
|
163
|
+
if existing_comment.nil?
|
164
|
+
client.add_comment(project_slug, pr_number, comment_body)
|
165
|
+
else
|
166
|
+
client.update_comment(project_slug, existing_comment.id, comment_body)
|
167
|
+
end
|
168
|
+
|
169
|
+
reuse_identifier
|
170
|
+
end
|
131
171
|
end
|
132
172
|
end
|
133
173
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-wpmreleasetoolkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorenzo Mattei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|
@@ -408,6 +408,7 @@ files:
|
|
408
408
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb
|
409
409
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb
|
410
410
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb
|
411
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb
|
411
412
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb
|
412
413
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb
|
413
414
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb
|
@@ -439,6 +440,7 @@ files:
|
|
439
440
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb
|
440
441
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_final_tag.rb
|
441
442
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb
|
443
|
+
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_generate_strings_file_from_code.rb
|
442
444
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb
|
443
445
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb
|
444
446
|
- lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_store_app_sizes.rb
|