capkin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2b9796e5c2613d9609e4052216f0bd39942aef9d
4
+ data.tar.gz: b2a519ddb95c7cbd44432edfe0d672e385097710
5
+ SHA512:
6
+ metadata.gz: 2d4d176737c53651bccda74417666f681de7e52ff2597a6962415a7516ff522d41a68542ef04842dd7fd116efe89cfc7875c62889c0b48884a9ca0291c9ff6ed
7
+ data.tar.gz: d9d5c8daaddbd5aebb614a350237d6ff20ca0e8e677519fc5628dae4423c07771db8b8a34ecac11c2ab045712d707891c9a4ba064ba235684b9b835d6770db0b
@@ -0,0 +1,7 @@
1
+ Gemfile.lock
2
+ .bundle/
3
+ log/*.log
4
+ pkg/
5
+
6
+ Capkin
7
+ build/*
@@ -0,0 +1,68 @@
1
+ Capkin
2
+ ======
3
+
4
+ * Upload your `Android Apps` ➔ `Google Play`
5
+ * Uploads your `.apk` to Alpha, Beta or Production stages.
6
+ * Promote apk from stages.
7
+
8
+
9
+ ## Install
10
+
11
+
12
+ gem install capkin
13
+
14
+
15
+ ## Use
16
+
17
+ To upload a new `.apk`:
18
+
19
+ ```sh
20
+ capkin production
21
+ capkin beta
22
+ capkin alpha
23
+ ```
24
+
25
+ To move current version to another stage:
26
+
27
+ **TODO**
28
+
29
+ ## Capkin
30
+
31
+ Config file:
32
+
33
+ ```
34
+ name: 'Foo'
35
+ app: 'com.your.app'
36
+ build: 'build/'
37
+ ```
38
+
39
+
40
+ ## Login/Auth
41
+
42
+ On Google Developer:
43
+
44
+ > Create a new project
45
+
46
+ On Play:
47
+
48
+ > Settings > API access > Link your developer project
49
+
50
+
51
+ ### JSON Key
52
+
53
+ > APIs & auth > Credentials > Add credential > Service Account > JSON
54
+
55
+
56
+ ```sh
57
+ export GOOGLE_APPLICATION_CREDENTIALS='/path/to/googs.json'
58
+ ```
59
+
60
+
61
+ ### Client/Secret
62
+
63
+ > APIs & auth > Credentials > Add credential > OAuth 2.0 client ID > Other
64
+
65
+ **TODO**
66
+
67
+
68
+ ## Capkin
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'capkin'
4
+
5
+ Capkin::CLI.work!(ARGV)
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'capkin/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'capkin'
8
+ s.version = Capkin::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+
11
+ s.authors = ['Marcos Piccinini', 'Jorge Fernando']
12
+ s.homepage = 'http://github.com/fireho/capkin'
13
+ s.email = 'see@github.com'
14
+ s.description = 'Uploads your apps to Google Play'
15
+ s.summary = 'Uploads your apps to Google Play'
16
+ s.license = 'MIT'
17
+
18
+ s.executables = ['capkin']
19
+ s.default_executable = 'capkin'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.require_paths = ['lib']
24
+
25
+ s.add_dependency 'thor'
26
+ s.add_dependency 'paint'
27
+ s.add_dependency 'google-api-client', '0.9.pre3'
28
+ s.add_dependency 'googleauth'
29
+ end
@@ -0,0 +1,13 @@
1
+ require 'pry'
2
+ require 'yaml'
3
+ require 'paint'
4
+ require 'fileutils'
5
+
6
+ require 'googleauth'
7
+ require 'google/apis/androidpublisher_v2'
8
+
9
+ # Capkin. Uploading your apks since 2015!
10
+ module Capkin
11
+ autoload :CLI, 'capkin/cli'
12
+ autoload :Robot, 'capkin/robot'
13
+ end
@@ -0,0 +1,30 @@
1
+ module Capkin
2
+ # Capking Command Line
3
+ class CLI
4
+ # Using class methods
5
+ class << self
6
+ #
7
+ # Check config file
8
+ #
9
+ def check_capkin_file
10
+ return if File.exist?('Capkin')
11
+ puts Paint['Creating Capkin file...', :red]
12
+ FileUtils.cp File.join(File.dirname(__FILE__), 'Capkin'), '.'
13
+ puts Paint['✓ Config file `Capkin` created, edit and re-run.', :green]
14
+ exit
15
+ end
16
+
17
+ def read_file
18
+ @config = YAML.load_file('Capkin')
19
+ msg = "✓ Config file OK! '#{@config['app']}' [#{@config['name']}]"
20
+ puts Paint[msg, :green]
21
+ end
22
+
23
+ def work!(params)
24
+ check_capkin_file
25
+ read_file
26
+ Capkin::Robot.new(@config, params).upload_apk!
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,81 @@
1
+ module Capkin
2
+ # Oauth2
3
+ # grant_type=authorization_token|refresh_token
4
+ # code=
5
+ # client_id=<the client ID token created in the APIs Console>
6
+ # client_secret=<the client secret corresponding to the client ID>
7
+ # refresh_token=<the refresh token from the previous step>
8
+ # start a new edit
9
+ # headers = {
10
+ # 'access_token' => ENV['CAPKIN_CLIENT']
11
+ # }
12
+ # auth.apply(headers)
13
+ class Robot
14
+ SCOPE = ['https://www.googleapis.com/auth/androidpublisher']
15
+ STAGE = 'alpha'
16
+ attr_reader :apk, :app, :pub, :pkg, :stage, :track, :source
17
+
18
+ def initialize(config, stage = nil)
19
+ @app = config['app']
20
+ @pkg = config['name']
21
+ @source ||= File.join(config['build'], "#{@app}.apk")
22
+ stage = stage.join if stage.respond_to?(:join)
23
+ @stage = stage.strip.empty? ? STAGE : stage.strip
24
+
25
+ init_google
26
+ puts Paint["Publishing new APK: ./#{source} ➔ '#{@stage}'", :blue]
27
+ end
28
+
29
+ def init_google
30
+ # Get authorization!
31
+ @auth = Google::Auth.get_application_default(SCOPE)
32
+ # create a publisher object
33
+ @pub = Google::Apis::AndroidpublisherV2::AndroidPublisherService.new
34
+ @pub.authorization = @auth
35
+ end
36
+
37
+ # Create new editio
38
+ def edit
39
+ @edit ||= pub.insert_edit(pkg)
40
+ end
41
+
42
+ def track
43
+ @track ||= pub.get_track(pkg, edit.id, stage)
44
+ end
45
+
46
+ # Uploads the APK
47
+ def upload_apk!
48
+ @apk = pub.upload_apk(pkg, edit.id, upload_source: source)
49
+ puts Paint["✓ APK uploaded! ##{apk.version_code}", :green]
50
+ track!
51
+ puts Paint["✓ All done! ##{apk.inspect}", :green]
52
+ rescue Google::Apis::ClientError => e
53
+ if e.to_s =~ /apkUpgradeVersionConflict/
54
+ puts Paint['✓ Version already exists on play store!', :yellow]
55
+ else
56
+ puts Paint["✗ Problem with upload: #{e}", :red]
57
+ raise e
58
+ end
59
+ end
60
+
61
+ # Update the alpha track to point to this APK
62
+ # You need to use a track object to change this
63
+ def track!
64
+ puts Paint["Pushing APK ➔ '#{@track.track}'", :blue]
65
+ track.update!(version_codes: [apk.version_code])
66
+
67
+ # Save the modified track object
68
+ pub.update_track(pkg, edit.id, stage, track)
69
+
70
+ commit!
71
+ end
72
+
73
+ # Commit the edit
74
+ def commit!
75
+ pub.commit_edit(pkg, edit.id)
76
+ rescue Google::Apis::ClientError => e
77
+ puts Paint["✗ Problem commiting: #{e}", :red]
78
+ raise e
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,3 @@
1
+ module Capkin
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capkin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marcos Piccinini
8
+ - Jorge Fernando
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-09-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: paint
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: google-api-client
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 0.9.pre3
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '='
54
+ - !ruby/object:Gem::Version
55
+ version: 0.9.pre3
56
+ - !ruby/object:Gem::Dependency
57
+ name: googleauth
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: Uploads your apps to Google Play
71
+ email: see@github.com
72
+ executables:
73
+ - capkin
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - README.md
79
+ - bin/capkin
80
+ - capkin.gemspec
81
+ - lib/capkin.rb
82
+ - lib/capkin/Capkin
83
+ - lib/capkin/cli.rb
84
+ - lib/capkin/robot.rb
85
+ - lib/capkin/version.rb
86
+ homepage: http://github.com/fireho/capkin
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.8
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Uploads your apps to Google Play
110
+ test_files: []