fastlane-plugin-wpmreleasetoolkit 9.0.1 → 9.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +41 -5
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +37 -6
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +40 -5
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +40 -5
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +35 -3
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +42 -5
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +33 -3
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +25 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +28 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +13 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +3 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +25 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +28 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +28 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +28 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +29 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb +2 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb +80 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{removebranchprotection_action.rb → remove_branch_protection_action.rb} +24 -17
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb +153 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb +2 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +8 -9
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +31 -47
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/deprecated.rb +46 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +49 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/app_version.rb +36 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb +27 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb +85 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb +32 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb +37 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb +26 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb +21 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb +22 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb +76 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb +64 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb +27 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb +33 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb +22 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb +35 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb +65 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb +20 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit.rb +1 -1
- metadata +36 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb +0 -63
@@ -15,7 +15,15 @@ module Fastlane
|
|
15
15
|
current_branch = Fastlane::Helper::GitHelper.current_git_branch
|
16
16
|
UI.user_error!("Current branch - '#{current_branch}' - is not a release branch. Abort.") unless current_branch.start_with?('release/')
|
17
17
|
|
18
|
-
|
18
|
+
project_root_folder = params[:project_root_folder]
|
19
|
+
project_name = params[:project_name]
|
20
|
+
build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
|
21
|
+
version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')
|
22
|
+
|
23
|
+
version = Fastlane::Helper::Android::VersionHelper.get_public_version(
|
24
|
+
build_gradle_path: build_gradle_path,
|
25
|
+
version_properties_path: version_properties_path
|
26
|
+
)
|
19
27
|
message = "Finalizing release: #{version}\n"
|
20
28
|
if params[:skip_confirm]
|
21
29
|
UI.message(message)
|
@@ -51,6 +59,22 @@ module Fastlane
|
|
51
59
|
description: 'Skips confirmation',
|
52
60
|
type: Boolean,
|
53
61
|
default_value: false), # the default value if the user didn't provide one
|
62
|
+
FastlaneCore::ConfigItem.new(key: :build_gradle_path,
|
63
|
+
description: 'Path to the build.gradle file',
|
64
|
+
type: String,
|
65
|
+
optional: true,
|
66
|
+
conflicting_options: %i[project_name
|
67
|
+
project_root_folder
|
68
|
+
version_properties_path]),
|
69
|
+
FastlaneCore::ConfigItem.new(key: :version_properties_path,
|
70
|
+
description: 'Path to the version.properties file',
|
71
|
+
type: String,
|
72
|
+
optional: true,
|
73
|
+
conflicting_options: %i[build_gradle_path
|
74
|
+
project_name
|
75
|
+
project_root_folder]),
|
76
|
+
Fastlane::Helper::Deprecated.project_root_folder_config_item,
|
77
|
+
Fastlane::Helper::Deprecated.project_name_config_item,
|
54
78
|
]
|
55
79
|
end
|
56
80
|
|
@@ -3,7 +3,16 @@ module Fastlane
|
|
3
3
|
class AndroidGetAlphaVersionAction < Action
|
4
4
|
def self.run(params)
|
5
5
|
require_relative '../../helper/android/android_version_helper'
|
6
|
-
|
6
|
+
|
7
|
+
project_root_folder = params[:project_root_folder]
|
8
|
+
project_name = params[:project_name]
|
9
|
+
build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
|
10
|
+
version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')
|
11
|
+
|
12
|
+
Fastlane::Helper::Android::VersionHelper.get_alpha_version(
|
13
|
+
build_gradle_path: build_gradle_path,
|
14
|
+
version_properties_path: version_properties_path
|
15
|
+
)
|
7
16
|
end
|
8
17
|
|
9
18
|
#####################################################
|
@@ -19,7 +28,24 @@ module Fastlane
|
|
19
28
|
end
|
20
29
|
|
21
30
|
def self.available_options
|
22
|
-
|
31
|
+
[
|
32
|
+
FastlaneCore::ConfigItem.new(key: :build_gradle_path,
|
33
|
+
description: 'Path to the build.gradle file',
|
34
|
+
type: String,
|
35
|
+
optional: true,
|
36
|
+
conflicting_options: %i[project_name
|
37
|
+
project_root_folder
|
38
|
+
version_properties_path]),
|
39
|
+
FastlaneCore::ConfigItem.new(key: :version_properties_path,
|
40
|
+
description: 'Path to the version.properties file',
|
41
|
+
type: String,
|
42
|
+
optional: true,
|
43
|
+
conflicting_options: %i[build_gradle_path
|
44
|
+
project_name
|
45
|
+
project_root_folder]),
|
46
|
+
Fastlane::Helper::Deprecated.project_root_folder_config_item,
|
47
|
+
Fastlane::Helper::Deprecated.project_name_config_item,
|
48
|
+
]
|
23
49
|
end
|
24
50
|
|
25
51
|
def self.output
|
@@ -3,7 +3,16 @@ module Fastlane
|
|
3
3
|
class AndroidGetAppVersionAction < Action
|
4
4
|
def self.run(params)
|
5
5
|
require_relative '../../helper/android/android_version_helper'
|
6
|
-
|
6
|
+
|
7
|
+
project_root_folder = params[:project_root_folder]
|
8
|
+
project_name = params[:project_name]
|
9
|
+
build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
|
10
|
+
version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')
|
11
|
+
|
12
|
+
Fastlane::Helper::Android::VersionHelper.get_public_version(
|
13
|
+
build_gradle_path: build_gradle_path,
|
14
|
+
version_properties_path: version_properties_path
|
15
|
+
)
|
7
16
|
end
|
8
17
|
|
9
18
|
#####################################################
|
@@ -19,7 +28,24 @@ module Fastlane
|
|
19
28
|
end
|
20
29
|
|
21
30
|
def self.available_options
|
22
|
-
|
31
|
+
[
|
32
|
+
FastlaneCore::ConfigItem.new(key: :build_gradle_path,
|
33
|
+
description: 'Path to the build.gradle file',
|
34
|
+
type: String,
|
35
|
+
optional: true,
|
36
|
+
conflicting_options: %i[project_name
|
37
|
+
project_root_folder
|
38
|
+
version_properties_path]),
|
39
|
+
FastlaneCore::ConfigItem.new(key: :version_properties_path,
|
40
|
+
description: 'Path to the version.properties file',
|
41
|
+
type: String,
|
42
|
+
optional: true,
|
43
|
+
conflicting_options: %i[build_gradle_path
|
44
|
+
project_name
|
45
|
+
project_root_folder]),
|
46
|
+
Fastlane::Helper::Deprecated.project_root_folder_config_item,
|
47
|
+
Fastlane::Helper::Deprecated.project_name_config_item,
|
48
|
+
]
|
23
49
|
end
|
24
50
|
|
25
51
|
def self.output
|
@@ -3,7 +3,16 @@ module Fastlane
|
|
3
3
|
class AndroidGetReleaseVersionAction < Action
|
4
4
|
def self.run(params)
|
5
5
|
require_relative '../../helper/android/android_version_helper'
|
6
|
-
|
6
|
+
|
7
|
+
project_root_folder = params[:project_root_folder]
|
8
|
+
project_name = params[:project_name]
|
9
|
+
build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
|
10
|
+
version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')
|
11
|
+
|
12
|
+
Fastlane::Helper::Android::VersionHelper.get_release_version(
|
13
|
+
build_gradle_path: build_gradle_path,
|
14
|
+
version_properties_path: version_properties_path
|
15
|
+
)
|
7
16
|
end
|
8
17
|
|
9
18
|
#####################################################
|
@@ -19,7 +28,24 @@ module Fastlane
|
|
19
28
|
end
|
20
29
|
|
21
30
|
def self.available_options
|
22
|
-
|
31
|
+
[
|
32
|
+
FastlaneCore::ConfigItem.new(key: :build_gradle_path,
|
33
|
+
description: 'Path to the build.gradle file',
|
34
|
+
type: String,
|
35
|
+
optional: true,
|
36
|
+
conflicting_options: %i[project_name
|
37
|
+
project_root_folder
|
38
|
+
version_properties_path]),
|
39
|
+
FastlaneCore::ConfigItem.new(key: :version_properties_path,
|
40
|
+
description: 'Path to the version.properties file',
|
41
|
+
type: String,
|
42
|
+
optional: true,
|
43
|
+
conflicting_options: %i[build_gradle_path
|
44
|
+
project_name
|
45
|
+
project_root_folder]),
|
46
|
+
Fastlane::Helper::Deprecated.project_root_folder_config_item,
|
47
|
+
Fastlane::Helper::Deprecated.project_name_config_item,
|
48
|
+
]
|
23
49
|
end
|
24
50
|
|
25
51
|
def self.output
|
@@ -5,8 +5,19 @@ module Fastlane
|
|
5
5
|
require_relative '../../helper/android/android_version_helper'
|
6
6
|
require_relative '../../helper/android/android_git_helper'
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
project_root_folder = params[:project_root_folder]
|
9
|
+
project_name = params[:project_name]
|
10
|
+
build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
|
11
|
+
version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')
|
12
|
+
|
13
|
+
release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(
|
14
|
+
build_gradle_path: build_gradle_path,
|
15
|
+
version_properties_path: version_properties_path
|
16
|
+
)
|
17
|
+
alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(
|
18
|
+
build_gradle_path: build_gradle_path,
|
19
|
+
version_properties_path: version_properties_path
|
20
|
+
)
|
10
21
|
Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME])
|
11
22
|
Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless alpha_ver.nil? || (params[:tag_alpha] == false)
|
12
23
|
end
|
@@ -30,6 +41,22 @@ module Fastlane
|
|
30
41
|
description: 'True to skip tagging the alpha version',
|
31
42
|
type: Boolean,
|
32
43
|
default_value: true),
|
44
|
+
FastlaneCore::ConfigItem.new(key: :build_gradle_path,
|
45
|
+
description: 'Path to the build.gradle file',
|
46
|
+
type: String,
|
47
|
+
optional: true,
|
48
|
+
conflicting_options: %i[project_name
|
49
|
+
project_root_folder
|
50
|
+
version_properties_path]),
|
51
|
+
FastlaneCore::ConfigItem.new(key: :version_properties_path,
|
52
|
+
description: 'Path to the version.properties file',
|
53
|
+
type: String,
|
54
|
+
optional: true,
|
55
|
+
conflicting_options: %i[build_gradle_path
|
56
|
+
project_name
|
57
|
+
project_root_folder]),
|
58
|
+
Fastlane::Helper::Deprecated.project_root_folder_config_item,
|
59
|
+
Fastlane::Helper::Deprecated.project_name_config_item,
|
33
60
|
]
|
34
61
|
end
|
35
62
|
|
@@ -8,6 +8,8 @@ module Fastlane
|
|
8
8
|
require_relative '../../helper/release_notes_helper'
|
9
9
|
require_relative '../../helper/git_helper'
|
10
10
|
|
11
|
+
UI.deprecated('The `PROJECT_ROOT_FOLDER` environment variable is deprecated and will be removed in a future release. Please pass a path to the `release_notes_file_path` param instead.') unless ENV['PROJECT_ROOT_FOLDER'].nil?
|
12
|
+
|
11
13
|
path = params[:release_notes_file_path]
|
12
14
|
next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_short_version(params[:new_version])
|
13
15
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../../helper/github_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CopyBranchProtectionAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
repository = params[:repository]
|
9
|
+
from_branch = params[:from_branch]
|
10
|
+
to_branch = params[:to_branch]
|
11
|
+
|
12
|
+
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
|
13
|
+
|
14
|
+
response = begin
|
15
|
+
github_helper.get_branch_protection(
|
16
|
+
repository: repository,
|
17
|
+
branch: from_branch
|
18
|
+
)
|
19
|
+
rescue Octokit::NotFound
|
20
|
+
UI.user_error!("Branch `#{from_branch}` of repository `#{repository}` was not found.")
|
21
|
+
end
|
22
|
+
UI.user_error!("Branch `#{from_branch}` does not have any branch protection set up.") if response.nil?
|
23
|
+
settings = Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(response)
|
24
|
+
|
25
|
+
response = begin
|
26
|
+
github_helper.set_branch_protection(
|
27
|
+
repository: repository,
|
28
|
+
branch: to_branch,
|
29
|
+
**settings
|
30
|
+
)
|
31
|
+
rescue Octokit::NotFound
|
32
|
+
UI.user_error!("Branch `#{to_branch}` of repository `#{repository}` was not found.")
|
33
|
+
end
|
34
|
+
|
35
|
+
Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(response)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.description
|
39
|
+
'Copies the branch protection settings of one branch onto another branch'
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.details
|
43
|
+
description
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.return_value
|
47
|
+
'The hash corresponding to the response returned by the API request, and containing the applied protection settings'
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.available_options
|
51
|
+
[
|
52
|
+
FastlaneCore::ConfigItem.new(key: :repository,
|
53
|
+
env_name: 'GHHELPER_REPOSITORY',
|
54
|
+
description: 'The remote path of the GH repository on which we work',
|
55
|
+
optional: false,
|
56
|
+
type: String),
|
57
|
+
FastlaneCore::ConfigItem.new(key: :from_branch,
|
58
|
+
env_name: 'GHHELPER_FROM_BRANCH',
|
59
|
+
description: 'The branch to copy the protection settings from',
|
60
|
+
optional: false,
|
61
|
+
type: String),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :to_branch,
|
63
|
+
env_name: 'GHHELPER_TO_BRANCH',
|
64
|
+
description: 'The branch to copy the protection settings to',
|
65
|
+
optional: false,
|
66
|
+
type: String),
|
67
|
+
Fastlane::Helper::GithubHelper.github_token_config_item,
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.authors
|
72
|
+
['Automattic']
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.is_supported?(platform)
|
76
|
+
true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -3,42 +3,34 @@ require_relative '../../helper/github_helper'
|
|
3
3
|
|
4
4
|
module Fastlane
|
5
5
|
module Actions
|
6
|
-
class
|
6
|
+
class RemoveBranchProtectionAction < Action
|
7
7
|
def self.run(params)
|
8
8
|
repository = params[:repository]
|
9
9
|
branch_name = params[:branch]
|
10
10
|
|
11
|
-
branch_url = "https://api.github.com/repos/#{repository}/branches/#{branch_name}"
|
12
|
-
restrictions = { url: "#{branch_url}/protection/restrictions", users_url: "#{branch_url}/protection/restrictions/users", teams_url: "#{branch_url}/protection/restrictions/teams", users: [], teams: [] }
|
13
|
-
required_pull_request_reviews = { url: "#{branch_url}/protection/required_pull_request_reviews", dismiss_stale_reviews: false, require_code_owner_reviews: false }
|
14
|
-
|
15
11
|
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
|
16
12
|
github_helper.remove_branch_protection(
|
17
13
|
repository: repository,
|
18
|
-
branch: branch_name
|
19
|
-
restrictions: restrictions,
|
20
|
-
enforce_admins: nil,
|
21
|
-
required_pull_request_reviews: required_pull_request_reviews
|
14
|
+
branch: branch_name
|
22
15
|
)
|
16
|
+
rescue Octokit::NotFound
|
17
|
+
UI.user_error!("Branch `#{branch_name}` of repository `#{repository}` was not found.")
|
18
|
+
rescue Octokit::BranchNotProtected
|
19
|
+
UI.message("Note: Branch `#{branch_name}` was not protected in the first place.")
|
23
20
|
end
|
24
21
|
|
25
22
|
def self.description
|
26
|
-
|
23
|
+
'Removes the protection settings for the specified branch'
|
27
24
|
end
|
28
25
|
|
29
|
-
def self.
|
30
|
-
|
26
|
+
def self.details
|
27
|
+
description
|
31
28
|
end
|
32
29
|
|
33
30
|
def self.return_value
|
34
31
|
# If your method provides a return value, you can describe here what it does
|
35
32
|
end
|
36
33
|
|
37
|
-
def self.details
|
38
|
-
# Optional:
|
39
|
-
"Sets the 'release branch' protection state for the specified branch"
|
40
|
-
end
|
41
|
-
|
42
34
|
def self.available_options
|
43
35
|
[
|
44
36
|
FastlaneCore::ConfigItem.new(key: :repository,
|
@@ -55,9 +47,24 @@ module Fastlane
|
|
55
47
|
]
|
56
48
|
end
|
57
49
|
|
50
|
+
def self.authors
|
51
|
+
['Automattic']
|
52
|
+
end
|
53
|
+
|
58
54
|
def self.is_supported?(platform)
|
59
55
|
true
|
60
56
|
end
|
61
57
|
end
|
58
|
+
|
59
|
+
# For backwards compatibility
|
60
|
+
class RemovebranchprotectionAction < RemoveBranchProtectionAction
|
61
|
+
def self.category
|
62
|
+
:deprecated
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.deprecated_notes
|
66
|
+
"This action has been renamed `#{superclass.action_name}`"
|
67
|
+
end
|
68
|
+
end
|
62
69
|
end
|
63
70
|
end
|
@@ -0,0 +1,153 @@
|
|
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
|
+
github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
|
11
|
+
|
12
|
+
settings = if params[:keep_existing_settings_unchanged]
|
13
|
+
Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(
|
14
|
+
github_helper.get_branch_protection(repository: repository, branch: branch_name)
|
15
|
+
)
|
16
|
+
else
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
|
20
|
+
# `required_status_checks` field — only override existing `checks` subfield if param provided
|
21
|
+
unless params[:required_ci_checks].nil?
|
22
|
+
if params[:required_ci_checks].empty?
|
23
|
+
settings[:required_status_checks] = nil # explicitly completely delete existing check requirement
|
24
|
+
else
|
25
|
+
settings[:required_status_checks] ||= { strict: false }
|
26
|
+
settings[:required_status_checks][:checks] = params[:required_ci_checks].map { |ctx| { context: ctx } }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# `enforce_admins` field — only override existing value if param provided
|
31
|
+
if params[:enforce_admins].nil?
|
32
|
+
settings[:enforce_admins] ||= nil # parameter is required to be provided, even if nil (aka false) value
|
33
|
+
else
|
34
|
+
settings[:enforce_admins] = params[:enforce_admins]
|
35
|
+
end
|
36
|
+
|
37
|
+
# `required_pull_request_reviews` field — only override `required_approving_review_count` subfield if param provided
|
38
|
+
settings[:required_pull_request_reviews] ||= {
|
39
|
+
dismiss_stale_reviews: false,
|
40
|
+
require_code_owner_reviews: false
|
41
|
+
}
|
42
|
+
unless params[:required_approving_review_count].nil?
|
43
|
+
settings[:required_pull_request_reviews][:required_approving_review_count] = params[:required_approving_review_count]
|
44
|
+
end
|
45
|
+
|
46
|
+
# `restrictions` field
|
47
|
+
settings[:restrictions] ||= { users: [], teams: [] }
|
48
|
+
|
49
|
+
# `allow_force_pushes` field — only override existing value if param provided
|
50
|
+
unless params[:allow_force_pushes].nil?
|
51
|
+
settings[:allow_force_pushes] = params[:allow_force_pushes]
|
52
|
+
end
|
53
|
+
|
54
|
+
# `lock_branch` field — only override existing value if param provided
|
55
|
+
unless params[:lock_branch].nil?
|
56
|
+
settings[:lock_branch] = params[:lock_branch]
|
57
|
+
end
|
58
|
+
|
59
|
+
# API Call - See https://docs.github.com/en/rest/branches/branch-protection#update-branch-protection
|
60
|
+
response = github_helper.set_branch_protection(
|
61
|
+
repository: repository,
|
62
|
+
branch: branch_name,
|
63
|
+
**settings
|
64
|
+
)
|
65
|
+
|
66
|
+
Fastlane::Helper::GithubHelper.branch_protection_api_response_to_normalized_hash(response)
|
67
|
+
rescue Octokit::NotFound => e
|
68
|
+
UI.user_error!("Branch `#{branch_name}` of repository `#{repository}` was not found.\n#{e.message}")
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.description
|
72
|
+
'Sets the protection state for the specified branch'
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.details
|
76
|
+
description
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.return_value
|
80
|
+
'The hash corresponding to the response returned by the API request, and containing the applied protection settings'
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.available_options
|
84
|
+
[
|
85
|
+
FastlaneCore::ConfigItem.new(key: :repository,
|
86
|
+
env_name: 'GHHELPER_REPOSITORY',
|
87
|
+
description: 'The slug of the GH repository on which we work',
|
88
|
+
optional: false,
|
89
|
+
type: String),
|
90
|
+
# NOTE: GitHub branch protection API doesn't allow wildcard characters for the branch parameter
|
91
|
+
FastlaneCore::ConfigItem.new(key: :branch,
|
92
|
+
env_name: 'GHHELPER_BRANCH',
|
93
|
+
description: 'The branch to protect',
|
94
|
+
optional: false,
|
95
|
+
type: String),
|
96
|
+
FastlaneCore::ConfigItem.new(key: :keep_existing_settings_unchanged,
|
97
|
+
description: 'If set to true, will only change the settings that are explicitly provided to the action, ' \
|
98
|
+
+ 'while keeping the values of other existing protection settings (if any) unchanged. If false, it will ' \
|
99
|
+
+ 'discard any existing branch protection setting if any before setting just the ones provided ' \
|
100
|
+
+ '(and leaving the rest with default GitHub values)',
|
101
|
+
default_value: true,
|
102
|
+
type: Boolean),
|
103
|
+
FastlaneCore::ConfigItem.new(key: :required_ci_checks,
|
104
|
+
description: 'If provided, specifies the list of CI status checks to mark as required. If not provided (nil), will keep existing ones',
|
105
|
+
optional: true,
|
106
|
+
default_value: nil,
|
107
|
+
type: Array),
|
108
|
+
FastlaneCore::ConfigItem.new(key: :required_approving_review_count,
|
109
|
+
description: 'If not nil, change the number of approving reviews required to merge the PR. ' \
|
110
|
+
+ 'Acceptable values are `nil` (do not change), 0 (disable) or a number between 1–6',
|
111
|
+
optional: true,
|
112
|
+
default_value: nil,
|
113
|
+
type: Integer),
|
114
|
+
FastlaneCore::ConfigItem.new(key: :enforce_admins,
|
115
|
+
description: 'If provided, will update the setting of whether admins can bypass restrictions (false) or not (true)',
|
116
|
+
optional: true,
|
117
|
+
default_value: nil,
|
118
|
+
type: Boolean),
|
119
|
+
FastlaneCore::ConfigItem.new(key: :allow_force_pushes,
|
120
|
+
description: 'If provided, will update the setting of whether to allow force pushes on the branch',
|
121
|
+
optional: true,
|
122
|
+
default_value: nil,
|
123
|
+
type: Boolean),
|
124
|
+
FastlaneCore::ConfigItem.new(key: :lock_branch,
|
125
|
+
description: 'If provided, will update the locked (aka readonly) state of the branch',
|
126
|
+
optional: true,
|
127
|
+
default_value: nil,
|
128
|
+
type: Boolean),
|
129
|
+
Fastlane::Helper::GithubHelper.github_token_config_item,
|
130
|
+
]
|
131
|
+
end
|
132
|
+
|
133
|
+
def self.authors
|
134
|
+
['Automattic']
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.is_supported?(platform)
|
138
|
+
true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# For backwards compatibility
|
143
|
+
class SetbranchprotectionAction < SetBranchProtectionAction
|
144
|
+
def self.category
|
145
|
+
:deprecated
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.deprecated_notes
|
149
|
+
"This action has been renamed `#{superclass.action_name}`"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -8,6 +8,8 @@ module Fastlane
|
|
8
8
|
require_relative '../../helper/release_notes_helper'
|
9
9
|
require_relative '../../helper/git_helper'
|
10
10
|
|
11
|
+
UI.deprecated('The `PROJECT_ROOT_FOLDER` environment variable is deprecated and will be removed in a future release. Please pass a path to the `release_notes_file_path` param instead.') unless ENV['PROJECT_ROOT_FOLDER'].nil?
|
12
|
+
|
11
13
|
path = params[:release_notes_file_path]
|
12
14
|
next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_release_version(params[:new_version])
|
13
15
|
|
@@ -12,17 +12,16 @@ module Fastlane
|
|
12
12
|
# @env PROJECT_ROOT_FOLDER The path to the git root of the project
|
13
13
|
# @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file)
|
14
14
|
#
|
15
|
-
def self.commit_version_bump
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
message: 'Bump version number'
|
20
|
-
files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties')
|
15
|
+
def self.commit_version_bump(build_gradle_path:, version_properties_path:)
|
16
|
+
if File.exist?(version_properties_path)
|
17
|
+
git_commit(
|
18
|
+
path: version_properties_path,
|
19
|
+
message: 'Bump version number'
|
21
20
|
)
|
22
21
|
else
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
git_commit(
|
23
|
+
path: build_gradle_path,
|
24
|
+
message: 'Bump version number'
|
26
25
|
)
|
27
26
|
end
|
28
27
|
end
|