fastlane-plugin-unity_exporter 1.0.4 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +50 -2
- data/lib/fastlane/plugin/unity_exporter/actions/unity_commit_version_bump.rb +15 -2
- data/lib/fastlane/plugin/unity_exporter/actions/unity_export.rb +13 -2
- data/lib/fastlane/plugin/unity_exporter/actions/unity_get_build_number.rb +56 -0
- data/lib/fastlane/plugin/unity_exporter/actions/unity_get_version_number.rb +56 -0
- data/lib/fastlane/plugin/unity_exporter/helper/build_exporter_helper.rb +44 -0
- data/lib/fastlane/plugin/unity_exporter/helper/generic_helper.rb +3 -1
- data/lib/fastlane/plugin/unity_exporter/helper/unity_editor_helper.rb +20 -9
- data/lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb +2 -2
- data/lib/fastlane/plugin/unity_exporter/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3054d1e2b69c1d5c8d9d036f18339e0fbdcd1d9c232e40bf1986ac96c1ce8fde
|
4
|
+
data.tar.gz: aa1e6ab7b87c527ccba402bce4029e9dc0a1609bbb5bc587e6e9783e5e2f2192
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
97
|
-
unity_export(
|
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 =
|
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.
|
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.
|
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?(
|
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?(
|
7
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
8
8
|
|
9
9
|
module Helper
|
10
10
|
class UnityEditorHelper
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
72
|
+
unity_project_path
|
61
73
|
end
|
62
74
|
|
63
75
|
package_manifest_path = "#{relative_path}/Packages/manifest.json"
|
64
|
-
|
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
|
-
|
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?(
|
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))
|
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
|
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.
|
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-
|
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
|