fastlane-plugin-unity_exporter 1.0.4 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96e50a14af9081a9995f926e20603a15aeeebbdb167c3a7488488e074f9095b4
4
- data.tar.gz: 3f894f28a17b8addad168696daf246e408ed00ba6e2164f4a9c742a97b114ec2
3
+ metadata.gz: 3054d1e2b69c1d5c8d9d036f18339e0fbdcd1d9c232e40bf1986ac96c1ce8fde
4
+ data.tar.gz: aa1e6ab7b87c527ccba402bce4029e9dc0a1609bbb5bc587e6e9783e5e2f2192
5
5
  SHA512:
6
- metadata.gz: 69f08ae45b2538b88c47fe4c2b01bf78312b2fc952414a21e5a733c1da4d41e459f3b3a0db9e184c4b1c56217ff44d917864c2ff9a4d78586b1488c80926fdf8
7
- data.tar.gz: 1629f955e2b634eceff64074e821d3c93336e92d79b3d14ddc6681fdb4ea51ce08b7961a388122174b00ff8a8a63249588e960c7b0ab66032e32cc745964aedb
6
+ metadata.gz: 706fd9e68d728df14014d9d30e6bd88816a71f026ef6c852c075b0f6335c7e821644259d9ea30ea046aea8798aef2a731230846c659f3ff7d15c83601389f64c
7
+ data.tar.gz: f638422b8d2fb7261a586d8f99ca84f79baa6b773d993c7e1a5f46feca5a988665cd14274b8ebfc4bca58035331f994ed14645e0c419ab4b73f32d51e2cd00af
data/README.md CHANGED
@@ -88,13 +88,21 @@ unity_export(build_target: "...", new_version_code: "42")
88
88
  # increments the existing version code (Android) and build number (iOS)
89
89
  unity_export(build_target: "...", new_version_code: "increment")
90
90
 
91
+ # the expected default path is in accordance with the "getting started" section of this readme
92
+ # if a custom path to the Unity project is required, it's specified this way
93
+ # note that the starting point for relative paths is the directory that contains the 'fastlane' folder
94
+ unity_export(build_target: "...", project_path: "path/some-example-unity-projects-directory")
95
+
91
96
  # exports the Unity project to the specified path
92
97
  # if no export path is specified, a default path will be used
93
98
  # note that the starting point for relative paths is the root of the Unity project
94
99
  unity_export(build_target: "...", export_path: "path/some-example-builds-directory")
95
100
 
96
- # combined usage of 'new_version' and 'new_version_code' and 'export_path'
97
- unity_export(build_target: "...", new_version: "2.3.4", new_version_code: "0", export_path: "path/Builds")
101
+ # combined usage of 'new_version', 'new_version_code', 'project_path' and 'export_path'
102
+ unity_export(
103
+ build_target: "...",
104
+ new_version: "2.3.4", new_version_code: "0",
105
+ project_path: "path/Unity-project", export_path: "path/Builds")
98
106
  ```
99
107
 
100
108
  ### Using `unity_commit_version_bump`
@@ -107,6 +115,46 @@ unity_export(build_target: "...", new_version: "3.4.5", new_version_code: "0")
107
115
 
108
116
  # after the export is finished, we commit the version bump
109
117
  unity_commit_version_bump
118
+
119
+ # another invocation example that specifies a project path
120
+ # the expected default path is in accordance with the "getting started" section of this readme
121
+ # if a custom path to the Unity project is required, it's specified this way
122
+ # note that the starting point for relative paths is the directory that contains the 'fastlane' folder
123
+ unity_commit_version_bump(project_path: "path/some-example-unity-projects-directory")
124
+ ```
125
+
126
+ ### Using `unity_get_version_number`
127
+
128
+ ```ruby
129
+ # you must first use the unity export action
130
+ unity_export(...)
131
+
132
+ # afterwards you can get the version number like so
133
+ # note that an error code will be returned if something fails
134
+ version_number = unity_get_version_number
135
+
136
+ # another invocation example that specifies a project path
137
+ # the expected default path is in accordance with the "getting started" section of this readme
138
+ # if a custom path to the Unity project is required, it's specified this way
139
+ # note that the starting point for relative paths is the directory that contains the 'fastlane' folder
140
+ version_number = unity_get_version_number(project_path: "path/some-example-unity-projects-directory")
141
+ ```
142
+
143
+ ### Using `unity_get_build_number`
144
+
145
+ ```ruby
146
+ # you must first use the unity export action
147
+ unity_export(...)
148
+
149
+ # afterwards you can get the build number like so
150
+ # note that an error code will be returned if something fails
151
+ build_number = unity_get_build_number
152
+
153
+ # another invocation example that specifies a project path
154
+ # the expected default path is in accordance with the "getting started" section of this readme
155
+ # if a custom path to the Unity project is required, it's specified this way
156
+ # note that the starting point for relative paths is the directory that contains the 'fastlane' folder
157
+ build_number = unity_get_build_number(project_path: "path/some-example-unity-projects-directory")
110
158
  ```
