Class: Fastlane::Actions::SemanticBumpAction

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

Overview

Action to bumps the version according to semantic versioning and writes a changelog.

Class Method Summary collapse

Class Method Details

.authorsObject



49
50
51
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 49

def self.authors
  ["kassi"]
end

.available_optionsObject

:nocov:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 68

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :bump_message,
                                 env_name: "SEMANTIC_VERSIONING_BUMP_MESSAGE",
                                 description: "The commit mesage to use for the bump commit",
                                 optional: true,
                                 default_value: "version $current_version → $new_version",
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :changelog_file,
                                 env_name: "SEMANTIC_VERSIONING_CHANGELOG_FILE",
                                 description: "Filename for the changelog",
                                 optional: true,
                                 default_value: "CHANGELOG.md",
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :versioning_system,
                                 env_name: "SEMANTIC_VERSIONING_VERSIONING_SYSTEM",
                                 description: "Type of versioning to use. Can be 'manual' or 'apple-generic'." \
                                              "For 'apple-generic', the project has to be prepared with prepare_versioning." \
                                              "Defaults to 'manual'",
                                 optional: true,
                                 default_value: "manual",
                                 is_string: true,
                                 verify_block: ->(value) { Helper::SemanticVersioningHelper.verify_versioning_system(value) })
  ]
end

.descriptionObject

:nocov:



45
46
47
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 45

def self.description
  "Bumps the version according to semantic versioning and writes a changelog."
end

.detailsObject



62
63
64
65
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 62

def self.details
  # Optional:
  "Reads commits from last version and determines next version and changelog."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 94

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
  #
  %i[ios mac].include?(platform)
end

.outputObject



53
54
55
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 53

def self.output
  # Define the shared values you are going to provide
end

.return_valueObject



57
58
59
60
# File 'lib/fastlane/plugin/semantic_versioning/actions/semantic_bump_action.rb', line 57

def self.return_value
  # If your method provides a return value, you can describe here what it does
  "Returns true when the bump was successful, false otherwise."
end

.run(params) ⇒ Object



10
11
12
13
14
15
16
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/semantic_versioning/actions/semantic_bump_action.rb', line 10

def self.run(params)
  unless Actions.lane_context.key?(SharedValues::SEMVER_BUMPABLE) && Actions.lane_context.key?(SharedValues::SEMVER_VERSIONING_SYSTEM)
    UI.user_error!("No semver information found. Please run get_versioning_info beforehand.")
  end

  Helper::SemanticVersioningHelper.verify_versioning_system(Actions.lane_context[SharedValues::SEMVER_VERSIONING_SYSTEM])

  unless Actions.lane_context[SharedValues::SEMVER_BUMPABLE]
    UI.message("No version bump detected.")
    return false
  end

  system = Actions.lane_context[SharedValues::SEMVER_VERSIONING_SYSTEM]
  version_number = Actions.lane_context[SharedValues::SEMVER_NEW_VERSION]
  next_changelog = Actions.lane_context[SharedValues::SEMVER_NEW_CHANGELOG]

  Helper::SemanticVersioningHelper.set_version_number(version_number: version_number, system: system)

  if params[:changelog_file]
    Helper::SemanticVersioningHelper.write_changelog(
      path: params[:changelog_file],
      changelog: next_changelog
    )
  end

  Fastlane::Actions::CommitVersionBumpAction.run(
    message: Helper::SemanticVersioningHelper.bump_message(params[:bump_message]),
    force: true,
    include: [params[:changelog_file]].compact
  )

  true
end