Class: Fastlane::Actions::FlutterVersioncodeBumpAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



34
35
36
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 34

def self.authors
  ["Sjors van Mierlo"]
end

.available_optionsObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 51

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :pubspec_location,
                            env_name: "PUBSPEC_LOCATION",
                         description: "The location of the pubspec.yaml",
                            optional: true,
                                type: String,
                                default_value: 'pubspec.yaml'),
    FastlaneCore::ConfigItem.new(key: :version_code_increment,
                            env_name: "VERSION_CODE_INCREMENT",
                         description: "The increment of the version code",
                            optional: true,
                                type: Integer,
                       default_value: 1)
  ]
end

.descriptionObject



30
31
32
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 30

def self.description
  "A plugin to bump the flutter version code with fastlane."
end

.detailsObject



44
45
46
47
48
49
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 44

def self.details
  "A plugin to bump the flutter version code with fastlane
  and also keep the comments in the pubspec.yaml.

  Useful for automated app distribution with an unique version code for each build."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 68

def self.is_supported?(platform)
  true
end

.return_valueObject



38
39
40
41
42
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 38

def self.return_value
  [
    ['VERSION', 'The bumped version']
  ]
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb', line 8

def self.run(params)
  # Retrieve given params
  pubspec_location = params[:pubspec_location]
  version_code_increment = params[:version_code_increment]

  UI.message("Let's bump the flutter version code with an increment of #{version_code_increment}!")

  # Retrieve the full version of the given pubspec.yaml location
  full_version = Helper::FlutterVersioncodeBumpHelper.retrieve_full_version(pubspec_location)
  UI.message("Current version is: #{full_version}")

  # Bump the version code of the full version by the increment that is given
  full_version = Helper::FlutterVersioncodeBumpHelper.bump_version_code(full_version, version_code_increment)

  # Update the version code of the pubspec.yaml
  Helper::FlutterVersioncodeBumpHelper.write_full_version(pubspec_location, full_version)
  UI.success("Succesfully bumped flutter version to: #{full_version}")
  {
    'version' => full_version
  }
end