111
159
 
112
160
 
@@ -1,18 +1,23 @@
1
1
  require 'fastlane/action'
2
2
  require_relative '../helper/unity_editor_helper'
3
+ require_relative '../helper/generic_helper'
3
4
 
4
5
  module Fastlane
5
6
  module Actions
6
7
  class UnityCommitVersionBumpAction < Action
7
8
  def self.run(params)
9
+ if params[:project_path]
10
+ Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path])
11
+ end
12
+
8
13
  # TODO: improve the commit command: currently it simply commits the ProjectSettings file
9
14
  # what if there are other changes in the file and you don't want these changes to be part of the commit
10
15
 
11
- log_file = "unity-export-logs/#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S-%L')}_git.log"
16
+ log_file = Helper::GenericHelper.instance_variable_get(:@git_log_path)
12
17
 
13
18
  # Thank you: https://linuxize.com/post/bash-redirect-stderr-stdout/#redirecting-stderr-to-stdout
14
19
  sh("echo 'UnityCommitVersionBumpAction: created file' > #{log_file} 2>&1")
15
- sh("git add '#{Helper::UnityEditorHelper.unity_project_path_relative_to_fastfile}ProjectSettings/ProjectSettings.asset' >> #{log_file} 2>&1")
20
+ sh("git add '#{Helper::UnityEditorHelper.unity_project_path}ProjectSettings/ProjectSettings.asset' >> #{log_file} 2>&1")
16
21
  sh("git commit -m 'Version Bump' >> #{log_file} 2>&1")
17
22
  end
18
23
 
@@ -33,6 +38,14 @@ module Fastlane
33
38
  end
34
39
 
35
40
  def self.available_options
41
+ [
42
+ FastlaneCore::ConfigItem.new(key: :project_path,
43
+ env_name: "FL_UNITY_PROJECT_PATH",
44
+ description: "The path to the Unity project. The starting point for relative paths is the directory that contains the 'fastlane' folder",
45
+ optional: true,
46
+ type: String,
47
+ conflicting_options: [:arguments])
48
+ ]
36
49
  end
37
50
 
38
51
  def self.is_supported?(platform)
@@ -17,11 +17,15 @@ module Fastlane
17
17
  end
18
18
 
19
19
  elsif params[:build_target]
20
+ if params[:project_path]
21
+ Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path])
22
+ end
23
+
20
24
  # following are arguments as defined in the docs: https://docs.unity3d.com/Manual/CommandLineArguments.html
21
25
  headless_args = "-buildTarget #{params[:build_target]}"
22
26
  headless_args << " -batchmode -nographics -quit" # some arguments that are required when running Unity in headless-mode
23
27
  headless_args << " -accept-apiupdate -releaseCodeOptimization"
24
- headless_args << " -projectPath #{Helper::UnityEditorHelper.unity_project_path_relative_to_fastfile}"
28
+ headless_args << " -projectPath #{Helper::UnityEditorHelper.unity_project_path}"
25
29
  headless_args << " -logFile unity-export-logs/#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S-%L')}_#{params[:build_target]}_build.log" # logging; not specifying a path will print the log to the console
26
30
 
27
31
  # following are custom arguments defined in 'UnityExporter.BuildUtility'
@@ -67,7 +71,7 @@ module Fastlane
67
71
  return
68
72
  end
69
73
 
70
- UI.message("Open 'logFile', if you want to know whats going on with your build.")
74
+ UI.message("Open 'logFile', if you want to know whats going on with your build. Look for its path in the invocation of the next line.")
71
75
  invocation = unity_path.to_s
72
76
  invocation << " #{params[:arguments]}"
73
77
  sh(invocation) # 'sh' will print what's passed to it
@@ -166,6 +170,13 @@ module Fastlane
166
170
  end
167
171
  end),
168
172
 
