fastlane-plugin-unity3d 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7934a1f963e0edd69bc7bfe4aabbfa4c2116b7b856d1cd9559f55e7fba88c077
4
+ data.tar.gz: 6c19c86142845fb24c74a46318701e193b5eaeb724334696ff60189a05034a24
5
+ SHA512:
6
+ metadata.gz: fd34d58a93a5825980232f7e3cfaaa253b8474a46098eddc45d52b08ac629b1e83784365db6c65194c05004404e6b4b5b928756e9ae15db9248a8bec13721aab
7
+ data.tar.gz: c26cf42c2ba9b7fddbdcc3992a2b00368570f34f8543782e657eeecef3e3756464e26dadb33a7e030ed8ee729393be28fd366e59e84eb7d12a6b7a22a1c729f3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 fuzhongqing <fuzhongqing1995@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,84 @@
1
+ # unity3d plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-unity3d)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-unity3d`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin unity3d
11
+ ```
12
+
13
+ ## About unity3d
14
+
15
+ fastlane pulgin for unity3d engine
16
+
17
+ ## Usage
18
+
19
+ ```ruby
20
+ unity3d(
21
+ execute_method: "SomeClass.YourBuildMethod"
22
+ )
23
+ ```
24
+
25
+ **recommend**:
26
+
27
+ Add the following code to your `build script` to get a better experience
28
+
29
+ ```c#
30
+ var result = BuildPipeline.BuildPlayer(scene, path, isAndroid ? BuildTarget.Android : BuildTarget.iOS, option);
31
+ var summary = result.summary;
32
+ var summaryJson = JsonConvert.SerializeObject(summary);
33
+
34
+ System.IO.File.WriteAllText(@".build_summary.json", summaryJson);
35
+ ```
36
+
37
+
38
+
39
+ ## Context Values
40
+
41
+ if you genreated the `.build_summary.json` , There will be some [Lane Variables](https://docs.fastlane.tools/advanced/lanes/#lane-context)
42
+
43
+ | SharedValue | **Description** |
44
+ | ------------------------------------------ | --------------- |
45
+ | SharedValues::UNITY3D_OUTPUT_PATH | |
46
+ | SharedValues::UNITY3D_BUILD_STARTED_AT | |
47
+ | SharedValues::UNITY3D_BUILD_ENDED_AT | |
48
+ | SharedValues::UNITY3D_PLATFORM | |
49
+ | SharedValues::UNITY3D_OPTIONS | |
50
+ | SharedValues::UNITY3D_TOTAL_ERRORS | |
51
+ | SharedValues::UNITY3D_TOTAL_TOTAL_WARNINGS | |
52
+ | SharedValues::UNITY3D_TOTAL_TIME | |
53
+ | SharedValues::UNITY3D_TOTAL_SIZE | |
54
+
55
+
56
+
57
+ ## Run tests for this plugin
58
+
59
+ To run both the tests, and code style validation, run
60
+
61
+ ```
62
+ rake
63
+ ```
64
+
65
+ To automatically fix many of the styling issues, use
66
+ ```
67
+ rubocop -a
68
+ ```
69
+
70
+ ## Issues and Feedback
71
+
72
+ For any other issues and feedback about this plugin, please submit it to this repository.
73
+
74
+ ## Troubleshooting
75
+
76
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
77
+
78
+ ## Using _fastlane_ Plugins
79
+
80
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
81
+
82
+ ## About _fastlane_
83
+
84
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/unity3d/version'
2
+
3
+ module Fastlane
4
+ module Unity3d
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::Unity3d.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,163 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/unity3d_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+
7
+ module SharedValues
8
+ UNITY3D_OUTPUT_PATH = :UNITY3D_OUTPUT_PATH
9
+ UNITY3D_BUILD_STARTED_AT = :UNITY3D_BUILD_STARTED_AT
10
+ UNITY3D_BUILD_ENDED_AT = :UNITY3D_BUILD_ENDED_AT
11
+ UNITY3D_PLATFORM = :UNITY3D_PLATFORM
12
+ UNITY3D_OPTIONS = :UNITY3D_OPTIONS
13
+ UNITY3D_TOTAL_ERRORS = :UNITY3D_TOTAL_ERRORS
14
+ UNITY3D_TOTAL_TOTAL_WARNINGS = :UNITY3D_TOTAL_TOTAL_WARNINGS
15
+ UNITY3D_TOTAL_TIME =:UNITY3D_TOTAL_TIME
16
+ UNITY3D_TOTAL_SIZE =:UNITY3D_TOTAL_SIZE
17
+ end
18
+
19
+ class Unity3dAction < Action
20
+ def self.run(params)
21
+
22
+ build_cmd = "#{params[:executable]}"
23
+ build_cmd << " -projectPath #{params[:project_path]}"
24
+ build_cmd << " -batchmode"
25
+ build_cmd << " -quit"
26
+ build_cmd << " -logfile #{params[:logfile]}"
27
+ build_cmd << " -nographics" if params[:nographics]
28
+ build_cmd << " -executeMethod #{params[:execute_method]}" if params[:execute_method]
29
+
30
+ UI.message "\n#{
31
+ Terminal::Table.new(
32
+ title: "Unity".green,
33
+ headings: ["Option", "Value"],
34
+ rows: params.values
35
+ )}\n"
36
+
37
+
38
+ UI.message "Start running"
39
+
40
+ sh build_cmd unless params[:skip_building]
41
+
42
+ if File.exist?('.build_summary.json') then
43
+ summary = Helper::BuildSummary.new(JSON.parse(File.read('.build_summary.json')))
44
+
45
+ UI.message "\n#{
46
+ Terminal::Table.new(
47
+ title: "build summary".green,
48
+ headings: ["Key", "Value"],
49
+ rows: summary.kv
50
+ )}\n"
51
+
52
+ UI.error "build faild, check logfile" unless summary.success?
53
+
54
+ Actions.lane_context[SharedValues::UNITY3D_BUILD_STARTED_AT] = summary.kv['buildStartedAt']
55
+ Actions.lane_context[SharedValues::UNITY3D_PLATFORM] = summary.kv['platform']
56
+ Actions.lane_context[SharedValues::UNITY3D_OPTIONS] = summary.kv['options']
57
+ Actions.lane_context[SharedValues::UNITY3D_OUTPUT_PATH] = summary.kv['outputPath']
58
+ Actions.lane_context[SharedValues::UNITY3D_TOTAL_SIZE] = summary.kv['totalSize']
59
+ Actions.lane_context[SharedValues::UNITY3D_TOTAL_TIME] = summary.kv['totalTime']
60
+ Actions.lane_context[SharedValues::UNITY3D_BUILD_ENDED_AT] = summary.kv['buildEndedAt']
61
+ Actions.lane_context[SharedValues::UNITY3D_TOTAL_ERRORS] = summary.kv['totalErrors']
62
+ Actions.lane_context[SharedValues::UNITY3D_TOTAL_TOTAL_WARNINGS] = summary.kv['totalWarnings']
63
+
64
+ if summary.is_android? then
65
+ build_script_file = Dir[File.join(summary.build_path, '*', 'build.gradle')].find { |path| File.exist?(path) }
66
+ if build_script_file then
67
+ # if export mode
68
+ sh "gradle -p \'#{File.dirname(build_script_file)}\' wrapper"
69
+ ENV["FL_GRADLE_PROJECT_DIR"] = File.dirname(build_script_file)
70
+ end
71
+ end
72
+
73
+ else
74
+ UI.message "file `build_summary.json` not found"
75
+ end
76
+
77
+ end
78
+
79
+ #####################################################
80
+ # @!group Documentation
81
+ #####################################################
82
+
83
+ def self.description
84
+ "fastlane plugin for unity3d engine"
85
+ end
86
+
87
+ def self.authors
88
+ ["fuzhongqing"]
89
+ end
90
+
91
+ def self.return_value
92
+ # If your method provides a return value, you can describe here what it does
93
+ end
94
+
95
+ def self.details
96
+ # Optional:
97
+ "fastlane for unity3d engine"
98
+ end
99
+
100
+ def self.available_options
101
+ [
102
+ FastlaneCore::ConfigItem.new(key: :executable,
103
+ env_name: "FL_UNITY_EXECUTABLE",
104
+ description: "Path for Unity executable",
105
+ optional: true,
106
+ default_value: Helper::Unity3dHelper.default_exe_path),
107
+
108
+ FastlaneCore::ConfigItem.new(key: :project_path,
109
+ env_name: "FL_UNITY_PROJECT_PATH",
110
+ description: "Path for Unity project",
111
+ optional: true,
112
+ default_value: "#{Dir.pwd}"),
113
+
114
+ FastlaneCore::ConfigItem.new(key: :execute_method,
115
+ env_name: "FL_UNITY_EXECUTE_METHOD",
116
+ description: "Method to execute",
117
+ optional: true,
118
+ default_value: nil),
119
+
120
+ FastlaneCore::ConfigItem.new(key: :build_type,
121
+ env_name: "FL_UNITY_BUILD_TYPE",
122
+ description: "`Debug` or `Release`",
123
+ optional: true,
124
+ default_value: "Release"),
125
+
126
+ FastlaneCore::ConfigItem.new(key: :nographics,
127
+ env_name: "FL_UNITY_NOGRAPHICS",
128
+ description: "Initialize graphics device or not",
129
+ optional: true,
130
+ is_string: false,
131
+ default_value: true),
132
+
133
+ FastlaneCore::ConfigItem.new(key: :logfile,
134
+ env_name: "FL_UNITY_LOGFILE",
135
+ description: "log file",
136
+ optional: true,
137
+ is_string: true,
138
+ default_value: ""),
139
+
140
+ FastlaneCore::ConfigItem.new(key: :skip_building,
141
+ env_name: "FL_UNITY_SKIP_BUILDING",
142
+ description: "Need skip building",
143
+ optional: true,
144
+ is_string: false,
145
+ default_value: false),
146
+ ]
147
+ end
148
+
149
+ def self.is_supported?(platform)
150
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
151
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
152
+ #
153
+ # [:ios, :mac, :android].include?(platform)
154
+ true
155
+ end
156
+
157
+ def self.category
158
+ :building
159
+ end
160
+
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,66 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class Unity3dHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::Unity3dHelper.your_method`
10
+ #
11
+ # https://github.com/safu9/fastlane-plugin-unity/blob/main/lib/fastlane/plugin/unity/helper/unity_helper.rb
12
+ def self.default_exe_path
13
+ paths = []
14
+
15
+ if OS::Underlying.docker?
16
+ # See: https://gitlab.com/gableroux/unity3d
17
+ paths << "/opt/Unity/Editor/Unity"
18
+ end
19
+
20
+ if OS.windows?
21
+ paths << "C:\\Program Files\\Unity\\Editor\\Unity.exe"
22
+ elsif OS.mac?
23
+ paths << "/Applications/Unity/Unity.app/Contents/MacOS/Unity"
24
+ paths << Dir[File.join('Applications', '**', 'Unity.app', 'Contents', 'MacOS', 'Unity')]
25
+ elsif OS.linux?
26
+ paths << "~/Unity/Editor/Unity"
27
+ end
28
+
29
+ return paths.find { |path| File.exist?(path) }
30
+ end
31
+ end
32
+
33
+ class BuildSummary
34
+
35
+ @@object = nil
36
+
37
+ def initialize(json_obj)
38
+ @object = json_obj
39
+ end
40
+
41
+ def build_path
42
+ @object['outputPath']
43
+ end
44
+
45
+ def success?
46
+ @object['result'] == 1
47
+ end
48
+
49
+ def is_android?
50
+ @object['platform'] == 13
51
+ end
52
+
53
+ def is_ios?
54
+ @object['platform'] == 9
55
+ end
56
+
57
+ def kv
58
+ @object.merge!(
59
+ {
60
+ "android" => self.is_android?,
61
+ "ios" => self.is_ios?,
62
+ })
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Unity3d
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-unity3d
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - fuzhongqing
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec_junit_formatter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.49.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.49.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-require_tools
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: fastlane
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.171.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.171.0
139
+ description:
140
+ email: fuzhongqing1995@gmail.com
141
+ executables: []
142
+ extensions: []
143
+ extra_rdoc_files: []
144
+ files:
145
+ - LICENSE
146
+ - README.md
147
+ - lib/fastlane/plugin/unity3d.rb
148
+ - lib/fastlane/plugin/unity3d/actions/unity3d_action.rb
149
+ - lib/fastlane/plugin/unity3d/helper/unity3d_helper.rb
150
+ - lib/fastlane/plugin/unity3d/version.rb
151
+ homepage: https://github.com/fuzhongqing/fastlane-plugin-unity3d
152
+ licenses:
153
+ - MIT
154
+ metadata: {}
155
+ post_install_message:
156
+ rdoc_options: []
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ requirements: []
170
+ rubygems_version: 3.0.3
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: fastlane for unity3d engine
174
+ test_files: []