Class: Fastlane::Actions::ReleaseHelperAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/release_helper/actions/release_helper_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



48
49
50
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 48

def self.authors
  ["Artem Ivanov"]
end

.available_optionsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 61

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :match,
      description: "Match parameter of git describe. See man page of git describe for more info",
      verify_block: proc do |value|
        UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :releases,
      description: "Map types of commit to release (major, minor, patch)",
      default_value: { fix: "patch", feat: "minor" },
      type: Hash
    ),
    FastlaneCore::ConfigItem.new(
      key: :tag_version_match,
      description: "To parse version number from tag name",
      default_value: '\d+\.\d+\.\d+'
    )
  ]
end

.descriptionObject



44
45
46
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 44

def self.description
  "release heper"
end

.detailsObject



56
57
58
59
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 56

def self.details
  # Optional:
  "Release helper"
end

.get_commits_from_hash(params) ⇒ Object



12
13
14
15
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 12

def self.get_commits_from_hash(params) 
  commits = Helper::ReleaseHelperHelper.git_log('%s|%b', params[:hash])
  commits.split("\n")
end

.get_last_tag(params) ⇒ Object



7
8
9
10
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 7

def self.get_last_tag(params)
  command = "git describe --tags --match=#{params[:match]}"
  Actions.sh(command, log: false)
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
87
88
89
90
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 84

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



52
53
54
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 52

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fastlane/plugin/release_helper/actions/release_helper_action.rb', line 17

def self.run(params)
  UI.message("Inside plugin123")
  hash = "HEAD"
  version = "0.0.0"

  tag = get_last_tag(match: params[:match])

  if tag.empty?
    UI.message("First commit of the branch is taken as a begining of next release")
    # If there is no tag found we taking the first commit of current branch
    hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: false).chomp
  else
    # Tag's format is v2.3.4-5-g7685948
    # See git describe man page for more info
    tag_name = tag.split('-')[0].strip
    parsed_version = tag_name.match(params[:tag_version_match])

    if parsed_version.nil?
      UI.user_error("Error while parsing version from tag")
    end

    version = parsed_version[0]
    commits = get_commits_from_hash(hash: version)
    UI.message(version)
  end
end