Class: Fastlane::Actions::UnityCommitVersionBumpAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



32
33
34
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 32

def self.authors
  ["steft"]
end

.available_optionsObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 44

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :project_path,
                                 env_name: "FL_UNITY_PROJECT_PATH",
                                 description: "The path to the Unity project. The starting point for relative paths is the directory that contains the 'fastlane' folder",
                                 optional: true,
                                 type: String,
                                 conflicting_options: [:arguments])
  ]
end

.descriptionObject



28
29
30
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 28

def self.description
  "Commits a version bump, if there is any."
end

.detailsObject



40
41
42
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 40

def self.details
  # Optional:
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 55

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, :android].include?(platform)
  true
end

.return_valueObject



36
37
38
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb', line 36

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

.run(params) ⇒ Object



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

def self.run(params)
  if params[:project_path]
    Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path])
  end

  # TODO: improve the commit command: currently it simply commits the ProjectSettings file
  #      what if there are other changes in the file and you don't want these changes to be part of the commit

  log_file = Helper::GenericHelper.instance_variable_get(:@git_log_path)

  # this changes the working directory for the code run between the do/end block
  Dir.chdir(Helper::UnityEditorHelper.unity_project_path) do
    # Thank you: https://linuxize.com/post/bash-redirect-stderr-stdout/#redirecting-stderr-to-stdout
    sh("echo 'UnityCommitVersionBumpAction: created file' > #{log_file} 2>&1")
    sh("git add 'ProjectSettings/ProjectSettings.asset' >> #{log_file} 2>&1")
    sh("git commit -m 'Version Bump' >> #{log_file} 2>&1")
  end
end