cocoapods-submit 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f60fe74826bb86503f7c10253c8e29f54b3af984
4
+ data.tar.gz: a8d04ccb15c185eb85778ddcdd36a8ad22d7ad90
5
+ SHA512:
6
+ metadata.gz: 72253787996febd05a3cae447968b1f42cd8d8122ea9f805cbaa8e9dd649954aef35f536cb171817722ec52f1bc8bf7f66f733a7be54eb88c8ea4da8a7611cc1
7
+ data.tar.gz: b2e5727e06d5ccb2946fcdeba73e85c702432dc79e37c32ebc9b3edaeb784e8ae19ea75fecc56013339ba440a238f4c3c4209ae92389518d6fc26efa3659ecb6
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-submit.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Oliver Letterer, Sparrow-Labs
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Cocoapods::Submit
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-submit
8
+
9
+ ## Usage
10
+
11
+ TODO: Write usage instructions here
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it ( https://github.com/[my-github-username]/cocoapods-submit/fork )
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cocoapods-submit"
8
+ spec.version = CocoapodsSubmit::VERSION
9
+ spec.authors = ["Oliver Letterer"]
10
+ spec.email = ["oliver.letterer@gmail.com"]
11
+ spec.summary = %q{Build and submit ios projects to iTunes Connect}
12
+ spec.description = %q{CocoaPods plugin that let's you build and submit builds to iTunes Connect, thanks to nomad/Shenzhen.}
13
+ spec.homepage = "https://github.com/Sparrow-Labs/cocoapods-submit"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "shenzhen", "~> 0.8"
22
+ spec.add_dependency "xcpretty", "~> 0.1"
23
+ spec.add_dependency "plist", "~> 3.1"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
@@ -0,0 +1 @@
1
+ require 'pod/command/submit'
@@ -0,0 +1,152 @@
1
+ require 'plist'
2
+ require 'io/console'
3
+ require 'provisioning_profile'
4
+ require 'time'
5
+
6
+ module Pod
7
+ class Command
8
+ class Submit < Command
9
+ self.summary = 'Build and submit to iTunes Connect'
10
+
11
+ def execute(command)
12
+ puts "#{"==>".magenta} #{command}"
13
+ abort unless system(command)
14
+ end
15
+
16
+ self.arguments = [
17
+ CLAide::Argument.new('target_name', false),
18
+ ]
19
+
20
+ def initialize(argv)
21
+ @target_name = argv.shift_argument unless argv.arguments.empty?
22
+ super
23
+ end
24
+
25
+ def login(bundle_identifier)
26
+ puts "You will now have to login to iTunes Connect. Don't worry. Your credentials will be securly stored in your keychain."
27
+ print "Username: "
28
+ username = $stdin.gets.chomp
29
+ abort "Username is required" if username.empty?
30
+
31
+ print "Password for #{username}: "
32
+ password = STDIN.noecho(&:gets).chomp
33
+ abort "Password is required" if password.empty?
34
+ puts ""
35
+
36
+ print "Apple-ID for #{bundle_identifier} (you can find it in iTunes Connect): "
37
+ apple_id = $stdin.gets.chomp
38
+ abort "Apple-ID is required" if apple_id.empty?
39
+
40
+ `security add-generic-password -a #{bundle_identifier}.cocoapods-submit.username -s #{bundle_identifier}.cocoapods-submit.username -w #{username}`
41
+ `security add-generic-password -a #{bundle_identifier}.cocoapods-submit.password -s #{bundle_identifier}.cocoapods-submit.password -w #{password}`
42
+ `security add-generic-password -a #{bundle_identifier}.cocoapods-submit.apple-id -s #{bundle_identifier}.cocoapods-submit.apple-id -w #{apple_id}`
43
+
44
+ return [username, password, apple_id]
45
+ end
46
+
47
+ def credentials(bundle_identifier)
48
+ username = `security find-generic-password -wl #{bundle_identifier}.cocoapods-submit.username`.chomp
49
+ return login(bundle_identifier) if $?.to_i > 0
50
+
51
+ password = `security find-generic-password -wl #{bundle_identifier}.cocoapods-submit.password`.chomp
52
+ return login(bundle_identifier) if $?.to_i > 0
53
+
54
+ apple_id = `security find-generic-password -wl #{bundle_identifier}.cocoapods-submit.apple-id`.chomp
55
+ return login(bundle_identifier) if $?.to_i > 0
56
+
57
+ return [username, password, apple_id]
58
+ end
59
+
60
+ def create_package(target, apple_id)
61
+ ipa = "#{target}.ipa"
62
+ size = File.size(ipa)
63
+ checksum = Digest::MD5.file(ipa)
64
+
65
+ FileUtils.mkdir_p("Package.itmsp")
66
+ FileUtils.copy_entry(ipa, "Package.itmsp/#{ipa}")
67
+
68
+ File.write("Package.itmsp/metadata.xml", metadata(apple_id, checksum, size))
69
+ end
70
+
71
+ def find_best_configuration(target)
72
+ identifiers = target.build_configurations.map { |c| c.build_settings["PROVISIONING_PROFILE"] }
73
+ profiles = identifiers.map { |uuid| CocoapodsSubmit::ProvisioningProfile.from_uuid uuid }
74
+ ranks = profiles.map &:rank
75
+
76
+ return target.build_configurations[ranks.each_with_index.max[1]]
77
+ end
78
+
79
+ def run
80
+ workspaces = Dir.entries(".").select { |s| s.end_with? ".xcworkspace" }
81
+ abort "pod submit only supports one .xcworkspace in the current directory" unless workspaces.count == 1
82
+
83
+ workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspaces[0])
84
+ project = Xcodeproj::Project.open workspace.file_references.first.path
85
+ schemes = Xcodeproj::Project.schemes project.path
86
+
87
+ targets = project.targets.select { |t| t.product_type == "com.apple.product-type.application" }
88
+ if @target_name
89
+ targets = targets.select { |t| t.name == @target_name }
90
+ abort "Target #{@target_name} not found" if targets.count == 0
91
+ end
92
+
93
+ if targets.count > 1
94
+ puts "Could not auto determine the target to submit. Please specify your target like:"
95
+ puts ""
96
+ for target in targets
97
+ puts " * pod submit #{target.name}"
98
+ end
99
+ puts ""
100
+ abort
101
+ end
102
+
103
+ @target = targets.first
104
+ @target_name = @target.name
105
+
106
+ configuration = find_best_configuration @target
107
+ abort "No build configuration found for target #{@target}." unless configuration
108
+
109
+ # grap info.plist and extract bundle identifier
110
+ relative_info_path = @target.build_configuration_list["Release"].build_settings["INFOPLIST_FILE"]
111
+ info_path = File.join File.dirname(project.path), relative_info_path
112
+ info_plist = Plist::parse_xml(info_path)
113
+ identifier = info_plist["CFBundleIdentifier"]
114
+ info_plist["CFBundleVersion"] = (info_plist["CFBundleVersion"].to_i + 1).to_s
115
+ File.write info_path, info_plist.to_plist
116
+
117
+ username, password, apple_id = credentials(identifier)
118
+
119
+ execute "ipa build --verbose --scheme #{@target_name} --configuration #{configuration.name} | xcpretty -c && exit ${PIPESTATUS[0]}"
120
+ execute "ipa info #{@target_name}.ipa"
121
+
122
+ transporter = File.join `xcode-select --print-path`.chomp, "/../Applications/Application\\ Loader.app/Contents/MacOS/itms/bin/iTMSTransporter"
123
+
124
+ create_package(@target_name, apple_id)
125
+ execute "#{transporter} -m verify -f Package.itmsp -u #{username} -p #{password}"
126
+ execute "#{transporter} -m upload -f Package.itmsp -u #{username} -p #{password}"
127
+ `rm -rf Package.itmsp #{@target_name}.ipa #{@target_name}.app.dSYM.zip`
128
+
129
+ time = Time.now.iso8601
130
+ execute "git add ."
131
+ execute "git commit -am 'Submitted to iTunes Connect submit-#{time}-#{@target.name}-#{info_plist["CFBundleShortVersionString"]}-#{info_plist["CFBundleVersion"]}'"
132
+ execute "git tag submit-#{time}-#{@target.name}-#{info_plist["CFBundleShortVersionString"]}-#{info_plist["CFBundleVersion"]}"
133
+ execute "git push && git push --tags"
134
+ end
135
+
136
+ def metadata(apple_id, checksum, size)
137
+ %Q(<?xml version="1.0" encoding="UTF-8"?>
138
+ <package version="software4.7" xmlns="http://apple.com/itunes/importer">
139
+ <software_assets apple_id="#{apple_id}">
140
+ <asset type="bundle">
141
+ <data_file>
142
+ <file_name>#{@target_name}.ipa</file_name>
143
+ <checksum type="md5">#{checksum}</checksum>
144
+ <size>#{size}</size>
145
+ </data_file>
146
+ </asset>
147
+ </software_assets>
148
+ </package>)
149
+ end
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,37 @@
1
+ require 'plist'
2
+
3
+ module CocoapodsSubmit
4
+ class ProvisioningProfile
5
+ def initialize(hash)
6
+ @hash = hash
7
+ end
8
+
9
+ def self.from_uuid(uuid)
10
+ from_file File.expand_path File.join "~/Library/MobileDevice/Provisioning Profiles", "#{uuid}.mobileprovision"
11
+ end
12
+
13
+ def rank
14
+ return 0.0 unless @hash
15
+
16
+ rank = 1.0
17
+ rank *= 0.0 if @hash["Entitlements"]["get-task-allow"]
18
+ rank *= 1.0 / @hash["ProvisionedDevices"].count if @hash["ProvisionedDevices"]
19
+
20
+ return rank
21
+ end
22
+
23
+ def self.from_file(path)
24
+ return nil unless File.exists? path
25
+
26
+ start_string = "<?"
27
+ end_string = "</plist>"
28
+
29
+ profile = File.read(path)
30
+ profile = profile.slice(profile.index(start_string), profile.length)
31
+ profile = profile.slice(0, profile.index(end_string) + end_string.length)
32
+ profile = Plist::parse_xml(profile)
33
+
34
+ new(profile)
35
+ end
36
+ end
37
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module CocoapodsSubmit
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-submit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oliver Letterer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shenzhen
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: xcpretty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: plist
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: CocoaPods plugin that let's you build and submit builds to iTunes Connect,
84
+ thanks to nomad/Shenzhen.
85
+ email:
86
+ - oliver.letterer@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - cocoapods-submit.gemspec
97
+ - lib/cocoapods_plugin.rb
98
+ - lib/pod/command/submit.rb
99
+ - lib/provisioning_profile.rb
100
+ - lib/version.rb
101
+ homepage: https://github.com/Sparrow-Labs/cocoapods-submit
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Build and submit ios projects to iTunes Connect
125
+ test_files: []