173
+ FastlaneCore::ConfigItem.new(key: :project_path,
174
+ env_name: "FL_UNITY_PROJECT_PATH",
175
+ description: "The path to the Unity project. The starting point for relative paths is the directory that contains the 'fastlane' folder",
176
+ optional: true,
177
+ type: String,
178
+ conflicting_options: [:arguments]),
179
+
169
180
  FastlaneCore::ConfigItem.new(key: :export_path,
170
181
  env_name: "FL_UNITY_EXPORT_PATH",
171
182
  description: "The path to the exported Unity project. The starting point for relative paths is the root of the Unity project",
@@ -0,0 +1,56 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/unity_editor_helper'
3
+ require_relative '../helper/build_exporter_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class UnityGetBuildNumberAction < Action
8
+ def self.run(params)
9
+ if params[:project_path]
10
+ Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path])
11
+ end
12
+
13
+ build_number = Helper::BuildExporterHelper.build_number
14
+ if build_number == ""
15
+ return "unity_exporter_error_occurred"
16
+ end
17
+
18
+ return build_number
19
+ end
20
+
21
+ def self.description
22
+ "Will get the build number that was used for the latest Unity export action. Therefore make sure to call the Unity export action before you use this action."
23
+ end
24
+
25
+ def self.authors
26
+ ["steft"]
27
+ end
28
+
29
+ def self.return_value
30
+ "Returns the build number that was used for the latest Unity export action. In case of error will return 'unity_exporter_error_occurred'."
31
+ end
32
+
33
+ def self.details
34
+ # Optional:
35
+ end
36
+
37
+ def self.available_options
38
+ [
39
+ FastlaneCore::ConfigItem.new(key: :project_path,
40
+ env_name: "FL_UNITY_PROJECT_PATH",
41
+ description: "The path to the Unity project. The starting point for relative paths is the directory that contains the 'fastlane' folder",
42
+ optional: true,
43
+ type: String,
44
+ conflicting_options: [:arguments])
45
+ ]
46
+ end
47
+
48
+ def self.is_supported?(platform)
49
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
50
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
51
+ [:ios, :android].include?(platform)
52
+ true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,56 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/unity_editor_helper'
3
+ require_relative '../helper/build_exporter_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class UnityGetVersionNumberAction < Action
8
+ def self.run(params)
9
+ if params[:project_path]
10
+ Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path])
11
+ end
12
+
13
+ version_number = Helper::BuildExporterHelper.version_number
14
+ if version_number == ""
15
+ return "unity_exporter_error_occurred"
16
+ end
17
+
18
+ return version_number
19
+ end
20
+
21
+ def self.description
22
+ "Will get the version number that was used for the latest Unity export action. Therefore make sure to call the Unity export action before you use this action."
23
+ end
24
+
25
+ def self.authors
26
+ ["steft"]
27
+ end
28
+
29
+ def self.return_value
30
+ "Returns the version number that was used for the latest Unity export action. In case of error will return 'unity_exporter_error_occurred'."
31
+ end
32
+
33
+ def self.details
34
+ # Optional:
35
+ end
36
+
37
+ def self.available_options
38
+ [
39
+ FastlaneCore::ConfigItem.new(key: :project_path,
40
+ env_name: "FL_UNITY_PROJECT_PATH",
41
+ description: "The path to the Unity project. The starting point for relative paths is the directory that contains the 'fastlane' folder",
42
+ optional: true,
43
+ type: String,
44
+ conflicting_options: [:arguments])
45
+ ]
46
+ end
47
+
48
+ def self.is_supported?(platform)
49
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
50
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
51
+ [:ios, :android].include?(platform)
52
+ true
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,44 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'shellwords'
3
+ require_relative './unity_editor_helper'
4
+
5
+ module Fastlane
6
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
7
+
8
+ module Helper
9
+ # a helper class specific to the Unity-Build-Exporter package: https://github.com/ar-met/unity-build-exporter
10
+ class BuildExporterHelper
11
+ def self.versions_file_content
12
+ # this is created and updated whenever you create a build via the build exporter
13
+ build_exporter_versions_file = "#{Helper::UnityEditorHelper.unity_project_path}/BuildExporter/latest-build-version.txt"
14
+
15
+ if File.file?(build_exporter_versions_file)
16
+ return File.readlines(build_exporter_versions_file, chomp: true)
17
+ else
18
+ UI.user_error!("Versions file does not exist yet. You must execute the Unity export action beforehand.")
19
+ return []
20
+ end
21
+ end
22
+
23
+ def self.version_number
24
+ versions = versions_file_content
25
+
26
+ if versions.count > 0
27
+ return versions[0]
28
+ else
29
+ return ""
30
+ end
31
+ end
32
+
33
+ def self.build_number
34
+ versions = versions_file_content
35
+
36
+ if versions.count > 0
37
+ return versions[1]
38
+ else
39
+ return ""
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -2,10 +2,12 @@ require 'fastlane_core/ui/ui'
2
2
  require 'shellwords'
3
3
 
4
4
  module Fastlane
5
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
6
6
 
7
7
  module Helper
8
8
  class GenericHelper
