Class: Fastlane::Actions::UnityExportAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UnityExportAction
- Defined in:
- lib/fastlane/plugin/unity_exporter/actions/unity_export.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .invoke_unity(params) ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
90 91 92 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 90 def self. ["steft"] end |
.available_options ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 103 def self. [ # # How to start Unity via commandline? # Want a full list of all of Unity's commandline arguments? # See here: https://docs.unity3d.com/Manual/CommandLineArguments.html # FastlaneCore::ConfigItem.new(key: :arguments, env_name: "FL_UNITY_ARGUMENTS", description: "Use the 'arguments' parameter, if you want to specify all headless arguments yourself. See Unity docs regarding 'CommandLineArguments' for a all available arguments", optional: true, type: String, conflicting_options: [:build_target]), FastlaneCore::ConfigItem.new(key: :use_default_paths, env_name: "FL_UNITY_USE_DEFAULT_PATHS", description: "'true': Plugin expects Unity default paths. 'false': Custom path is provided as part of the 'arguments' parameter", optional: true, default_value: true, conflicting_options: [:build_target], verify_block: proc do |value| unless value == true || value == false UI.user_error!("Must be set to 'true' or 'false'.") end end), FastlaneCore::ConfigItem.new(key: :build_target, env_name: "FL_UNITY_BUILD_TARGET", description: "The build target. Options: 'iOS' and/or 'Android' depending on your platform", optional: true, type: String, conflicting_options: [:arguments], verify_block: proc do |value| # For now we only support iOS and Android as these platforms are supported by fastlane as well. # TODO add support for other platforms that are also supported by both fastlane and Unity # TODO verify if Unity's commandline param 'buildTarget' is case-sensitive if FastlaneCore::Helper.is_mac? unless value == "iOS" || value == "Android" UI.user_error!("Please pass a valid build target. Mac options: 'iOS', 'Android'") end elsif FastlaneCore::Helper.is_windows? unless value == "Android" UI.user_error!("Please pass a valid build target. Windows options: 'Android'") end end end), FastlaneCore::ConfigItem.new(key: :new_version, env_name: "FL_UNITY_NEW_VERSION", description: "The new version. Options: 'major', 'minor', 'patch' (for bumping) and '{major}.{minor}.{patch}' (new semantic version to apply)", optional: true, type: String, conflicting_options: [:arguments], verify_block: proc do |value| unless value == "major" || value == "minor" || value == "patch" || Gem::Version.correct?(value) UI.user_error!("Please pass a valid version. For options see 'fastlane action unity_exporter'") end end), FastlaneCore::ConfigItem.new(key: :new_version_code, env_name: "FL_UNITY_NEW_VERSION_CODE", description: "The new version code. Options: 'increment' (for incrementing the current code), '{unsigned integer}' (new code to apply)", optional: true, type: String, conflicting_options: [:arguments], verify_block: proc do |value| unless value == "increment" # Thank you: https://stackoverflow.com/a/24980633 num = value.to_i if num.to_s != value || num < 0 UI.user_error!("Please pass a valid version code. For options see 'fastlane action unity_exporter'") end end end), 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]), FastlaneCore::ConfigItem.new(key: :export_path, env_name: "FL_UNITY_EXPORT_PATH", description: "The path to the exported Unity project. The starting point for relative paths is the root of the Unity project", optional: true, type: String, conflicting_options: [:arguments]) ] end |
.description ⇒ Object
86 87 88 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 86 def self.description "Exports a Unity project." end |
.details ⇒ Object
98 99 100 101 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 98 def self.details # Optional: "Plugin for 'fastlane' that defines a pre-processing action to export iOS and Android projects via Unity3D. This allows Unity3D to more easily integrate with 'fastlane'." end |
.invoke_unity(params) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 65 def self.invoke_unity(params) unless params[:arguments] UI.error("'arguments' required") return end unless Helper::UnityHubHelper.verify_default_path return end unity_path = Helper::UnityEditorHelper.unity_editor_path if unity_path == "" return end UI.("Open 'logFile', if you want to know whats going on with your build. Look for its path in the invocation of the next line.") invocation = unity_path.to_s invocation << " #{params[:arguments]}" sh(invocation) # 'sh' will print what's passed to it end |
.is_supported?(platform) ⇒ Boolean
195 196 197 198 199 200 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 195 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_value ⇒ Object
94 95 96 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 94 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fastlane/plugin/unity_exporter/actions/unity_export.rb', line 9 def self.run(params) if params[:arguments] # UI.message("Passed arguments: '#{params[:arguments]}'") if params[:use_default_paths] pp = params[:arguments].scan(/-projectPath ((\w|[[:punct:]])*)/)[0][0] if pp != "" UI.("Parsed project path from passed arguments: '#{pp}'") Helper::UnityEditorHelper.instance_variable_set(:@project_path, pp) end invoke_unity(arguments: " #{params[:arguments]}") else # path to Unity is provided as part of 'arguments' UI.important("Expecting path to Unity as part of 'arguments'.") sh(params[:arguments]) end elsif params[:build_target] if params[:project_path] Helper::UnityEditorHelper.instance_variable_set(:@project_path, params[:project_path]) end # following are arguments as defined in the docs: https://docs.unity3d.com/Manual/CommandLineArguments.html headless_args = "-buildTarget #{params[:build_target]}" headless_args << " -batchmode -nographics -quit" # some arguments that are required when running Unity in headless-mode headless_args << " -accept-apiupdate -releaseCodeOptimization" headless_args << " -projectPath #{Helper::UnityEditorHelper.unity_project_path}" headless_args << " -logFile #{Helper::UnityEditorHelper.unity_project_path}/BuildExporter/#{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 # following are custom arguments defined in 'UnityExporter.BuildUtility' # this script is part of the 'fastlane-plugin-unity-exporter-package' headless_args << " -executeMethod armet.BuildExporter.BuildUtility.CreateBuild" headless_args << " -newVersion #{params[:new_version]}" if params[:new_version] headless_args << " -newVersionCode #{params[:new_version_code]}" if params[:new_version_code] # NOTE: the different relative paths used in 'projectPath' and 'exportPath' # while 'projectPath' is relative to the 'fastfile', # 'exportPath' is relative to 'projectPath' aka the Unity project's root directory if params[:export_path] headless_args << " -exportPath #{params[:export_path]}" else headless_args << " -exportPath fastlane-build-exporter/#{params[:build_target]}/unity-export" end unless Helper::UnityEditorHelper.verify_exporter_package return end invoke_unity(arguments: headless_args) else UI.user_error!("Either provide a 'build_target' or 'arguments'.") if !params[:build_target] && !params[:arguments] end end |