Class: Fastlane::Actions::AppVersionAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb

Class Method Summary collapse

Class Method Details

.authorObject



70
71
72
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 70

def self.author
  "Felix Rudat"
end

.available_optionsObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 74

def self.available_options
  require 'souyuz'
  ::Souyuz::Options.available_options.concat(
    [
      FastlaneCore::ConfigItem.new(key: :version,
                                   env_name: "FL_APP_VERSION",
                                   description: "App version value",
                                   optional: true),
      FastlaneCore::ConfigItem.new(key: :build,
                                   env_name: "FL_APP_BUILD",
                                   description: "App build number value",
                                   optional: true)
    ]
  )
end

.descriptionObject



66
67
68
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 66

def self.description
  "Easily set or print app version with `app_version`"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 90

def self.is_supported?(platform)
  true
end

.run(values) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 4

def self.run(values)
  require 'souyuz'
  values[:platform] = ::Souyuz::Platform.from_lane_context(Actions.lane_context)
  ::Souyuz.config = values

  if ::Souyuz.project.ios? or ::Souyuz.project.osx?
    version, build = set_plist_version values[:version], values[:build], values[:plist_path]
  elsif ::Souyuz.project.android?
    version, build = set_manifest_version values[:version], values[:build], values[:manifest_path]
  end

  UI.important "Current Version is:"
  UI.message "  Version: #{version}"
  UI.message "  Build: #{build}"
end

.set_manifest_version(version, build, manifest_path = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 40

def self.set_manifest_version(version, build, manifest_path = nil)
  manifest_path ||= ::Souyuz.config[:manifest_path]

  # parse the doc
  f1 = File.open(manifest_path)
  doc = Nokogiri::XML(f1)
  f1.close

  attrs = doc.xpath('//manifest')[0]

  version ||= attrs['android:versionName']
  build ||= attrs['android:versionCode']

  if version or build
    attrs['android:versionName'] = version if version
    attrs['android:versionCode'] = build if build

    # save the doc
    File.open(manifest_path, 'w') do |f2|
      f2.print(doc.to_xml)
    end
  end

  [version, build]
end

.set_plist_version(version, build, plist_path = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/souyuz-ventaapps/actions/app_version_action.rb', line 20

def self.set_plist_version(version, build, plist_path = nil)
  plist_path ||= ::Souyuz.config[:plist_path]
  version ||= other_action.get_info_plist_value(path: plist_path, key: 'CFBundleShortVersionString')
  build ||= other_action.get_info_plist_value(path: plist_path, key: 'CFBundleVersion')

  other_action.set_info_plist_value(
    path: plist_path,
    key: 'CFBundleShortVersionString',
    value: version
  )

  other_action.set_info_plist_value(
    path: plist_path,
    key: 'CFBundleVersion',
    value: build
  )

  [version, build]
end