9
+ @git_log_path = "fastlane-unity-exporter/logs/#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S-%L')}_git.log"
10
+
9
11
  def self.shellify(path)
10
12
  if FastlaneCore::Helper.is_mac?
11
13
  return Shellwords.escape(path)
@@ -4,14 +4,25 @@ require_relative './unity_hub_helper'
4
4
  require_relative './generic_helper'
5
5
 
6
6
  module Fastlane
7
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
7
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
8
8
 
9
9
  module Helper
10
10
  class UnityEditorHelper
11
- def self.unity_project_path_relative_to_fastfile
12
- # project path relative if following hierarchy is given: "root/{unity-project}/fastlane-build-exporter/{platform}-export/."
13
- # p File.expand_path("../../")
14
- return "../../"
11
+ # project path relative if following hierarchy is given: "root/{unity-project}/fastlane-build-exporter/{platform}-export/."
12
+ # p File.expand_path("../../")
13
+ @project_path_default = "../../"
14
+ @project_path = ""
15
+
16
+ def self.unity_project_path
17
+ project_path = @project_path == "" ? "../../" : @project_path
18
+
19
+ # we verify the path to the Unity project by looking for the 'manifest.json' file
20
+ package_manifest_path = "#{project_path}/Packages/manifest.json"
21
+ unless File.file?(package_manifest_path)
22
+ UI.user_error!("Cannot find 'manifest.json' at '#{package_manifest_path}'. Make sure that the Unity project path is properly set.")
23
+ end
24
+
25
+ return project_path
15
26
  end
16
27
 
17
28
  def self.unity_editor_path
@@ -46,6 +57,7 @@ module Fastlane
46
57
  # TODO Unity currently does not support commandline arguments for the Package Manager
47
58
  exporter_package_namespace = "io.armet.unity.buildexporter"
48
59
  included = load_unity_project_package_manifest.include?(exporter_package_namespace)
60
+ # UI.message("exporter package part of Unity project: '#{included}'")
49
61
  unless included
50
62
  UI.user_error!("Package 'io.armet.unity.exporter' must be added to the Unity project.")
51
63
  end
@@ -57,19 +69,18 @@ module Fastlane
57
69
  relative_path = if FastlaneCore::Helper.is_test?
58
70
  "/tmp/fastlane/tests/fixtures/unity_project"
59
71
  else
60
- unity_project_path_relative_to_fastfile
72
+ unity_project_path
61
73
  end
62
74
 
63
75
  package_manifest_path = "#{relative_path}/Packages/manifest.json"
64
- package_manifest_json = File.read(package_manifest_path)
65
- return package_manifest_json
76
+ return File.read(package_manifest_path)
66
77
  end
67
78
 
68
79
  def self.load_unity_project_version
69
80
  relative_path = if FastlaneCore::Helper.is_test?
70
81
  "/tmp/fastlane/tests/fixtures/unity_project"
71
82
  else
72
- unity_project_path_relative_to_fastfile
83
+ unity_project_path
73
84
  end
74
85
 
75
86
  project_version_txt_path = "#{relative_path}/ProjectSettings/ProjectVersion.txt"
@@ -2,7 +2,7 @@ require 'fastlane_core/ui/ui'
2
2
  require_relative './generic_helper'
3
3
 
4
4
  module Fastlane
5
- UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
6
6
 
7
7
  module Helper
8
8
  class UnityHubHelper
@@ -28,7 +28,7 @@ module Fastlane
28
28
 
29
29
  def self.verify_default_path
30
30
  # verifies that the Unity Hub exists at the default path
31
- exists = File.file?(Helper::UnityHubHelper.unity_hub_path(false)) == true
31
+ exists = File.file?(Helper::UnityHubHelper.unity_hub_path(false))
32
32
  unless exists
33
33
  UI.error("Unity Hub does not exist at path '#{Helper::UnityHubHelper.unity_hub_path(false)}'")
34
34
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module UnityExporter
3
- VERSION = "1.0.4"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-unity_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ar:met
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-12 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -161,6 +161,9 @@ files:
161
161
  - lib/fastlane/plugin/unity_exporter.rb
162
162
  - lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb
163
163
  - lib/fastlane/plugin/unity_exporter/actions/unity_export.rb
164
+ - lib/fastlane/plugin/unity_exporter/actions/unity_get_build_number.rb
165
+ - lib/fastlane/plugin/unity_exporter/actions/unity_get_version_number.rb
166
+ - lib/fastlane/plugin/unity_exporter/helper/build_exporter_helper.rb
164
167
  - lib/fastlane/plugin/unity_exporter/helper/generic_helper.rb
165
168
  - lib/fastlane/plugin/unity_exporter/helper/unity_editor_helper.rb
166
169
  - lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb