fastlane-plugin-unity_exporter 1.0.3 → 1.3.0

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: 99aaaf9abdb2e6fa743ffb0817d6631f18d9ce657802aeac72e33aed6ad3be60
4
- data.tar.gz: 613bd80e538855cce80c4e80e5accb65747398eef2fb2efe8b0fe63133372b99
3
+ metadata.gz: 1a1b16db5c56d81b08d0c944ddfde6d5e3295d714ec07cb0ed0155faa663ea21
4
+ data.tar.gz: f84cc70bd9024acd8df427efad57d3dbd1c58e8855fd35eed5a60643651cf10e
5
5
  SHA512:
6
- metadata.gz: e22a576504bde4153f303377b0e8c5ebe5ef5000e8f30d856bf07816919a8d099219d5fdda79680940d7ae97148156c40322662b52c56a402639e1115f0904c7
7
- data.tar.gz: 39760c4e0b721e407deccd8056ea3c0a4542ba21a93f69f209224452d868469e35afafe881c85c37045f6b3aadc9f3bdb57027ee32075cd186ba13fc844bab44
6
+ metadata.gz: e126535a70b41d1a67d8d6939c7d426fcac0e5138c96d9ba13f902899ab6e02f3f4bad882e8f98b5df651fa76fa4b9a90a5ca0a30ff60978fa059b248ef5f401
7
+ data.tar.gz: 365a6cd6106ca841fc0e59baa8ca837fa3c8c3ba1bd096453950ce3895b2b23a47fe324c8182ab247d2ae66f19c90b924b9dc57326a47c1cdd3bbaceda235ff4
data/README.md CHANGED
@@ -88,8 +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
- # combined usage of 'new_version' and 'new_version_code'
92
- unity_export(build_target: "...", new_version: "2.3.4", new_version_code: "0")
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
+
96
+ # exports the Unity project to the specified path
97
+ # if no export path is specified, a default path will be used
98
+ # note that the starting point for relative paths is the root of the Unity project
99
+ unity_export(build_target: "...", export_path: "path/some-example-builds-directory")
100
+
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")
93
106
  ```
94
107
 
95
108
  ### Using `unity_commit_version_bump`
@@ -102,12 +115,47 @@ unity_export(build_target: "...", new_version: "3.4.5", new_version_code: "0")
102
115
 
103
116
  # after the export is finished, we commit the version bump
104
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")
105
124
  ```
106
125
 
126
+ ### Using `unity_get_version_number`
107
127
 
108
- ## Compatibility
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
+ ```
109
142
 
110
- Both this _fastlane plugin_ and the [_Unity Build Exporter_](https://github.com/ar-met/unity-build-exporter) were developed with _Unity 2020.3.13f1_. We haven't tested the plugin with any earlier versions, but we don't expect there to be any issues. If you run into trouble, regarding compatibility or anything else, [please open an issue](https://github.com/ar-met/unity-build-exporter/issues). For pull requests [see here](#pull-requests).
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")
158
+ ```
111
159
 
112
160
 
113
161
  ## Example
@@ -117,6 +165,24 @@ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plu
117
165
  Also check out the example [_Unity3d_ project](https://github.com/ar-met/fastlane-plugin-unity-exporter-example-project) to see how this plugin works. See the repositories readme for more details.
118
166
 
119
167
 
168
+ ## Compatibility
169
+
170
+ Both this _fastlane plugin_ and the [_Unity Build Exporter_](https://github.com/ar-met/unity-build-exporter) were developed with _Unity 2020.3.13f1_. We haven't tested the plugin with any earlier versions, but we don't expect there to be any issues. If you run into trouble, regarding compatibility or anything else, [please open an issue](https://github.com/ar-met/unity-build-exporter/issues). For pull requests [see here](#pull-requests).
171
+
172
+
173
+ ## Ruby
174
+
175
+ Note that this plugin requires `Ruby 2.7.4`.
176
+
177
+ ### Ruby on Mac
178
+
179
+ Installing ruby -- even different versions of it -- on Mac and _fastlane_ is well documented.
180
+
181
+ ### Ruby on Windows
182
+
183
+ To install ruby on Windows you, e.g., can use [_RubyInstaller_](https://rubyinstaller.org/downloads/). Be sure to get `Ruby 2.7.4`. After that you can use `gem` commands with Windows' command prompt and rely on _fastlane_'s documentation to get you going.
184
+
185
+
120
186
  ## Pull requests
121
187
 
122
188
  We are happy to accept [pull requests](https://github.com/ar-met/unity-build-exporter/pulls). For easier development of this plugin, we suggest you use the provided [_Unity3d_ project](https://github.com/ar-met/fastlane-plugin-unity-exporter-dev-project).
@@ -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'
@@ -29,7 +33,12 @@ module Fastlane
29
33
  headless_args << " -executeMethod armet.BuildExporter.BuildUtility.CreateBuild"
30
34
  headless_args << " -newVersion #{params[:new_version]}" if params[:new_version]
31
35
  headless_args << " -newVersionCode #{params[:new_version_code]}" if params[:new_version_code]
32
- headless_args << " -exportPath fastlane-build-exporter/#{params[:build_target]}/unity-export"
36
+
37
+ if params[:export_path]
38
+ headless_args << " -exportPath #{params[:export_path]}"
39
+ else
40
+ headless_args << " -exportPath fastlane-build-exporter/#{params[:build_target]}/unity-export"
41
+ end
33
42
 
34
43
  # NOTE: the different relative paths used in 'projectPath' and 'exportPath'
35
44
  # while 'projectPath' is relative to the 'fastfile',
@@ -62,7 +71,7 @@ module Fastlane
62
71
  return
63
72
  end
64
73
 
65
- 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.")
66
75
  invocation = unity_path.to_s
67
76
  invocation << " #{params[:arguments]}"
68
77
  sh(invocation) # 'sh' will print what's passed to it
@@ -159,7 +168,21 @@ module Fastlane
159
168
  UI.user_error!("Please pass a valid version code. For options see 'fastlane action unity_exporter'")
160
169
  end
161
170
  end
162
- end)
171
+ end),
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
+
180
+ FastlaneCore::ConfigItem.new(key: :export_path,
181
+ env_name: "FL_UNITY_EXPORT_PATH",
182
+ description: "The path to the exported Unity project. The starting point for relative paths is the root of the Unity project",
183
+ optional: true,
184
+ type: String,
185
+ conflicting_options: [:arguments])
163
186
  ]
164
187
  end
165
188
 
@@ -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
@@ -6,6 +6,8 @@ module Fastlane
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)
@@ -8,10 +8,21 @@ module Fastlane
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"
@@ -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.3"
3
+ VERSION = "1.3.0"
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.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ar:met
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-27 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