fastlane-plugin-xambuild 0.1.0

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.
@@ -0,0 +1,17 @@
1
+ require "fastlane"
2
+ require "fastlane/plugin/xambuild/helpers/runner"
3
+ require "fastlane/plugin/xambuild/version"
4
+
5
+ module Xambuild
6
+ class Manager
7
+ def work(options)
8
+ Xambuild.config = options
9
+
10
+ FastlaneCore::PrintTable.print_values(config: Xambuild.config,
11
+ hide_keys: [],
12
+ title: "Summary for xambuild #{Fastlane::Xambuild::VERSION}")
13
+
14
+ Runner.new.run
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,43 @@
1
+ module Xambuild
2
+ module Msbuild
3
+ class Project
4
+ attr_accessor :options
5
+
6
+ def initialize(options)
7
+ @options = options
8
+ end
9
+
10
+ def project_name
11
+ @options[:project_name]
12
+ end
13
+
14
+ def project_path
15
+ @options[:project_path]
16
+ end
17
+
18
+ def ios?
19
+ is_platform? Xambuild::Platform::IOS
20
+ end
21
+
22
+ def osx?
23
+ is_platform? Xambuild::Platform::OSX
24
+ end
25
+
26
+ def android?
27
+ is_platform? Xambuild::Platform::ANDROID
28
+ end
29
+
30
+ def is_platform?(platform)
31
+ case platform
32
+ when Xambuild::Platform::IOS
33
+ then project_name.downcase.include? "ios"
34
+ when Xambuild::Platform::OSX
35
+ then project_name.downcase.include? "mac"
36
+ when Xambuild::Platform::ANDROID
37
+ then project_name.downcase.include? "droid"
38
+ else false
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ module Xambuild
2
+ module Msbuild
3
+ class Solution
4
+ attr_accessor :projects
5
+
6
+ def initialize
7
+ @projects = []
8
+ end
9
+
10
+ def add_project(project)
11
+ @projects << project
12
+ end
13
+
14
+ def get_platform(platform)
15
+ @projects.select { |p| p.is_platform? platform }
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,36 @@
1
+ require "fastlane/plugin/xambuild/helpers/msbuild/solution"
2
+
3
+ module Xambuild
4
+ module Msbuild
5
+ class SolutionParser
6
+ def self.parse(filename)
7
+ solution = Solution.new
8
+
9
+ File.open(filename) do |f|
10
+ f.read.split("\n").each do |line|
11
+ if line.start_with? "Project"
12
+ options = parse_line line
13
+ solution.add_project Project.new(options)
14
+ end
15
+ end
16
+ end
17
+
18
+ solution
19
+ end
20
+
21
+ def self.parse_line(line)
22
+ name = get_project_name line
23
+ project_file = get_project_file line
24
+ {project_name: name, project_path: project_file}
25
+ end
26
+
27
+ def self.get_project_name(project_line)
28
+ project_line.split("\"")[3]
29
+ end
30
+
31
+ def self.get_project_file(project_line)
32
+ project_line.split("\"")[5].tr('\\', "/")
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,102 @@
1
+ require "fastlane"
2
+
3
+ module Xambuild
4
+ class Options
5
+ def self.available_options
6
+ [
7
+ FastlaneCore::ConfigItem.new(key: :silent,
8
+ env_name: "XAMBUILD_SILENT",
9
+ description: "Hide all information that's not necessary while building",
10
+ default_value: false,
11
+ is_string: false),
12
+
13
+ FastlaneCore::ConfigItem.new(key: :compiler_bin,
14
+ env_name: "XAMBUILD_COMPILER_BIN",
15
+ description: "Path to the compiler binary",
16
+ default_value: "msbuild"),
17
+
18
+ FastlaneCore::ConfigItem.new(key: :build_configuration,
19
+ env_name: "XAMBUILD_BUILD_CONFIGURATION",
20
+ description: "Build configuration value",
21
+ default_value: "Release"),
22
+
23
+ FastlaneCore::ConfigItem.new(key: :build_platform,
24
+ env_name: "XAMBUILD_BUILD_PLATFORM",
25
+ description: "Build platform value",
26
+ default_value: "iPhone"),
27
+
28
+ FastlaneCore::ConfigItem.new(key: :build_target,
29
+ env_name: "XAMBUILD_BUILD_TARGET",
30
+ description: "Build targets to build",
31
+ default_value: ["Build"],
32
+ type: Array),
33
+
34
+ FastlaneCore::ConfigItem.new(key: :extra_build_options,
35
+ env_name: "XAMBUILD_EXTRA_BUILD_OPTIONS",
36
+ description: "Extra options to pass to `msbuild`. Example: `/p:MYOPTION=true`",
37
+ optional: true),
38
+
39
+ FastlaneCore::ConfigItem.new(key: :output_path,
40
+ env_name: "XAMBUILD_BUILD_OUTPUT_PATH",
41
+ description: "Build output path",
42
+ optional: true),
43
+
44
+ FastlaneCore::ConfigItem.new(key: :project_name,
45
+ env_name: "XAMBUILD_BUILD_PROJECT_NAME",
46
+ description: "Build project name",
47
+ optional: true),
48
+
49
+ FastlaneCore::ConfigItem.new(key: :assembly_name,
50
+ env_name: "XAMBUILD_BUILD_ASSEMBLY_NAME",
51
+ description: "Build assembly name",
52
+ optional: true),
53
+
54
+ FastlaneCore::ConfigItem.new(key: :platform,
55
+ env_name: "XAMBUILD_PLATFORM",
56
+ description: "Targeted device platform (i.e. android, ios, osx)",
57
+ optional: false),
58
+
59
+ FastlaneCore::ConfigItem.new(key: :solution_path,
60
+ env_name: "XAMBUILD_SOLUTION_PATH",
61
+ description: "Path to the build solution (sln) file",
62
+ optional: true),
63
+
64
+ FastlaneCore::ConfigItem.new(key: :project_path,
65
+ env_name: "XAMBUILD_PROJECT_PATH",
66
+ description: "Path to the build project (csproj) file",
67
+ optional: true),
68
+
69
+ FastlaneCore::ConfigItem.new(key: :manifest_path,
70
+ env_name: "XAMBUILD_ANDROID_MANIFEST_PATH",
71
+ description: "Path to the android manifest (xml) file",
72
+ optional: true),
73
+
74
+ FastlaneCore::ConfigItem.new(key: :plist_path,
75
+ env_name: "XAMBUILD_IOS_PLIST_PATH",
76
+ description: "Path to the iOS plist file",
77
+ optional: true),
78
+
79
+ FastlaneCore::ConfigItem.new(key: :keystore_path,
80
+ env_name: "XAMBUILD_ANDROID_KEYSTORE_PATH",
81
+ description: "Path to the keystore",
82
+ optional: true),
83
+
84
+ FastlaneCore::ConfigItem.new(key: :keystore_alias,
85
+ env_name: "XAMBUILD_ANDROID_KEYSTORE_ALIAS",
86
+ description: "Alias of the keystore",
87
+ optional: true),
88
+
89
+ FastlaneCore::ConfigItem.new(key: :keystore_password,
90
+ env_name: "XAMBUILD_ANDROID_KEYSTORE_PASSWORD",
91
+ description: "Password of the keystore",
92
+ optional: true),
93
+
94
+ FastlaneCore::ConfigItem.new(key: :keystore_tsa,
95
+ default_value: "http://timestamp.digicert.com",
96
+ env_name: "XAMBUILD_ANDROID_KEYSTORE_TSA",
97
+ description: "TSA for jarsigner",
98
+ optional: true)
99
+ ]
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,13 @@
1
+ module Xambuild
2
+ module Platform
3
+ IOS = "ios"
4
+ OSX = "osx"
5
+ ANDROID = "android"
6
+
7
+ def self.from_lane_context(context)
8
+ current_platform = context[:PLATFORM_NAME].to_s
9
+
10
+ current_platform
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,108 @@
1
+ require "fastlane"
2
+ require "fastlane/plugin/xambuild/helpers/generators/build_command_generator"
3
+ require "fastlane/plugin/xambuild/helpers/generators/zip_dsym_command_generator"
4
+ require "fastlane/plugin/xambuild/helpers/generators/java_sign_command_generator"
5
+ require "fastlane/plugin/xambuild/helpers/generators/android_zipalign_command_generator"
6
+
7
+ module Xambuild
8
+ class Runner
9
+
10
+ def run
11
+ config = Xambuild.config
12
+
13
+ build_app
14
+
15
+ if Xambuild.project.ios? || Xambuild.project.osx?
16
+ compress_and_move_dsym
17
+ path = ipa_file
18
+
19
+ path
20
+ elsif Xambuild.project.android?
21
+ path = apk_file
22
+ if config[:keystore_path] && config[:keystore_alias]
23
+ UI.success "Jar it, sign it, zip it..."
24
+
25
+ jarsign_and_zipalign
26
+ end
27
+
28
+ path
29
+ end
30
+ end
31
+
32
+ def build_app
33
+ command = BuildCommandGenerator.generate
34
+
35
+ FastlaneCore::CommandExecutor.execute(command: command,
36
+ print_all: true,
37
+ print_command: !Xambuild.config[:silent])
38
+ end
39
+
40
+ def apk_file
41
+ build_path = Xambuild.project.options[:output_path]
42
+ assembly_name = Xambuild.project.options[:assembly_name]
43
+
44
+ Xambuild.cache[:build_apk_path] = "#{build_path}/#{assembly_name}.apk"
45
+
46
+ "#{build_path}/#{assembly_name}.apk"
47
+ end
48
+
49
+ def jarsign_and_zipalign
50
+ command = JavaSignCommandGenerator.generate
51
+ FastlaneCore::CommandExecutor.execute(command: command,
52
+ print_all: false,
53
+ print_command: !Xambuild.config[:silent])
54
+
55
+ UI.success "Successfully signed apk #{Xambuild.cache[:build_apk_path]}"
56
+
57
+ command = AndroidZipalignCommandGenerator.generate
58
+ FastlaneCore::CommandExecutor.execute(command: command,
59
+ print_all: true,
60
+ print_command: !Xambuild.config[:silent])
61
+ end
62
+
63
+ def package_path
64
+ build_path = Xambuild.project.options[:output_path]
65
+ assembly_name = Xambuild.project.options[:assembly_name]
66
+
67
+ package_path = if File.exist? "#{build_path}/#{assembly_name}.ipa"
68
+ # after Xamarin.iOS Cycle 9
69
+ build_path
70
+ else
71
+ # before Xamarin.iOS Cycle 9
72
+ Dir.glob("#{build_path}/#{assembly_name} *").max
73
+ end
74
+
75
+ package_path
76
+ end
77
+
78
+ def ipa_file
79
+ assembly_name = Xambuild.project.options[:assembly_name]
80
+
81
+ "#{package_path}/#{assembly_name}.ipa"
82
+ end
83
+
84
+ def compress_and_move_dsym
85
+ build_path = Xambuild.project.options[:output_path]
86
+ assembly_name = Xambuild.project.options[:assembly_name]
87
+
88
+ build_dsym_path = "#{build_path}/#{assembly_name}.app.dSYM"
89
+ unless File.exist? build_dsym_path
90
+ UI.success "Did not found dSYM at #{build_dsym_path}, skipping..."
91
+ return
92
+ end
93
+
94
+ Xambuild.cache[:build_dsym_path] = build_dsym_path
95
+
96
+ command = ZipDsymCommandGenerator.generate
97
+ FastlaneCore::CommandExecutor.execute(command: command,
98
+ print_all: true,
99
+ print_command: !Xambuild.config[:silent])
100
+
101
+ # move dsym aside ipa
102
+ dsym_path = "#{dsym_path}.zip"
103
+ if File.exist? dsym_path
104
+ FileUtils.mv(dsym_path, "#{package_path}/#{File.basename dsym_path}")
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Xambuild
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-xambuild
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jake Barnby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fastlane
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.156'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.156'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
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: pry
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: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
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
+ description:
112
+ email: jakeb994@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - LICENSE
118
+ - README.md
119
+ - lib/fastlane/plugin/xambuild.rb
120
+ - lib/fastlane/plugin/xambuild/actions/app_version_action.rb
121
+ - lib/fastlane/plugin/xambuild/actions/xambuild_action.rb
122
+ - lib/fastlane/plugin/xambuild/helpers/commands_generator.rb
123
+ - lib/fastlane/plugin/xambuild/helpers/detect_values.rb
124
+ - lib/fastlane/plugin/xambuild/helpers/generators/android_zipalign_command_generator.rb
125
+ - lib/fastlane/plugin/xambuild/helpers/generators/build_command_generator.rb
126
+ - lib/fastlane/plugin/xambuild/helpers/generators/java_sign_command_generator.rb
127
+ - lib/fastlane/plugin/xambuild/helpers/generators/zip_dsym_command_generator.rb
128
+ - lib/fastlane/plugin/xambuild/helpers/manager.rb
129
+ - lib/fastlane/plugin/xambuild/helpers/msbuild/project.rb
130
+ - lib/fastlane/plugin/xambuild/helpers/msbuild/solution.rb
131
+ - lib/fastlane/plugin/xambuild/helpers/msbuild/solution_parser.rb
132
+ - lib/fastlane/plugin/xambuild/helpers/options.rb
133
+ - lib/fastlane/plugin/xambuild/helpers/platform.rb
134
+ - lib/fastlane/plugin/xambuild/helpers/runner.rb
135
+ - lib/fastlane/plugin/xambuild/version.rb
136
+ homepage: https://github.com/abnegate/fastlane-plugin-xambuild
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubygems_version: 3.1.4
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: A fastlane component to make Xamarin builds a breeze
159
+ test_files: []