fastlane-plugin-unity_exporter 1.0.2 → 1.2.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: 53984aaa0c3d1121abe876780db89b6921543cc1128314feb8e8b519418a8027
4
- data.tar.gz: d581d86006135f3b1d10dcd52d9beceb58463ea6c7702e7d800f7caf299a778e
3
+ metadata.gz: 5f871c4202b1c52b9d5d719312834f66f9374a6a16319925a6e39d5d3f87f258
4
+ data.tar.gz: 6c74a627ee70148c1b27d52421f5bf275d5ce2405c60588db6abeee04dcded2e
5
5
  SHA512:
6
- metadata.gz: dde31fb51816bc84aca04166bf1cdb7c53e6092b94104eb046b7663e30f0b319d32d1cb54fdbe6a3480f04b7a3bc552c6a13235245aa44af68cfd594161b89a1
7
- data.tar.gz: dfbf63a88dd528cd0cfc258e2d3e6d0dcbf302e111273990c57814c78a85eafd690b8dcab40fc404922c24a085f181965aa3f9a276f467ab8b6c5dd79d26234d
6
+ metadata.gz: e62253ae48ffaa41ee6a62ce09e91b0d10dcc610e05216ddec73414ea2f1d295263c95117289fd9ca33c0622036f98e9e7d44cddb3fedf360e4245378a569aa9
7
+ data.tar.gz: 3ce7dc870812337f11e80c9de94910697b47278dc98b31d51dbffe7b5006516bbb7b07342693269ee624d818000a931c4d31c9e4fecb4d4a9e63d6ae8e916482
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`
@@ -104,10 +117,27 @@ unity_export(build_target: "...", new_version: "3.4.5", new_version_code: "0")
104
117
  unity_commit_version_bump
105
118
  ```
106
119
 
120
+ ### Using `unity_get_version_number`
107
121
 
108
- ## Compatibility
122
+ ```ruby
123
+ # you must first use the unity export action
124
+ unity_export(...)
109
125
 
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).
126
+ # afterwards you can get the version number like so
127
+ # note that an error code will be returned if something fails
128
+ version_number = unity_get_version_number
129
+ ```
130
+
131
+ ### Using `unity_get_build_number`
132
+
133
+ ```ruby
134
+ # you must first use the unity export action
135
+ unity_export(...)
136
+
137
+ # afterwards you can get the build number like so
138
+ # note that an error code will be returned if something fails
139
+ build_number = unity_get_build_number
140
+ ```
111
141
 
112
142
 
113
143
  ## Example
@@ -117,6 +147,24 @@ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plu
117
147
  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
148
 
119
149
 
150
+ ## Compatibility
151
+
152
+ 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).
153
+
154
+
155
+ ## Ruby
156
+
157
+ Note that this plugin requires `Ruby 2.7.4`.
158
+
159
+ ### Ruby on Mac
160
+
161
+ Installing ruby -- even different versions of it -- on Mac and _fastlane_ is well documented.
162
+
163
+ ### Ruby on Windows
164
+
165
+ 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.
166
+
167
+
120
168
  ## Pull requests
121
169
 
122
170
  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,5 +1,6 @@
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
@@ -8,11 +9,11 @@ module Fastlane
8
9
  # TODO: improve the commit command: currently it simply commits the ProjectSettings file
9
10
  # what if there are other changes in the file and you don't want these changes to be part of the commit
10
11
 
11
- log_file = "unity-export-logs/#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S-%L')}_git.log"
12
+ log_file = Helper::GenericHelper.instance_variable_get(:@git_log_path)
12
13
 
13
14
  # Thank you: https://linuxize.com/post/bash-redirect-stderr-stdout/#redirecting-stderr-to-stdout
14
15
  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")
16
+ sh("git add '#{Helper::UnityEditorHelper.unity_project_path}ProjectSettings/ProjectSettings.asset' >> #{log_file} 2>&1")
16
17
  sh("git commit -m 'Version Bump' >> #{log_file} 2>&1")
17
18
  end
18
19
 
@@ -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,44 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/unity_editor_helper'
3
+ require_relative '../helper/generic_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class UnityGetBuildNumberAction < Action
8
+ def self.run(params)
9
+ build_number = Helper::GenericHelper.build_exporter_build_number
10
+ if build_number == ""
11
+ return "unity_exporter_error_occurred"
12
+ end
13
+
14
+ return build_number
15
+ end
16
+
17
+ def self.description
18
+ "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."
19
+ end
20
+
21
+ def self.authors
22
+ ["steft"]
23
+ end
24
+
25
+ def self.return_value
26
+ "Returns the build number that was used for the latest Unity export action. In case of error will return 'unity_exporter_error_occurred'."
27
+ end
28
+
29
+ def self.details
30
+ # Optional:
31
+ end
32
+
33
+ def self.available_options
34
+ end
35
+
36
+ def self.is_supported?(platform)
37
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
38
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
39
+ [:ios, :android].include?(platform)
40
+ true
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/unity_editor_helper'
3
+ require_relative '../helper/generic_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class UnityGetVersionNumberAction < Action
8
+ def self.run(params)
9
+ version_number = Helper::GenericHelper.build_exporter_version_number
10
+ if version_number == ""
11
+ return "unity_exporter_error_occurred"
12
+ end
13
+
14
+ return version_number
15
+ end
16
+
17
+ def self.description
18
+ "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."
19
+ end
20
+
21
+ def self.authors
22
+ ["steft"]
23
+ end
24
+
25
+ def self.return_value
26
+ "Returns the version number that was used for the latest Unity export action. In case of error will return 'unity_exporter_error_occurred'."
27
+ end
28
+
29
+ def self.details
30
+ # Optional:
31
+ end
32
+
33
+ def self.available_options
34
+ end
35
+
36
+ def self.is_supported?(platform)
37
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
38
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
39
+ [:ios, :android].include?(platform)
40
+ true
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,11 +1,46 @@
1
1
  require 'fastlane_core/ui/ui'
2
2
  require 'shellwords'
3
+ require_relative './unity_editor_helper'
3
4
 
4
5
  module Fastlane
5
6
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
7
 
7
8
  module Helper
8
9
  class GenericHelper
10
+ @git_log_path = "fastlane-unity-exporter/logs/#{DateTime.now.strftime('%Y-%m-%d_%H-%M-%S-%L')}_git.log"
11
+
12
+ def self.build_exporter_versions
13
+ # this is created and updated whenever you create a build via the build exporter
14
+ build_exporter_versions_file = "#{Helper::UnityEditorHelper.unity_project_path}/BuildExporter/latest-build-version.txt"
15
+
16
+ if File.file?(build_exporter_versions_file)
17
+ return File.readlines(build_exporter_versions_file, chomp: true)
18
+ else
19
+ UI.user_error!("Versions file does not exist yet. You must execute the Unity export action beforehand.")
20
+ return []
21
+ end
22
+ end
23
+
24
+ def self.build_exporter_version_number
25
+ versions = build_exporter_versions
26
+
27
+ if versions.count > 0
28
+ return versions[0]
29
+ else
30
+ return ""
31
+ end
32
+ end
33
+
34
+ def self.build_exporter_build_number
35
+ versions = build_exporter_versions
36
+
37
+ if versions.count > 0
38
+ return versions[1]
39
+ else
40
+ return ""
41
+ end
42
+ end
43
+
9
44
  def self.shellify(path)
10
45
  if FastlaneCore::Helper.is_mac?
11
46
  return Shellwords.escape(path)
@@ -8,9 +8,14 @@ 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("../../")
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
+ return @project_path if @project_path != ""
18
+
14
19
  return "../../"
15
20
  end
16
21
 
@@ -46,6 +51,7 @@ module Fastlane
46
51
  # TODO Unity currently does not support commandline arguments for the Package Manager
47
52
  exporter_package_namespace = "io.armet.unity.buildexporter"
48
53
  included = load_unity_project_package_manifest.include?(exporter_package_namespace)
54
+ # UI.message("exporter package part of Unity project: '#{included}'")
49
55
  unless included
50
56
  UI.user_error!("Package 'io.armet.unity.exporter' must be added to the Unity project.")
51
57
  end
@@ -57,19 +63,25 @@ module Fastlane
57
63
  relative_path = if FastlaneCore::Helper.is_test?
58
64
  "/tmp/fastlane/tests/fixtures/unity_project"
59
65
  else
60
- unity_project_path_relative_to_fastfile
66
+ unity_project_path
61
67
  end
62
68
 
63
69
  package_manifest_path = "#{relative_path}/Packages/manifest.json"
64
- package_manifest_json = File.read(package_manifest_path)
65
- return package_manifest_json
70
+
71
+ # we verify the path to the Unity project by looking for the 'manifest.json' file
72
+ if File.file?(package_manifest_path)
73
+ return File.read(package_manifest_path)
74
+ else
75
+ UI.user_error!("Cannot find 'manifest.json' at '#{package_manifest_path}'. Make sure that the Unity project path is properly set.")
76
+ return ""
77
+ end
66
78
  end
67
79
 
68
80
  def self.load_unity_project_version
69
81
  relative_path = if FastlaneCore::Helper.is_test?
70
82
  "/tmp/fastlane/tests/fixtures/unity_project"
71
83
  else
72
- unity_project_path_relative_to_fastfile
84
+ unity_project_path
73
85
  end
74
86
 
75
87
  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.2"
3
+ VERSION = "1.2.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.2
4
+ version: 1.2.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,8 @@ 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
164
166
  - lib/fastlane/plugin/unity_exporter/helper/generic_helper.rb
165
167
  - lib/fastlane/plugin/unity_exporter/helper/unity_editor_helper.rb
166
168
  - lib/fastlane/plugin/unity_exporter/helper/unity_hub_helper.rb