Class: Fastlane::Actions::FlutterVersionAction

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

Overview

The top-level plugin interface

Class Method Summary collapse

Class Method Details

.authorsObject



41
42
43
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 41

def self.authors
  ['tianhaoz95']
end

.available_optionsObject



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 59

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :pubspec_location,
      env_name: 'PUBSPEC_LOCATION',
      description: 'The location of pubspec.yml',
      optional: true,
      type: String,
      default_value: '../pubspec.yaml'
    )
  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 37

def self.description
  'A plugin to retrieve versioning information for Flutter projects.'
end

.detailsObject



52
53
54
55
56
57
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 52

def self.details
  "The plugin reads and parses pubspec.yml of a Flutter
  project and composes the versioning information into
  structured data to be consumed by various releasing
  automations."
end

.is_supported?(_platform) ⇒ Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


73
74
75
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 73

def self.is_supported?(_platform)
  true
end

.return_valueObject



45
46
47
48
49
50
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 45

def self.return_value
  [
    ['VERSION_CODE', 'The version code'],
    ['VERSION_NAME', 'The verison name']
  ]
end

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/flutter_version/actions/flutter_version_action.rb', line 11

def self.run(params)
  pubspec_location = params[:pubspec_location]
  begin
    pubspec = YAML.load_file(pubspec_location)
  # rubocop:disable Style/RescueStandardError
  rescue
    raise 'Read pubspec.yaml failed'
  end
  # rubocop:enable Style/RescueStandardError
  version = pubspec['version']
  UI.message('The full version is: '.dup.concat(version))
  unless version.include?('+')
    raise 'Verson code indicator (+) not found in pubspec.yml'
  end

  version_sections = version.split('+')
  version_name = version_sections[0]
  version_code = version_sections[1]
  UI.message('The version name: '.dup.concat(version_name))
  UI.message('The version code: '.dup.concat(version_code))
  {
    'version_code' => version_code,
    'version_name' => version_name
  }
end