build_47 0.1.7 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +13 -5
  2. data/bin/build_47 +35 -25
  3. data/lib/build_47.rb +41 -17
  4. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 828eafd6895dfa62cc27b4bf5f97d558cf0bea26
4
- data.tar.gz: b563a907870d5b4052369161fec9dcc1a497b5ea
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTk2ZmViMjJkMTkwZTU5ZDA0YWIwYjA2ZThkZjZkOGNiYzA5YzNlZg==
5
+ data.tar.gz: !binary |-
6
+ MGQ3MGI2ZTRkMDY5N2YxNDA2ODI1YzljNDc4ZjdhODk1NjBmOWYzZA==
5
7
  SHA512:
6
- metadata.gz: 88b3d7b5c8aa4e08c19d921be965203fd0dfbc0d95abba29aaba5f42273a9ad99ba8180e6492f346e41f4abe2dad268c6e9def5eb15cd7fbd7fcac6b69d7f437
7
- data.tar.gz: 81f4c44dc7ea9cc6dc03400f01e378e9996e74710dd697156949616c754eca899271256051188d03181dfe26854be5a5fb17f5fed94df8731a8674d6a6143409
8
+ metadata.gz: !binary |-
9
+ YjBiMjNiODk0NTM3Y2JlMGVkMWU5OTJjMTQ3YzM1YTNkYTZiOWRkM2NhZGRk
10
+ ZjM3MGJhMTcwNWM4YzAzYjNiNzdkM2MyZTNjZmY1NTczNmUyNWZjNGQwNjdk
11
+ MTA3MWI2NDVlMjc0ZjMzNWM2ZWZkODdhMWE3ZGZlOWIyMzMwNjg=
12
+ data.tar.gz: !binary |-
13
+ NjdmYzlmZTM0ZDI4MTZjZTI1NWYxYzI0ZGY5YmQ2Y2UyZDMzYmVjZmI3M2I4
14
+ ZDdhMzlmMTRhODNjYjQ3MzBkNDU1NmMzZTBmODg3ZGEzODE0NjRhYjFjMmE1
15
+ MmQ2ODU2NTQ1M2RjOGE3NjVhYjM3ZWY0OTNkODBkZTk3MWRmNmU=
data/bin/build_47 CHANGED
@@ -1,43 +1,53 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
- require 'build_47'
4
+ require './lib/build_47'
5
5
 
6
- # replace me with https://github.com/visionmedia/commander !
7
- options = {}
8
- OptionParser.new do |opts|
9
- opts.on("-t", "--token TOKEN", "Require processor class name") do |t|
6
+ options = { environment: 'Production',
7
+ release_notes: '',
8
+ make_active: false,
9
+ reuse_version_number: false,
10
+ reset_bundle_identifier: false,
11
+ notify_users_on_activation: true }
12
+ OptionParser.new do |opts|
13
+ opts.on('-t', '--token TOKEN', 'Require processor class name') do |t|
10
14
  options[:token] = t
11
15
  end
12
- opts.on("-a", "--app_id id", "App's ID") do |t|
16
+ opts.on('-a', '--app_id id', "App's ID") do |t|
13
17
  options[:app_id] = t
14
18
  end
15
- opts.on("-e", "--environment ENVIRONMENT", "Select environment -- Test or Production") do |t|
19
+ opts.on('-e', '--environment ENVIRONMENT', 'Select environment -- Test or Production') do |t|
16
20
  options[:environment] = t
17
21
  end
18
- opts.on("-p", "--platform PLATFORM", "Require platform, such as iOS or Android") do |t|
19
- options[:platform] = t
22
+ opts.on('-p', '--platform PLATFORM', 'Deprecated: platform, determined by file extension') do
23
+ puts '-p, --platform option is deprecated, the platform will be determined by file extension'
20
24
  end
21
- opts.on("-f", "--file FULL PATH", "full path to file for uploading") do |t|
25
+ opts.on('-f', '--file FULL PATH', 'full path to file for uploading') do |t|
22
26
  options[:path] = t
23
27
  end
24
- opts.on("-r", "--release_notes RELEASE NOTES", "release notes -- not required") do |t|
25
- options[:notes] = t
28
+ opts.on('-r', '--release_notes RELEASE NOTES', 'release notes -- not required') do |t|
29
+ options[:release_notes] = t
30
+ end
31
+ opts.on('-m', '--make_active', 'make the build active after processing -- not required') do
32
+ options[:make_active] = true
33
+ end
34
+ opts.on('-i', '--reset_bundle_identifier', 'reset the bundle identifier if changed -- not required') do
35
+ options[:reset_bundle_identifier] = true
36
+ end
37
+ opts.on('-u', '--reuse_version', 'reuse the version number if it already exists -- not required') do
38
+ options[:reuse_version_number] = true
39
+ end
40
+ opts.on('-n', '--notify_users true|false', 'notify users when the build is activated -- not required') do |t|
41
+ options[:notify_users_on_activation] = %w[true t yes y 1].include?(t.downcase)
26
42
  end
