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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +41 -5
  3. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +37 -6
  4. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +40 -5
  5. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +40 -5
  6. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +35 -3
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +42 -5
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +33 -3
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +25 -1
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +28 -2
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +13 -1
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +3 -1
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +25 -1
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +28 -2
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +28 -2
  16. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +28 -2
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +29 -2
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb +2 -0
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb +80 -0
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{removebranchprotection_action.rb → remove_branch_protection_action.rb} +24 -17
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb +153 -0
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_release_notes.rb +2 -0
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +8 -9
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +31 -47
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/deprecated.rb +46 -0
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +49 -4
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/models/app_version.rb +36 -0
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb +27 -0
  29. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
  30. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb +85 -0
  31. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb +32 -0
  32. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb +37 -0
  33. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb +26 -0
  34. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb +21 -0
  35. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb +22 -0
  36. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb +76 -0
  37. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb +64 -0
  38. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb +27 -0
  39. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb +33 -0
  40. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb +22 -0
  41. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb +35 -0
  42. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb +65 -0
  43. data/lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb +20 -0
  44. data/lib/fastlane/plugin/wpmreleasetoolkit.rb +1 -1
  45. metadata +36 -4
  46. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb +0 -63
@@ -0,0 +1,64 @@
1
+ require 'xcodeproj'
2
+
3
+ module Fastlane
4
+ module Wpmreleasetoolkit
5
+ module Versioning
6
+ # The `IOSVersionFile` class takes in an .xcconfig file path and reads/writes values to/from the file.
7
+ class IOSVersionFile
8
+ attr_reader :xcconfig_path
9
+
10
+ # Initializes a new instance of IOSVersionFile with the specified .xcconfig file path.
11
+ #
12
+ # @param [String] xcconfig_path The path to the .xcconfig file.
13
+ #
14
+ def initialize(xcconfig_path:)
15
+ UI.user_error!(".xcconfig file not found at this path: #{xcconfig_path}") unless File.exist?(xcconfig_path)
16
+
17
+ @xcconfig_path = xcconfig_path
18
+ end
19
+
20
+ # Reads the release version from the .xcconfig file and returns it as a String.
21
+ #
22
+ # @return [String] The release version.
23
+ #
24
+ def read_release_version
25
+ config = Xcodeproj::Config.new(xcconfig_path)
26
+ config.attributes['VERSION_SHORT']
27
+ end
28
+
29
+ # Reads the build code from the .xcconfig file and returns it String.
30
+ #
31
+ # Some apps store the build code in the VERSION_LONG attribute, while others store it in the BUILD_NUMBER attribute.
32
+ #
33
+ # @param [String] attribute_name The name of the attribute to read.
34
+ #
35
+ # @return [String] The build code.
36
+ #
37
+ def read_build_code(attribute_name:)
38
+ UI.user_error!('attribute_name must be `VERSION_LONG` or `BUILD_NUMBER`') unless attribute_name.eql?('VERSION_LONG') || attribute_name.eql?('BUILD_NUMBER')
39
+
40
+ config = Xcodeproj::Config.new(xcconfig_path)
41
+ config.attributes[attribute_name]
42
+ end
43
+
44
+ # Writes the provided version numbers to the .xcconfig file.
45
+ #
46
+ # @param [String, nil] version_short The short version string (optional).
47
+ # @param [String, nil] version_long The long version string (optional).
48
+ # @param [String, nil] build_number The build number (optional).
49
+ #
50
+ # version_long is optional because there are times when it won't be updated, such as a new beta build.
51
+ # version_short is optional because some apps (such as Day One iOS/Mac or Simplenote Mac) don't use it.
52
+ # build_number is optional because some apps (such as WP/JP iOS or WCiOS) don't use it.
53
+ #
54
+ def write(version_short: nil, version_long: nil, build_number: nil)
55
+ config = Xcodeproj::Config.new(xcconfig_path)
56
+ config.attributes['VERSION_SHORT'] = version_short.to_s unless version_short.nil?
57
+ config.attributes['VERSION_LONG'] = version_long.to_s unless version_long.nil?
58
+ config.attributes['BUILD_NUMBER'] = build_number.to_s unless build_number.nil?
59
+ config.save_as(Pathname.new(xcconfig_path))
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../calculators/abstract_version_calculator'
2
+
3
+ module Fastlane
4
+ module Wpmreleasetoolkit
5
+ module Versioning
6
+ # The `VersionFormatter` class is a generic version formatter that can be used as a base class
7
+ # for formatting version objects used by for different platforms. It contains formatting methods that
8
+ # are shared by all platforms. It has the abstract suffix because it should not be instantiated directly.
9
+ class AbstractVersionFormatter
10
+ # Get the release version string for the app.
11
+ #
12
+ # This method constructs the release version string based on the major, minor, and
13
+ # patch components of the provided `@version`. If the patch component is zero, it returns
14
+ # a version string in the format "major.minor" (e.g., '1.2'). Otherwise, it returns a
15
+ # version string in the format "major.minor.patch" (e.g., '1.2.3').
16
+ #
17
+ # @param [AppVersion] version The version object to format
18
+ #
19
+ # @return [String] The formatted release version string.
20
+ #
21
+ def release_version(version)
22
+ version.patch.zero? ? "#{version.major}.#{version.minor}" : "#{version.major}.#{version.minor}.#{version.patch}"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module Fastlane
2
+ module Wpmreleasetoolkit
3
+ module Versioning
4
+ # The `DerivedBuildCodeFormatter` class is a specialized build code formatter for derived build codes.
5
+ # It takes in an AppVersion object and derives a build code from it.
6
+ class DerivedBuildCodeFormatter
7
+ # Calculate the next derived build code.
8
+ #
9
+ # This method derives a new build code from the given AppVersion object by concatenating the digit 1,
10
+ # the major version, the minor version, the patch version, and the build number.
11
+ #
12
+ # @param [AppVersion] version The AppVersion object to derive the next build code from.
13
+ #
14
+ # @param [BuildCode] build_code A BuildCode object. This parameter is ignored but is included
15
+ # to have a consistent signature with other build code formatters.
16
+ #
17
+ # @return [String] The formatted build code string.
18
+ #
19
+ def build_code(build_code = nil, version:)
20
+ format(
21
+ # 1 is appended to the beginning of the string in case there needs to be additional platforms or
22
+ # extensions that could then use a different digit prefix such as 2, etc.
23
+ '1%<major>.2i%<minor>.2i%<patch>.2i%<build_number>.2i',
24
+ major: version.major,
25
+ minor: version.minor,
26
+ patch: version.patch,
27
+ build_number: version.build_number
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ require_relative '../formatters/four_part_version_formatter'
2
+
3
+ module Fastlane
4
+ module Wpmreleasetoolkit
5
+ module Versioning
6
+ # The `FourPartBuildCodeFormatter` is a specialized build code formatter for apps that use
7
+ # build codes in the format of `major.minor.patch.build_number`.
8
+ class FourPartBuildCodeFormatter
9
+ # @param [AppVersion] version The AppVersion object to format
10
+ #
11
+ # @param [BuildCode] build_code A BuildCode object. This parameter is ignored but is included
12
+ # to have a consistent signature with other build code formatters.
13
+ #
14
+ # @return [String] The formatted build code string.
15
+ #
16
+ def build_code(build_code = nil, version:)
17
+ FourPartVersionFormatter.new.to_s(version)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'abstract_version_formatter'
2
+
3
+ module Fastlane
4
+ module Wpmreleasetoolkit
5
+ module Versioning
6
+ # The `FourPartVersionFormatter` class extends the `VersionFormatter` class. It is a specialized version formatter for
7
+ # apps that use versions in the format of `1.2.3.4`.
8
+ class FourPartVersionFormatter < AbstractVersionFormatter
9
+ # Parse the version string into an AppVersion instance
10
+ #
11
+ # @param [String] version The version string to parse
12
+ #
13
+ # @return [AppVersion] The parsed version
14
+ #
15
+ def parse(version)
16
+ # Split the version string into its components
17
+ components = version.split('.').map(&:to_i)
18
+
19
+ # Create a new AppVersion instance from the version string components
20
+ Fastlane::Models::AppVersion.new(*components)
21
+ end
22
+
23
+ # Return the formatted version string
24
+ #
25
+ # @param [AppVersion] version The version object to format
26
+ #
27
+ # @return [String] The formatted version string
28
+ #
29
+ def to_s(version)
30
+ "#{version.major}.#{version.minor}.#{version.patch}.#{version.build_number}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,65 @@
1
+ require_relative 'abstract_version_formatter'
2
+
3
+ module Fastlane
4
+ module Wpmreleasetoolkit
5
+ module Versioning
6
+ # The `RCNotationVersionFormatter` class extends the `VersionFormatter` class. It is a specialized version
7
+ # formatter for apps that may use versions in the format of `1.2.3-rc-4`.
8
+ class RCNotationVersionFormatter < AbstractVersionFormatter
9
+ # The string identifier used for beta versions in Android.
10
+ RC_SUFFIX = 'rc'.freeze
11
+
12
+ # Parse the version string into an AppVersion instance
13
+ #
14
+ # @param [String] version_name The version string to parse
15
+ #
16
+ # @return [AppVersion] The parsed version
17
+ #
18
+ def parse(version_name)
19
+ # Set the build number to 0 by default so that it will be set correctly for non-beta version numbers
20
+ build_number = 0
21
+
22
+ if version_name.include?(RC_SUFFIX)
23
+ # Extract the build number from the version name
24
+ build_number = version_name.split('-')[2].to_i
25
+ # Extract the version name without the build number and drop the RC suffix
26
+ version_name = version_name.split(RC_SUFFIX)[0]
27
+ end
28
+
29
+ # Split the version name into its components
30
+ version_number_parts = version_name.split('.').map(&:to_i)
31
+ # Fill the array with 0 if needed to ensure array has at least 3 components
32
+ version_number_parts.fill(0, version_number_parts.length...3)
33
+
34
+ # Map version_number_parts to AppVersion model
35
+ major = version_number_parts[0]
36
+ minor = version_number_parts[1]
37
+ patch = version_number_parts[2]
38
+
39
+ # Create an AppVersion object
40
+ Fastlane::Models::AppVersion.new(major, minor, patch, build_number)
41
+ end
42
+
43
+ # Get the formatted beta version of the Android app
44
+ #
45
+ # This method constructs a beta version string by combining the release version
46
+ # with the beta identifier and the build number. It ensures that the build number is
47
+ # 1 or higher, as beta versions must have a build number greater than or equal to 1.
48
+ #
49
+ # @param [AppVersion] version The version object to format
50
+ #
51
+ # @return [String] The formatted beta version of the Android app
52
+ #
53
+ # @raise [UI::Error] If the build number of the beta version is not 1 or higher
54
+ #
55
+ def beta_version(version)
56
+ # Ensure that the build number is 1 or higher for a beta version
57
+ UI.user_error!('The build number of a beta version must be 1 or higher') unless version.build_number.positive?
58
+
59
+ # Construct and return the formatted beta version string.
60
+ "#{release_version(version)}-#{RC_SUFFIX}-#{version.build_number}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,20 @@
1
+ module Fastlane
2
+ module Wpmreleasetoolkit
3
+ module Versioning
4
+ # The `IntegerBuildCodeFormatter` is a specialized build code formatter for apps that use simple
5
+ # integer build codes in the format of `build_number`.
6
+ class SimpleBuildCodeFormatter
7
+ # @param version [AppVersion] An AppVersion object. This parameter is ignored but is included
8
+ # to have a consistent signature with other build code formatters.
9
+ #
10
+ # @param [BuildCode] build_code The BuildCode object to format
11
+ #
12
+ # @return [String] The formatted build code string.
13
+ #
14
+ def build_code(version = nil, build_code:)
15
+ build_code.to_s
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,7 +4,7 @@ module Fastlane
4
4
  module Wpmreleasetoolkit
5
5
  # Return all .rb files inside the "actions", "helper" and "models" directories
6
6
  def self.all_classes
7
- Dir[File.expand_path('**/{actions,helper,models}/**/*.rb', File.dirname(__FILE__))]
7
+ Dir[File.expand_path('**/{actions,helper,models,versioning}/**/*.rb', File.dirname(__FILE__))]
8
8
  end
9
9
  end
10
10
  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: 9.0.1
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-05 00:00:00.000000000 Z
11
+ date: 2023-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: java-properties
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.3.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.3.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: nokogiri
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -426,6 +440,7 @@ files:
426
440
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/circleci_trigger_job_action.rb
427
441
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb
428
442
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/comment_on_pr.rb
443
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/copy_branch_protection_action.rb
429
444
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb
430
445
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb
431
446
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb
@@ -436,8 +451,8 @@ files:
436
451
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb
437
452
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb
438
453
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb
439
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/removebranchprotection_action.rb
440
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setbranchprotection_action.rb
454
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/remove_branch_protection_action.rb
455
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/set_branch_protection_action.rb
441
456
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/setfrozentag_action.rb
442
457
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb
443
458
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb
@@ -484,6 +499,7 @@ files:
484
499
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/app_size_metrics_helper.rb
485
500
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb
486
501
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb
502
+ - lib/fastlane/plugin/wpmreleasetoolkit/helper/deprecated.rb
487
503
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb
488
504
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/filesystem_helper.rb
489
505
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb
@@ -506,6 +522,8 @@ files:
506
522
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb
507
523
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/release_notes_helper.rb
508
524
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/user_agent.rb
525
+ - lib/fastlane/plugin/wpmreleasetoolkit/models/app_version.rb
526
+ - lib/fastlane/plugin/wpmreleasetoolkit/models/build_code.rb
509
527
  - lib/fastlane/plugin/wpmreleasetoolkit/models/configuration.rb
510
528
  - lib/fastlane/plugin/wpmreleasetoolkit/models/file_reference.rb
511
529
  - lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_account.rb
@@ -513,6 +531,20 @@ files:
513
531
  - lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_lab_result.rb
514
532
  - lib/fastlane/plugin/wpmreleasetoolkit/models/firebase_test_runner.rb
515
533
  - lib/fastlane/plugin/wpmreleasetoolkit/version.rb
534
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/abstract_version_calculator.rb
535
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_build_code_calculator.rb
536
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/date_version_calculator.rb
537
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/marketing_version_calculator.rb
538
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/semantic_version_calculator.rb
539
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/calculators/simple_build_code_calculator.rb
540
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/android_version_file.rb
541
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb
542
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/abstract_version_formatter.rb
543
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/derived_build_code_formatter.rb
544
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_build_code_formatter.rb
545
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/four_part_version_formatter.rb
546
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/rc_notation_version_formatter.rb
547
+ - lib/fastlane/plugin/wpmreleasetoolkit/versioning/formatters/simple_build_code_formatter.rb
516
548
  homepage: https://github.com/wordpress-mobile/release-toolkit
517
549
  licenses:
518
550
  - MIT
@@ -1,63 +0,0 @@
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
-
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
- github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
16
- github_helper.set_branch_protection(
17
- repository: repository,
18
- branch: branch_name,
19
- restrictions: restrictions,
20
- enforce_admins: nil,
21
- required_pull_request_reviews: required_pull_request_reviews
22
- )
23
- end
24
-
25
- def self.description
26
- "Sets the 'release branch' protection state for the specified branch"
27
- end
28
-
29
- def self.authors
30
- ['Automattic']
31
- end
32
-
33
- def self.return_value
34
- # If your method provides a return value, you can describe here what it does
35
- end
36
-
37
- def self.details
38
- # Optional:
39
- "Sets the 'release branch' protection state for the specified branch"
40
- end
41
-
42
- def self.available_options
43
- [
44
- FastlaneCore::ConfigItem.new(key: :repository,
45
- env_name: 'GHHELPER_REPOSITORY',
46
- description: 'The remote path of the GH repository on which we work',
47
- optional: false,
48
- type: String),
49
- FastlaneCore::ConfigItem.new(key: :branch,
50
- env_name: 'GHHELPER_BRANCH',
51
- description: 'The branch to protect',
52
- optional: false,
53
- type: String),
54
- Fastlane::Helper::GithubHelper.github_token_config_item,
55
- ]
56
- end
57
-
58
- def self.is_supported?(platform)
59
- true
60
- end
61
- end
62
- end
63
- end