27
43
  end.parse!
28
44
 
29
- options[:environment] ||= 'Production'
30
- options[:platform] ||= 'iOS'
31
- options[:notes] ||= 'none'
32
-
33
- puts "you must provide a path to a particular build file" if options[:path].nil?
34
- puts "you must provide a token (i.e. -t <token>). You can find this for your account in the App47 dashbard)" if options[:token].nil?
35
- puts "you must provide an App Id (i.e. -a <app_id>). You can find this for your account in the App47 dashbard)" if options[:app_id].nil?
36
-
37
- if( !options[:path].nil? && !options[:token].nil? && !options[:app_id].nil? )
38
- build = Build47.new(options[:token])
39
- build.push(options[:app_id], options[:platform], options[:environment], options[:path], options[:notes])
40
- else
45
+ if options[:path].nil? || options[:token].nil? || options[:app_id].nil?
46
+ puts 'you must provide a path to a particular build file' if options[:path].nil?
47
+ puts 'you must provide a token (i.e. -t <token>). You can find this for your account in the App47 dashboard)' if options[:token].nil?
48
+ puts 'you must provide an App Id (i.e. -a <app_id>). You can find this for your account in the App47 dashboard)' if options[:app_id].nil?
41
49
  puts "i.e build_47 -t 'some token' -a some app_id -f path_to_file"
42
- puts "default arguments are -e Production -p iOS -r notes so if you want to push to Test or declare this as an Android build, use those flags."
50
+ puts 'default arguments are -e Production -p iOS -r notes so if you want to push to Test or declare this as an Android build, use those flags.'
51
+ else
52
+ Build47.api_v1_upload(options)
43
53
  end
data/lib/build_47.rb CHANGED
@@ -1,23 +1,47 @@
1
1
  require 'rest_client'
2
2
 
3
+ #
4
+ # Do the work of uploading to to the App47 server using API V1
5
+ #
3
6
  class Build47
4
-
5
- def initialize(account_token)
6
- @token = account_token
7
+
8
+ #
9
+ # Perform the upload to the server
10
+ #
11
+ def self.api_v1_upload(options)
12
+ app_id = options.delete(:app_id)
13
+ token = options.delete(:token)
14
+ load_file(options)
15
+
16
+ RestClient::Request.execute(method: :post,
17
+ url: "https://cirrus.app47.com/api/apps/#{app_id}/builds",
18
+ payload: {
19
+ multipart: true,
20
+ build: options
21
+ },
22
+ headers: { accept: 'application/json', 'X-Token': token },
23
+ raw_response: true) do |response|
24
+ puts "response code: #{response.code}"
25
+ end
7
26
  end
8
-
9
- def push(app_id, platform, env, file_path, release_notes)
10
- build_doc = {
11
- build: {
12
- platform: platform,
13
- environment: env,
14
- upload: File.new(file_path),
15
- build_file: file_path.split('/')[-1],
16
- release_notes: release_notes,
17
- make_active: true
18
- }
19
- }
20
- response = RestClient.post "https://cirrus.app47.com/api/apps/#{app_id}/builds", build_doc, {"X-Token"=> @token, accept: :json}
21
- puts "response code: #{response.code}"
27
+
28
+ #
29
+ # Load file for processing, making sure it exists
30
+ #
31
+ def self.load_file(options)
32
+ file_path = options.delete(:path)
33
+ raise "File not found: #{file_path}" unless File.exist?(file_path)
34
+
35
+ options[:build_upload] = File.new(file_path, 'rb')
36
+ extension = file_path.split('.').last
37
+ options[:platform] = case extension
38
+ when 'ipa'
39
+ 'iOS'
40
+ when 'apk'
41
+ 'Android'
42
+ else
43
+ 'Windows'
44
+ end
45
+ options
22
46
  end
23
47
  end
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: build_47
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Andrew Glover
7
+ - Chris Schroeder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-05 00:00:00.000000000 Z
11
+ date: 2019-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.6.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.0
27
- description: A simple Ruby utility for pushing builds to App47
27
+ description: A simple utility for pushing builds to App47
28
28
  email: support@app47.com
29
29
  executables:
30
30
  - build_47
@@ -42,19 +42,19 @@ require_paths:
42
42
  - lib
43
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ">="
50
+ - - ! '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.6.11
55
+ rubygems_version: 2.6.9
56
56
  signing_key:
57
- specification_version: 3
57
+ specification_version: 4
58
58
  summary: Pushes an iOS or Android build file to App47 for distribution via an App
59
59
  store.
60
60
  test_files: []